On 26/09/2012, at 5:56 AM, Gwern Branwen wrote:

> On Tue, Sep 25, 2012 at 1:42 PM, Rishabh Jain <[email protected]> wrote:
>> f x 0 = []
>> f (x:xs) y | x `mod` 2 == 0 = x : (f xs y) | otherwise = x : (f xs (y-1))
>> 
>>> f [0..] 4
>>> [0,1,2,3,4,5,6,7]
> 
> Tsk, tsk. So ugly. How's this:
> 
>> let f x = take x . filter odd

Wrong.  The original poster gave an explicit example
in which even elements were *retained* in the output,
they just weren't *counted*.


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to