Skip to content

Instantly share code, notes, and snippets.

@dewey92
Created June 27, 2017 02:57
Show Gist options
  • Select an option

  • Save dewey92/7426daac5aeb85dae5df59b2c8d4d073 to your computer and use it in GitHub Desktop.

Select an option

Save dewey92/7426daac5aeb85dae5df59b2c8d4d073 to your computer and use it in GitHub Desktop.
// map :: (a → b) → [a] → [b]
const map = fn => arr => arr.map(fn)
// :: (Int → String) → [Int] → [String]
map(x => x.toString())([1, 2, 3])
# ['1', '2', '3']
// :: (Int → Int) → [Int] → [Int]
map(x => x + 1)([1, 2, 3])
# [2, 3, 4]
// :: (String → [String]) → [String] → [[String]]
map(x => x.split())(['Jihad', 'Dzikri'])
# [['J', 'i', 'h', 'a', 'd'], ['D', 'z' .. 'i']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment