Skip to content

Instantly share code, notes, and snippets.

@wdiasvargas
Created February 28, 2019 18:32
Show Gist options
  • Save wdiasvargas/2d7399d90518eddc12a622e509741443 to your computer and use it in GitHub Desktop.
Save wdiasvargas/2d7399d90518eddc12a622e509741443 to your computer and use it in GitHub Desktop.
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