OK, OK, OK, last one, I promise
01/01/06 20:10 Filed in: Programming
| Ruby
Nowhere near as elegant as the inject method below, but this covers both assignment and block usages, so you can pick your poison. If you pass in a block then you have linear rather than exponential memory usage, although the run time is of course equivalent.
OK, I'm done. This is my final answer.
Wait... Maybe we should add an optional argument with a default value that limits the output, to prevent inadvertently calling it with an array that will take forever to return...
|