3 ms·
Collections-js looks like a nice split -- I might end up nabbing a few more things out of there. Maybe some of the unit tests too, although, FYI, your Functiona
by jashkenas 17y ago
Collections-js looks like a nice split -- I might end up nabbing a few more things out of there. Maybe some of the unit tests too, although, FYI, your Functional.js page has shown "Documentation Failed to Load" for me for the last few days (on Webkit).
One thing that it would be nice to agree on is the standard names for some of these things under Javascript. What should reduce be called? Inject? Foldl? I've followed the Prototype/Ruby naming conventions, but it might make sense to provide all of the commonly-used aliases -- especially when you're not extending core objects, and don't need to worry about cluttering them up. What do you think? Does the same function under 5 different names run as sweet?
- iamwil 17y agoI'd say just use the same function name. people will learn what is what as long as it sticks to some sort of consistent convention.
- davidmathers 17y agoNot inject. Inject was borrowed from smalltalk's #inject:into, but dropped the "into" and just ended up being unintuitive for many people. Ruby 1.8.7 and 1.9 now have #reduce, so I'd say that's the way to go. No reason to use foldl unless you're going to also have a foldr.
- jashkenas 17y agoVersion 0.2, which should be out this evening, will call it "reduce", and alias it to "inject". Thanks for the feedback.