Created
February 28, 2019 18:32
-
-
Save wdiasvargas/2d7399d90518eddc12a622e509741443 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mapper =(fn, [head, ...tail]) => ( head === undefined && tail.length < 1 ? [] : [fn(head), ...mapper(fn, tail)] ); | |
const filterr = (pred, [head, ...tail]) => head === undefined ? [] : (pred(head) ? [head, ...filterr(pred, tail)] : [...filterr(pred, tail)]); | |
const reducer = (fn, acc, [head, ...tail]) => head === undefined ? acc : reducer(fn, fn(acc, head), tail); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment