Create a gist now

Instantly share code, notes, and snippets.

Removing parts of an infinite list
module Main
main :: IO ()
main = print (take 100 (foo 2 [1..]))
foo :: Int -> [a] -> [a]
foo n l = go l
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