[Haskell-cafe] list comprehension doesn't work

Danny Gratzer danny.gratzer at gmail.com
Tue May 14 17:48:15 CEST 2013


> 1. Does the order of conditions affect the result at all?
>

Conditions, I don't believe so, the ordering/placement of bindings though
can effect the results a great deal.

When I say bindings, I mean something that involves a <-


> 2. The "," means AND or &&, right? So how do you write OR || instead? E.g
> z<-[1..10] OR z<-[100..110].
>

For that scenario I'd just append the lists, z <- [1..10]++[100..110], if
you wanted an or in conditions, you'd just use ||



> Allthough I tried it, but it says isProduct and isSquer are not in Scope,
> so
> I should define them first in WHERE-Clause right?
>

Yep, eg

listPairs = [...]
  where isSquare = ...
           isProduct = ...
-- 
Danny Gratzer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130514/4288b38e/attachment.htm>


More information about the Haskell-Cafe mailing list