Created
April 1, 2018 14:40
-
-
Save usametov/0652f1863dea84b7aa99b4490f6d9036 to your computer and use it in GitHub Desktop.
ES6 pattern matching using destructuring
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 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