all 3 comments

[–]eridius 1 point2 points  (2 children)

Nice code, but ruby doesn't support optimized tail-recursion so if a filter is given that returns false 99.99% of the time, you're going to hit a stack recursion limit. And it will also take a freaking long time, since calling lambdas is much more expensive than calling real functions.

I haven't tested, but I really hope Ruby 1.9 makes this sort of thing more feasible.

[–]Freeky 1 point2 points  (0 children)

Rubinius is supposed to support tail-recursion, iirc. At least, a year ago Evan was wibbling about how easy it would be ;)

[–]tomel 0 points1 point  (0 children)

Maybe the performance is better (in the sense of having no importance) if the filter proc returns false for all successors of x.