[Haskell-cafe] I need help getting started

mitchell at kaplan2.com mitchell at kaplan2.com
Sun Apr 25 11:49:05 EDT 2010


Hi David,

Thanks for the suggestion.  I took a quick look at your article, and I'll
have to spend a little more time on it.  "Delicious Primes?"  Great name.
Also I appreciate your correct use of the phrase "begging the question".
The common and incorrect use that I hear constantly is one of my pet peeves.

	Mitchell

-----Original Message-----
From: David Anderson [mailto:dave at natulte.net] 
Sent: Sunday, April 25, 2010 11:18 AM
To: mitchell at kaplan2.com
Cc: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] I need help getting started

On Sun, Apr 25, 2010 at 6:34 AM,  <mitchell at kaplan2.com> wrote:
> Hi,
>
>
>
> I’m just starting to learn, or trying to learn Haskell.  I want to write a
> function to tell me if a number’s prime.  This is what I’ve got:
>
>
>
> f x n y = if n>=y
>
>           then True
>
>           else
>
>           if gcd x n == 1
>
>           then f x (n+1) y
>
>           else False
>
>
>
>
>
> primeQ x = f x 2 y
>
>   where y = floor(sqrt(x))
>
>
>
> The compiler is very unhappy.  Apparently there’s some ambiguity in this,
> and I’m kind of running around in circles.  I’d appreciate any help that
> will get me started.

I won't go over your code, since more skilled people than me are
already helping you out with it. However, once you've finished your
own implementation, you may be interested in
http://blog.natulte.net/posts/2010-04-23-delicious-primes.html . It
may give you some interesting insights, imho as the post's author :-).

- Dave

>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>




More information about the Haskell-Cafe mailing list