In french: Transforme
Executes a procedure on each element of a source array and returns the results in a WLanguage array.
arrValue is array of int = [1,2,3,4,5]
arrTriple is array of int
// Construct an array with the values multiplied by three
arrTriple = Map(arrValue, AValue => AValue * 3)
// arrTriple contains [3, 6, 9, 12, 15]
// -> apply lowercase to all the strings in the array
// (Prefix syntax)
arr1 is array of strings = ["A", "b", "C"]
arr1 = arr1.Map( X => Lower(X))
// arr1 = ["a", "b", "c"]
<Result> = Map(<Source array> , <Operation to perform>)
<Result>: WLanguage array
Array that contains the result of the procedure executed for each element of the <Source array>.
<Source array>: WLanguage array
Name of the Array variable to use. This array must be a one-dimensional array.
<Operation to perform>: WLanguage procedure
Name of the WLanguage procedure to be executed for each element of the <Source array>. This procedure can be:
It is also possible to directly use a lambda procedure.
- a global or local procedure,
- an internal procedure.
The <Operation to perform> procedure is called for each element of the source array by passing this element as a parameter.
The results of all calls are stored in the <Result> array.
Sequence of functions
You can use array functions in a sequence.
The following functions can be used in a sequence:
This sequence can be used as a source for a FOR ALL statement or it can end with one of the following functions:
gnMean = garrUser.Filter(cbFilter).Map(cbMap).Mean()
Unit examples (WINDEV): Filter / Map / Reduce
Business / UI classification: Neutral code
This page is also available for…