ForNext
Only Do What Only You Can Do
120. map
Hyperpolyglot Interpreted Languages: PHP, Perl, Python, Ruby より (2012.05.08)
VBScript
JScript
Perl
map { $_ * $_ } (1,2,3)
PHP
array_map(function ($x) { return $x*$x; }, array(1,2,3))
Python
map(lambda x: x * x, [1,2,3]) # or use list comprehension: [x*x for x in [1,2,3]]
Ruby
[1,2,3].map { |o| o*o }