isPrime definition

Alex Teslin <[email protected]> Wed, 18 Apr 2007 21:19:52 +0100 (BST)
Newsgroups gmane.comp.lang.haskell.hugs.user
Message-ID <[email protected]>
--===============1215795969==
Content-Type: multipart/alternative; boundary="0-420263948-1176927592=:1460"
Content-Transfer-Encoding: 7bit

--0-420263948-1176927592=:1460
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

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 di=
visors function previously defined.
=20
I have managed to define the divisor function like this:

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

but when i am trying with isPrime function using divisors and list compre=
hension - 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
      =20
---------------------------------
 Yahoo! Answers - Got a question? Someone out there knows the answer. Try=
it now.
--0-420263948-1176927592=:1460
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hi, I am a newbie in Haskell and have a trivial question.<br><br>I am usi=
ng Simon Thomson's textbook for learning Haskell with Hugs.<br>I am stack=
 with exer 5.10, which asks to define isPrime function using divisors fun=
ction previously defined.<br>&nbsp;<br>I have managed to define the divis=
or function like this:<br><br>divisors :: Int -&gt; [Int]<br>divisors n =3D=
 [x | x&lt;-[1..n], n `mod` x =3D=3D 0]<br><br>but when i am trying with =
isPrime function using divisors and list comprehension - i am lost becaus=
e the type signature should be isPrime :: Int-&gt;Bool<br><br>But any lis=
t comprehension generates a list, which is not what i want.<br><br>Any su=
ggestions please?<br><br>Thank you<p>&#32;
      <hr size=3D1>=20
Yahoo! Answers - Got a question? Someone out there knows the answer. <a
href=3D"http://uk.answers.yahoo.com/;_ylc=3DX3oDMTEydmViNG02BF9TAzIxMTQ3M=
TcxOTAEc2VjA21haWwEc2xrA3RhZ2xpbmU">Try
it now</a>.
--0-420263948-1176927592=:1460--

--===============1215795969==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Hugs-Users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/hugs-users

--===============1215795969==--