Revision as of 12:58, 7 August 2011 by WillNess
I am a newbie, interested in Haskell.
I like this:
primes = 2 : g (fix g) -- double staged production idea due to M. O'Neill where g xs = 3 : (gaps 5 $ foldi (\q:qs -> (q:) . union qs) [[p*p, p*p+2*p..] | p <- xs]) fix g = xs where xs = g xs gaps k s@(x:xs) = if k < x -- | k<=x = minus [k,k+2..] xs then k : gaps (k+2) s -- inlined to avoid a space leak else gaps (k+2) xs