home > 比較編 > Perl, PHP, Python, Ruby > arrays >

ForNext

Only Do What Only You Can Do

120. map

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 }


PowerShell

Scala

F#

C

C++

C++Builder

VC++

C#

Java

Objective-C

D

VB

VB.NET

Delphi

Ada

PL/SQL

T-SQL

関数型

inserted by FC2 system