Skip to content

Instantly share code, notes, and snippets.

@23Skidoo
Created October 23, 2012 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 23Skidoo/3937737 to your computer and use it in GitHub Desktop.
Save 23Skidoo/3937737 to your computer and use it in GitHub Desktop.
Removing parts of an infinite list
-- http://stackoverflow.com/questions/13026095/lack-of-understanding-infinite-lists-and-seq-operator
module Main
where
main :: IO ()
main = print (take 100 (foo 2 [1..]))
foo :: Int -> [a] -> [a]
foo n l = go l
where
go xs = let (toKeep, rest) = splitAt n xs
in toKeep ++ go (drop n rest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment