ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Queue, stack, list and array functions / Array functions
  • Operating mode
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Executes a procedure on each element of a source array and returns the results in a WLanguage array.
This function can be used:
  • on one-dimensional arrays,
  • on associative arrays.
Example
tabValeur is array of int = [1,2,3,4,5]
tabTriple is array of int
// Construit un tableau avec les valeurs triples
tabTriple = Map(tabValeur, UneValeur => UneValeur * 3)
// tabTriple contient [3, 6, 9, 12, 15]
// -> mettre toutes les chaînes en minuscules dans le tableau (Syntaxe préfixée)
tab1 is array of strings = ["A", "b", "C"]
tab1 = tab1.Map(X => Lower(X))
// tab1 = ["a", "b", "c"]
WindowsLinux
tabValeurs is array of int = [1,2]
FOR EACH x,c of Map(tabValeurs, (valeur, clé) => valeur + clé)
	Trace(x,c)
END
// Affiche : 
// 2,1
// 4,2
WindowsLinux
dictValeurs is associative array of int
dictValeurs["A"] = 1
dictValeurs["B"] = 2
dictValeurs["C"] = 3
dictValeurs["D"] = 4
FOR EACH x,c of Map(dictValeurs, (valeur, clé) => valeur + clé)
	Trace(x,c)
END
// Affiche : 
// 1A A
// 2B B
// 3C C
// 4D D
Syntax
<Result> = Transform(<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 can be:
  • a one-dimensional array.
  • an associative 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:
  • a global or local procedure,
  • an internal procedure.
It is also possible to directly use a lambda procedure.
Remarks

Operating mode

The <Opération à effectuer> procedure is called for each element of the source array by passing:
  • the element of the source array,
  • the key to the element.
    In the case of a simple array, the key corresponds to the element index. This parameter is optional.
    In the case of an associative array, the key corresponds to the element indexing key.
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: Example:
gnMean = garrUser.Filter(cbFilter).Map(cbMap).Mean()
Related Examples:
Filter / Map / Reduce Unit examples (WINDEV): Filter / Map / Reduce
[ + ] This example shows how to use the Filter / Map / Reduce functions.
The Filter / Map / Reduce concept allows performing operations on sets of data in a remarkably concise way.
Filter is used to filter an array of elements in a customized way (with a callback procedure).
Map is used to transform an array of elements, also with a callback procedure.
Reduce is used to aggregate data in a customized way with a callback procedure.
Here, this example is used to calculate the average age of women among the users displayed in the table below.
Business / UI classification: Neutral code
Component: wd300vm.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help