Apply a callback to an array: Difference between revisions

(→‎{{header|Oz}}: Simplified)
Line 730:
 
=={{header|Oz}}==
<lang oz>functordeclare
import
Application System
define
 
Print = System.showInfo
 
fun{Square A}
A*A
end
 
ArrLst = [1 2 3 4 5]
fun{FuncEach Func A}
{Map A Func}
%% apply a PROCEDURE to every element
end
{ForAll ALst ProcShow}
 
proc{ProcEach Proc A}
{ForAll A Proc}
end
 
Arr = [1 2 3 4 5]
 
{ProcEach Print {FuncEach Square Arr}}
 
%% apply a FUNCTION to every element
{ForAll {Map Arr Square} Print} %% same
Result = {Map ALst FuncSquare}
{Show Result}</lang>
 
{Application.exit 0}
end</lang>
=={{header|Perl}}==
<lang perl># create array
Anonymous user