From: Caleb Clausen Date: 2010-04-13T02:00:41+09:00 Subject: Re: Is it possible, a fully general Enumerable#recursive ? > On Apr 12, 11:08 am, Robert Klemme wrote: > >> I don't really understand why this thread seems to be so complicated. >> I suspect that either I am missing something or not understanding >> properly, or other contributors to this thread are missing something. >> :-) I find this subject extremely confusing. Colin's answer to my last email is still causing me puzzlement. On 4/12/10, Intransition wrote: > I think I see what the confusion is. Your version of recursive looses > all the nested structure of the original. And so works fine for most > cases, as long that is what one wants/expects. I've been trying to do > it such that the nested structure stays intact. e.g. > > [3,2,1,[6,5,4,[9,8,7]].recursive.sort #=> [1,2,3,[4,5,6,[7,8,9]] > > Your method produces: > > [3,2,1,[6,5,4,[9,8,7]].recursive.sort #=> [1,2,3,4,5,6,7,8,9] > > The former proves much more difficult. Yeah, Intransition's way is what I understood to be the point of this thread.... Intransition, how would you handle this: [9,8,7,[6,5,4,[3,2,1]].recursive.sort #=> [1,2,3,[4,5,6,[7,8,9]] Clearly possible, but I have trouble seeing how you're going to make that happen easily. I have often found that too much recursion is confusing. This whole problem is going to be a lot easier if it's structured as an external iterator first and foremost. I have an extern iterator library (sequence) maybe I can figure out how to do this within that. (I don't really have a good grip on how Enumerator works, myself...)