push.cx
Peter Bhat Harkins
Recursive Sum
Code: recursion, Ruby
Comments Off on Recursive Sum
In #ruby on Freenode, platzhirsch asked about how to total an array of Transactions when the Transactions may have parents. The two obvious approaches have pitfalls when there are a lot of Transactions, and he said he expects to have 23 million that may be deeply nested. Here’s his sample code: