Help / WLanguage / WLanguage functions / Standard functions / Queue, stack, list and array management functions / Array functions
  • Operating mode
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Returns an array containing the elements of a source array for which a procedure returns True.
// Retrieve an array with all the customers
arrCustomer is array of Customer
// Construct the array of customers a with negative account balance
arrCustomerNegativeBalance is array of Customer
arrCustomerNegativeBalance = arrCustomer.Filter(ACustomer => ACustomer.Balance<0)
// -> keep even numbers of an array
arr2 is array of int = [1, 2, 3, 4]
arr2 = arr2.Filter( X => IsEven(X))
// arr2 = [2, 4]
<Result> = <Source array>.Filter(<Condition to check>)
<Result>: WLanguage array
Array that contains the elements of the <Source array> for which the <Condition to check> returns True.
<Source array>: WLanguage array
Name of the Array variable to use. This array must be a one-dimensional array.
<Condition to check>: WLanguage procedure
Name of the WLanguage procedure to be executed for each element of the <Source array>. This procedure must return True or False.
This procedure can be:
  • a global or local procedure,
  • an internal procedure.
It is also possible to directly use a lambda procedure.

Operating mode

The <Condition to check> procedure is called for each element of the array by passing this element as a parameter.
If the procedure returns True, the element from the source array is 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:
gnMoyenne = gtabUser.Filtre(cbFiltre).Transforme(cbTransforme).Moyenne()
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.
Component: wd280vm.dll
Minimum version required
  • Version 25
This page is also available for…
Click [Add] to post a comment

Last update: 06/21/2023

Send a report | Local help