mapcar

1.2.0 • Public • Published

Mapcar License NPM version Dependency Status Build Status

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

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i mapcar

    Weekly Downloads

    0

    Version

    1.2.0

    License

    MIT

    Last publish

    Collaborators

    • coderaiser