1. multi-line expressions aren't supported by the REPL.
2. You will need to use `let x = ..` syntax in the REPL (This is because the REPL are just so called IO-actions and the `let` syntax defines variables within its lexical scope)
You could try this:
> let sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0]
> let primes = sieve [2..]
> primes !! 3
> primes !! 4
Nice part abou this code is eventhough you express calculating ALL primes. It will only calculate upto the 3rd and the 4th prime due to lazy evaluation. This is one of the great strengths of haskell.
1. multi-line expressions aren't supported by the REPL.
2. You will need to use `let x = ..` syntax in the REPL (This is because the REPL are just so called IO-actions and the `let` syntax defines variables within its lexical scope)
You could try this:
Nice part abou this code is eventhough you express calculating ALL primes. It will only calculate upto the 3rd and the 4th prime due to lazy evaluation. This is one of the great strengths of haskell.