[Hugs-users] isPrime definition

Alex Teslin alexteslin at yahoo.co.uk
Wed Apr 18 16:19:52 EDT 2007


Hi, I am a newbie in Haskell and have a trivial question.

I am using Simon Thomson's textbook for learning Haskell with Hugs.
I am stack with exer 5.10, which asks to define isPrime function using divisors function previously defined.
 
I have managed to define the divisor function like this:

divisors :: Int -> [Int]
divisors n = [x | x<-[1..n], n `mod` x == 0]

but when i am trying with isPrime function using divisors and list comprehension - i am lost because the type signature should be isPrime :: Int->Bool

But any list comprehension generates a list, which is not what i want.

Any suggestions please?

Thank you
       
---------------------------------
 Yahoo! Answers - Got a question? Someone out there knows the answer. Tryit now.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/hugs-users/attachments/20070418/1209c8dd/attachment-0001.htm


More information about the Hugs-Users mailing list