Skip to content

Instantly share code, notes, and snippets.

@adambene
Last active January 13, 2017 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adambene/667d0c9a0f1b743483dac1e6ad574452 to your computer and use it in GitHub Desktop.
Save adambene/667d0c9a0f1b743483dac1e6ad574452 to your computer and use it in GitHub Desktop.
Pattern Matching in JavaScript - JavaScript map
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