
On 26/09/2012, at 12:28 PM, Gwern Branwen wrote:
On Tue, Sep 25, 2012 at 8:17 PM, Richard O'Keefe
wrote: Wrong. The original poster gave an explicit example in which even elements were *retained* in the output, they just weren't *counted*.
You are at least the fourth person to email me now to point this out. I'm glad I could make four people's day better with the joy of correction...
But I never said it was a full solution - please note that I did include the output of the function!
The "tsk tsk" is probably what made people so keen to reply.
One could consider it a partial solution, however: that gives you the _nth_ odd, so if you want a list of numbers up to the _nth_ odd, that gives you a stop condition - 'takeWhile =/ nth+1' etc.
That doesn't work either. Consider the list [1,1,1,1,1]. The element just after the 5th odd number in the list is 1; takeWhile (/= 1) will thus return [] instead of [1,1,1,1]. |A 2N traverse
(which laziness might fuse to just 1 traverse, dunno).
Not in this case, for fairly obvious reasons.