in reply to Challenge: Another Infinite Lazy List
Here's my naive Haskell implementation, done without studying any of the others here, though after finishing and looking briefly through them, it is rather similar to some.
I'm not sure how fast it is comparatively (especially since I'm running it in Hugs), but I can get a million items in about 20 seconds.merge (x:xs) (y:ys) | x < y = x : merge xs (y:ys) | x > y = y : merge (x:xs) ys | x == y = x : merge xs ys supermerge (x:[]) = x supermerge (x:y:ys) = supermerge $ (merge x y) : ys multiples x = map (*x) [1..] multiplesFromList x = supermerge $ map (multiples) x limbic's_challenge = multiplesFromList [2,3,5]
|
---|
In Section
Seekers of Perl Wisdom