Skip to content

Instantly share code, notes, and snippets.

@indongyoo
Created April 3, 2018 12:24
Show Gist options
  • Save indongyoo/e831a1467a7e5b1fddcab4c19de66382 to your computer and use it in GitHub Desktop.
Save indongyoo/e831a1467a7e5b1fddcab4c19de66382 to your computer and use it in GitHub Desktop.
const mapC = curry2((f, coll) =>
map(([a]) => a,
map(a => [f(a)], coll)));
go([1, 2, 3],
map(add10),
console.log); // 3초 뒤 [11, 12, 13]
go([4, 5, 6],
mapC(add10),
console.log); // 1초 뒤 [14, 15, 16]
go({ a: 7, b: 8, c: 9 },
mapC(add10),
console.log); // 1초 뒤 { a: 17, b: 18, c: 19 }
go(new Map([['a', 10], ['b', 11], ['c', 12]]),
mapC(add10),
console.log); // 1초 뒤 Map(3) {"a" => 20, "b" => 21, "c" => 22}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment