It only works for infinite lists, though
Christopher Done wrote:Ho, good shot! It only works for infinite lists, though:
> Can't forget fix in a game of code golf!
>
>> (fix $ \f (x:_: xs) -> x : f xs) [1..]
> => [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,4...
Prelude> (fix $ \f (x:_: xs) -> x : f xs) [1..10]
[1,3,5,7,9*** Exception: <interactive>:1:7-30: Non-exhaustive patterns in lambda
Regards,
Yitz
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe