(no title)
shangaslammi | 11 years ago
As it says, you can evaluate a single line Haskell "expression" and top-level declarations (like the sieve example) are not expressions. In addition, the sieve example declares an infinite list so there's no sensible way to print it.
You can fix all the above by using a let-expression on single line and only evaluating a finite part of the list using the 'take' function.
let { primes = sieve [2..]; sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0] } in take 10 primes
No comments yet.