Skip to content

Instantly share code, notes, and snippets.

@bradparker
Last active April 20, 2016 03:46
Show Gist options
  • Save bradparker/e220d2f7ce0ba5f7c9cd6c70247c71f9 to your computer and use it in GitHub Desktop.
Save bradparker/e220d2f7ce0ba5f7c9cd6c70247c71f9 to your computer and use it in GitHub Desktop.
Map
const map = (fn, arr) => {
  if (!arr.length) return []
  const [head, ...tail] = arr
  return [fn(head, ...map(fn, tail)]
}
map :: (a -> b) -> [a] -> [b]
map _ [] = []
map fn (head:tail) = (fn head):(map fn tail)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment