Apply a callback to an array: Difference between revisions

m (Fixed lang tags.)
Line 449:
The same can be done using anonymous functions, this time squaring the members of the input array.
<lang fsharp>let result = Array.map (fun x -> x * x) [|1; 2; 3; 4; 5|]</lang>
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|Groovy}}==
Anonymous user