Skip to content

coderaiser/mapcar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

applies function to elements of lists with same index

Resources

License

Stars

Watchers

Forks

Packages

No packages published