The Map method with Arrays



The Map method.
Smart pascal source code
function MyFunc(a: Integer): string; begin Result := '(' + IntToStr(a) + ')'; end; { unit1.pas } var a: array of Integer; b: array of Integer; c: array of String; begin a := [1,3,2,5,4]; b := a.Map(Sqr); for var i in b do Writeln(i); // 1 9 4 25 16 Writeln(''); c := b.Map(MyFunc); for var i in c do Writeln(i); // (1)(9)(4)(25)(16) Writeln('');