[Haskell-cafe] Removing alternate items from a list

Alexey Levan exlevan at gmail.com
Tue Jun 8 10:00:57 EDT 2010


2010/6/6 R J <rj248842 at hotmail.com>:
> What's the cleanest definition for a function f :: [a] -> [a] that takes a
> list and returns the same list, with alternate items removed?  e.g., f [0,
> 1, 2, 3, 4, 5] = [1,3,5]?

f x = [y | (True, y) <- zip (cycle [False, True]) x]


More information about the Haskell-Cafe mailing list