>
> It only works for infinite lists, though
>

you wanted it :)

(fix $ \f xs -> case xs of { (x:_: xs) -> x : f xs; _ -> [] }) [1..10]
= [1,3,5,7,9]

here you go :)

2010/6/8 Yitzchak Gale <g...@sefer.org>

> Christopher Done wrote:
> > 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...
>
> Ho, good shot! It only works for infinite lists, though:
>
> 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
>



-- 
Ozgur Akgun
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to