Login
|
Signup
langref.org
-
php
,
clojure
, and
fantom
add..
all
cpp
csharp
erlang
fsharp
go
groovy
haskell
java
ocaml
perl
python
ruby
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Lists
Manipulation
Perform an operation on every item of a list
Perform an operation on every item of a list, e.g.
for the list
["ox", "cat", "deer", "whale"]
calculate
the list of sizes of the strings, e.g.
[2, 3, 4, 5]
php
$sizes = array_map('strlen', array('ox', 'cat', 'deer', 'whale'));
<?php
$sizes = array_map('strlen', array('ox', 'cat', 'deer', 'whale'));
?>
clojure
(map count ["ox" "cat" "deer" "whale"])
(map count ["ox" "cat" "deer" "whale"])
fantom
["ox", "cat", "deer", "whale"].map { it.size }
class SolutionXX
{
Void main()
{
["ox", "cat", "deer", "whale"].map { it.size }
}
}
Submit a new solution for
php
,
clojure
, or
fantom
There are 14 other solutions in
additional
languages (
cpp
,
csharp
,
erlang
,
fsharp
...)