[Haskell-beginners] Why does this list comprehension return an empty list?

Kim-Ee Yeoh ky3 at atamo.com
Wed Jul 24 02:47:24 CEST 2013


On Tue, Jul 23, 2013 at 3:53 PM, Costello, Roger L. <costello at mitre.org>wrote:

> Also, how would I modify this:
>
>         [(a,b) | a <- f xs, b <- g xs]
>
> so that it produces this:
>
>         [("a",[])]
>

Try:  [(a,b) | a <- f xs | b <- g xs]

Note the 2nd parallel bar. You may have to enable a Parallel List
Comprehension pragma or somesuch.

Everyone else has given great explanations about your curious definitions
of f and g and why the original does what it does. Well worth looking into.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130724/34c13d88/attachment.htm>


More information about the Beginners mailing list