Last active
January 13, 2017 22:14
-
-
Save adambene/667d0c9a0f1b743483dac1e6ad574452 to your computer and use it in GitHub Desktop.
Pattern Matching in JavaScript - JavaScript map
This file contains 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 map = (f, [x, ...xs]) => ( | |
(x === undefined && xs.length === 0) ? [] | |
: [f(x), ...map(f, xs)] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment