Apply a callback to an array: Difference between revisions

adding gap
(adding gap)
Line 590:
Use ''iter'' if the applied function does not return a value.
<lang fsharp>Array.iter (fun x -> printfn "%d" x) [|1; 2; 3; 4; 5|]</lang>
=={{header|GAP}}==
<lang gap>
a := [1 .. 4];
b := ShallowCopy(a);
 
# Apply and replace values
Apply(a, n -> n*n);
a;
# [ 1, 4, 9, 16 ]
 
# Apply and don't change values
Perform(b, Display);
1
2
3
4
 
b;
# [ 1 .. 4 ]</lang>
 
=={{header|Go}}==
<lang go>package main
506

edits