Apply a callback to an array: Difference between revisions

m
m (add to Iteration cat)
m (→‎{{header|Perl}}: migrate content from Loop Structures)
Line 798:
</lang>
=={{header|Perl}}==
<lang perl># create array
# create array
my @a = (1, 2, 3, 4, 5);
 
Line 827 ⟶ 826:
my $func = \&mycallback;
my @d = map $func->($_), @a; # @d is now (2, 4, 6, 8, 10)
 
</lang>
# createfilter an array
my @e = grep { $_ % 2 == 0 } @a; # @e is now (2, 4)</lang>
 
=={{header|PHP}}==
Anonymous user