3 ms·
That's interesting, I like how `slice` lets you concat sequences of arguments, but worry about building functions which have too many convenience features. Tho
by politician 14y ago
That's interesting, I like how `slice` lets you concat sequences of arguments, but worry about building functions which have too many convenience features. Thought experiment: what if I wanted to pass every other argument?
- ricardobeat 14y agoI imagine you could pass a function function(arg, i){ return i%2 } as the `slice` parameter, but that's going into crazy territory.
- bdr 14y agoHere's what I use: # Adapted from http://autotelicum.github.com/Smooth-CoffeeScript/literate/partial.html F.partial = (func, a...) -> (b...) -> func (for arg in a then arg ?= b.shift())..., b... For example, do `parseInt10 = F.partial(parseInt, undefined, 10)`, then `[].map(parseInt10)` does the right thing.