seq evaluates to Weak Head Normal Form (WHNF). WHNF is the first contructor. So your use of seq only evaluates the first number and the cons. I.E., it evaluates to:
I've got the following code, and I'm not sure why the seq seems to be doing nothing. The code should never terminate if the seq were forcing the full evaluation of y. Instead, it runs just fine (though stack overflows if I ask for too many elements of primes). I didn't see anything in the tutorial section of haskell.org that seems to explain this -- pointers to a useful source would be welcome.
sieve :: [Int] -> [Int]
sieve xs =
let ys = filter (\z -> 0 /= z `mod` head xs) xs
in seq ys $ head xs:sieve ys
primes = sieve [2..]
thanks
Lee
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners