[Haskell-cafe] Removing alternate items from a list
Bill Atkins
watkins at alum.rpi.edu
Mon Jun 7 19:21:37 EDT 2010
alts :: [a] -> [a]
alts xs = map fst . filter snd $ zip xs (cycle [False, True])
Prelude> alts [0, 1..5]
[1,3, 5]
On Sunday Jun 6, 2010, at 10:46 AM, R J wrote:
> 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]?
>
>
> The New Busy is not the old busy. Search, chat and e-mail from your inbox. Get started. _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list