KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I basically want to express the following behavior using _.each() or _.map() in Underscore.js. a = [1, 2, 3] b = [3, 2, 1] # Result list c = [0, 0, 0] for i in [0 .. a.length - 1] c[i] = a[i] + b[i] This is definitely possible in Matlab (my primary language) as such: c = arrayfun(@(x,y) x+y, a, b) Intuitively, it feels like the syntax in Underscore should be: c = _.map(a, b, function(x, y){ return x + y;}) However, that argument list isn't acceptable; the second parameter is supposed to be a callable function. The optional "context" argument won't help me in this situation.
Tags (comma-separated)
Save Edits
Cancel