3 ms·
You wouldn't use map or reduce, you'd just use recursion with an accumulator. If you absolutely insist on map/reduce, you can just use reduce, where your binar
by neutronicus 15y ago
You wouldn't use map or reduce, you'd just use recursion with an accumulator.
If you absolutely insist on map/reduce, you can just use reduce, where your binary function returns whichever object has a longer full name.
- ax 15y agoIn hindsight the second solution was obvious :) But can you explain your ideal solution more? Is it something that can be accomplished in Javascript?
- rapala 15y agoWell, reduce is a recursion with an accumulator. Did you had something special in mind?
- eru 15y agoWhy would you write mind-boggling recursion by hand, and not use a nice combinator that comes pre-debugged?
- neutronicus 15y agoBecause I had a brain fart and though "reduce" was "scan", and I didn't want to initialize an array.