From: David Masover Date: 2010-04-08T12:51:14+09:00 Subject: Re: Is it possible, a fully general Enumerable#recursive ? On Wednesday 07 April 2010 04:49:15 pm Intransition wrote: > For the last couple of days I've been trying to write an Enumerable > method called #recursive. Rather than create a bunch of methods like > #recursive_each, #recursive_map, #recursive_sort, etc. I figured that > it should be possible to create a single #recursive method that > returned an Enumerator, Yes! > or barring that a Functor, What's a Functor in this context? We already have proc objects, which is traditionally what "functor" means... > This works for #each and #map but not #sort. #sort isn't a method of Enumerable, it's a method of Array. > Can anyone think of a better solution? Probably, but I'm not sure what it would look like. What's your use case -- how would I actually use this to, say, generate an infinite stream of fibbonacci numbers? I guess I don't really see why you'd define it in terms of an enumerable (in that case, you probably want inject).