1.2.0 • Published 9 years ago
mapcar v1.2.0
Mapcar
Mapcar applies function fn
to elements of lists with same index.
Each application result is put into resulting list
.
Length of resulting list is the length of the shortest list argument.
Came from lisp.
Install
npm i mapcar --save
bower i mapcar --save
How to use?
mapcar(sum, [1,2,3,4], [1,2]);
// returns
[2,4]
function sum(array) {
return array.reduce(function(value, item) {
return value + item;
}, 0);
}
License
MIT