From: Robert Dober Date: 2010-04-13T02:37:59+09:00 Subject: Re: Is it possible, a fully general Enumerable#recursive ? On Mon, Apr 12, 2010 at 5:08 PM, Robert Klemme wrote: > 2010/4/12 Robert Dober : >> On Sun, Apr 11, 2010 at 10:55 PM, Robert Klemme >> wrote: >>> On 04/09/2010 08:53 PM, Intransition wrote: >>>> >>>> On Apr 9, 2:03 pm, Robert Dober wrote: >> eed to define #<=>  on the return value of recursive. >>> >>> Why that?  The whole point would be to sort all elements that would be >>> recursively returned.  The #recursive return value would never be seen then. >>  #each takes care of structure #<=> takes care of order, IOW > > As far as I understand the initial posting of this thread the whole > point is to create "something" (aka an Enumerator) whose #each method > recursively iterates through nested Enumerables.  This implies that > during that iteration only elements inside Enumerables are yielded > which are not Enumerable.  Hence there is no need to provide a > generalized <=> because x.recursive.sort only ever sees those non > Enumerable elements.  Of course, sort only can work properly if all > elements have the same type, are compare compatible or an explicit > comparison block is passed to #sort. > >> #recursive is called from #each, or did I miss something here? > > Technically speaking yes, but more correct would be to say that > #recursive is invoked from #recursive.  (=> my implementation for an > example) Ok I see what you mean now. I polluted my answer with how I would implement the thing, but I am not here to lecture anyone, it is just my style shining through. > > 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. > :-) IMHO because the rationale is not very clear, but I thought I could help on one tiny point nonetheless, maybe OP is just experimenting and finding out what (s)he wants, fair enough I'd say Cheers R. > > Kind regards > > robert > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ > > -- Learning without thought is labor lost; thought without learning is perilous.” --- Confucius