Skip to content

Instantly share code, notes, and snippets.

@vendethiel
Forked from heath/es6-map.js
Last active July 10, 2024 15:12
Show Gist options
  • Save vendethiel/5844577 to your computer and use it in GitHub Desktop.
Save vendethiel/5844577 to your computer and use it in GitHub Desktop.
Map in different languages
[1,2,3].map((n)=> n*2)
[1, 2, 3].map(function (n:int):int { return n * 2; });
(map (fn [n] (* n 2)) [1 2 3])
[1,2,3].map (n) -> n*2
vector<int> m {3, 4, 5};
for_each(m.begin(), m.end(), [](int n) { return n * 2; });
var m = (new[] { 1, 2, 3 }).Select(n => n * 2);
map(fun(n) -> n*2 end, [1,2,3])
Enum.map([1, 2, 3], fn(x) -> x * 2 end)
map (2*) [1,2,3]
(mapcar (lambda (n) (* n 2)) '(1 2 3))
[1 2 3]map (*2)
List.map (fun x -> x * 2) [1; 2; 3]
array_map(function($value){return $value * 2;},[1,2,3])
map $_ *2, 1..3
map(lambda n: n*2, [1,2,3])
[1,2,3].map { |n| n*2 }
[1,2,3].map(|v| v * 2)
List(1,2,3) map {_*2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment