More specifically, how do I generate a new list of every Nth element from an existing infinite list?
E.g. if the list is [5, 3, 0, 1, 8, 0, 3, 4, 0, 93, 211, 0
[5, 3, 0, 1, 8, 0, 3, 4, 0, 93, 211, 0
This seems a slightly better use of unfold:
everyNth :: Int -> [a] -> [a] everyNth n = unfoldr g where g [] = Nothing g xs = let (ys, zs) = splitAt n xs in Just (head ys, zs)
Or even better, use Data.List.Spit:
everyNth n = (map head) . chunksOf n