Skip to content

Instantly share code, notes, and snippets.

@fgalassi
Created June 8, 2017 14:45
Show Gist options
  • Save fgalassi/df1b3af0fcc12635233e5340282e6993 to your computer and use it in GitHub Desktop.
Save fgalassi/df1b3af0fcc12635233e5340282e6993 to your computer and use it in GitHub Desktop.
Map in very functional es6 style
let map = (func, [head, ...tail]) => head === undefined ? [] : [func(head), ...map(func, tail)]
map(n => n + 1, [1, 2, 3])
// [2, 3, 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment