[Haskell-cafe] This is an interesting place to showcase Haskell.
Dan Weston
westondan at imageworks.com
Fri Jun 15 14:42:23 EDT 2007
It does not bode well that the first example I looked at (which I chose
because it maximally would highlight the benefits of Haskell over other
languages):
http://en.literateprograms.org/Sieve_of_Eratosthenes_%28Haskell%29
has the following "Haskell" program.
primes :: [Int] -> [Int]
primes :: [] -> []
primes (n:ns) = n : primes (filter (\v -> v `mod` n /= 0) ns)
Not only are there two conflicting type declarations (making this
uncompilable), but after the "obvious" syntactic fix:
primes :: [Int] -> [Int]
primes [] = []
primes (n:ns) = n : primes (filter (\v -> v `mod` n /= 0) ns)
primes (n:ns) gives the wrong answer unless n == 2.
*P> primes [2..47]
[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
*P> primes [5..47]
[5,6,7,8,9,11,13,17,19,23,29,31,37,41,43,47]
*P> length . primes $ [100..200]
100
As there are so far relatively few Haskell programs listed (~100),
perhaps an interested party might go through and do a sanity check on them.
Dan
Michael T. Richter wrote:
> http://en.literateprograms.org/LiteratePrograms:Welcome
>
> There's some Haskell there already, but I think a lot more could be
> shown there. Even code dumps of things would be nice. They can always
> be explained later.
>
> --
> *Michael T. Richter* <ttmrichter at gmail.com
> <mailto:ttmrichter at gmail.com>> (*GoogleTalk:* ttmrichter at gmail.com)
> /Never, ever, ever let systems-level engineers do human interaction
> design unless they have displayed a proven secondary talent in that
> area. Their opinion of what represents good human-computer interaction
> tends to be a bit off-track. (Bruce Tognazzini)/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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