[Haskell-cafe] Removing alternate items from a list

Mike Dillon mike at embody.org
Tue Jun 8 11:02:59 EDT 2010


OK, here's mine:

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

-md

begin R J quotation:
> 
> 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.
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3

> _______________________________________________
> 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