Well, definitely, isSqrt should be called isSquare.
On Tue, May 14, 2013 at 5:22 PM, Daniel Díaz Casanueva < dhelta.d...@gmail.com> wrote: > You can always write it like this: > > listPairs = [ (x,y) | x <- [6 .. 499] , y <- [0 .. 1000] , isProduct x , > isSqrt y , mod y x == 0 ] > > So you have the bounds for x and y, and then the conditions. You then need > to define isProduct and isSqrt with types > > isProduct :: Int -> Bool > isSqrt :: Int -> Bool > > Hopefully, these problems will look easier separately. > > Well, it's just an idea. > > Good luck, > Daniel Díaz. > > > On Tue, May 14, 2013 at 4:57 PM, John <knowledge1...@gmail.com> wrote: > >> Hi, >> >> I have to write a function which returns a list of all pairs (x,y) where >> x, >> y ∈ N AND: >> – x is the product of two natural numbers (x = a · b, where a, b ∈ N) AND >> – x is really bigger than 5 but really smaller than 500, AND >> – y is a squer number (y = c² where c ∈ N) NOT greater than 1000, AND >> – x is a divisor of y. >> >> My attempt is as follows: >> >> listPairs :: [(Int, Int)] >> listPairs = [(x,y) | x<-[0..], y<-[0..], x<-[0..]*[0..], x > 5, x < 500, >> (y*y) < 1001, mod y x == 0] >> >> However it doesn't work unfortunatly >> >> Could anyone tell me where my mistake is? >> >> Thanks. >> >> >> >> -- >> View this message in context: >> http://haskell.1045720.n5.nabble.com/list-comprehension-doesn-t-work-tp5730158.html >> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > E-mail sent by Daniel Díaz Casanueva > > let f x = x in x > -- E-mail sent by Daniel Díaz Casanueva let f x = x in x
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe