[Haskell-cafe] list comprehension doesn't work

John knowledge1202 at gmail.com
Tue May 14 17:41:36 CEST 2013


Danny Gratzer wrote
> Well you've deleted the portion of the code referring to x and y.
> 
> listPairs = [(a*b, y) | y <- [0..], a <- [0..], b <- [0..], (a*b) > 5,
> (a*b) < 500, (y*y) < 1001, mod y (a*b) == 0]
> 
> This will still never terminate however.

oh I see, but as you say it doesn't terminate and I get nothing. Does it
mean, that the function is wrong in this place?

Some questions:
1. Does the order of conditions affect the result at all?
2. The "," means AND or &&, right? So how do you write OR || instead? E.g
z<-[1..10] OR z<-[100..110].
Ofcourse it doesn't relate to this topic, but I wanted to know it.

Since I'm a very beginner I think the approach of Daniel is slightly complex
for me to comprehend, right?
Allthough I tried it, but it says isProduct and isSquer are not in Scope, so
I should define them first in WHERE-Clause right?

Thanks again to all




--
View this message in context: http://haskell.1045720.n5.nabble.com/list-comprehension-doesn-t-work-tp5730158p5730167.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list