PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Operating mode
  • Existing computations
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
<Array>.Reduce (Function)
In french: <Tableau>.Agrège
Applies a computation to each element of a WLanguage array.
Example
arrValue is array of int = [1,2,3,4,5]
TheSum is integer
TheSum = arrValue.Reduce((Value, TheSum) => { RESULT Value + TheSum }, 0)
 
// Note: this example is for illustrative purposes; to find the sum of elements of an array,
// it is preferable to use the Sum function
Syntax
<Result> = <Array>.Reduce(<Operation to perform> [, <InitialValue>])
<Result>: Type corresponding to the result
Result of the requested reduce operation.
<Array>: WLanguage array
Name of Array variable to use. This array must be a one-dimensional array.
<Operation to perform>: WLanguage procedure
Name of WLanguage procedure to run. This procedure can be:
  • a global or local procedure,
  • an internal procedure.
It is also possible to directly use a lambda.
<InitialValue>: Optional parameter, type corresponding to the initial value
Initial value to use the first time the <Operation to perform> procedure is run.
Remarks

Operating mode

The <Operation to perform> procedure is called a first time with two parameters:
  • the first element of the array,
  • the initial value specified with <Initial value>.
The procedure is then called for all other elements of the array with two parameters:
  • the element of the array,
  • the value returned by the previous call.
Illustrative example
Let's study the following example:
In this example, the code:is equivalent to the following code:With this internal procedure, the calculation can be broken down as follows:
  • IntermediateResult1 = Add (t[1], InitialValue): in the example Add( 1, 0 ) -> 1
  • IntermediateResult2 = Add (t[2], IntermediateResult1): in the example Add( 2, 1 ) -> 3
  • ...
Remark: this example is for illustrative purposes; to find the sum of elements of an array, it is preferable to use <Array>.Sum.

Existing computations

The most common computations are available in WLanguage:
Versions 17 and later
<Tableau>.Moyenne
New in version 17
<Tableau>.Moyenne
<Tableau>.Moyenne
Calculates the mean of several elements:
  • elements found in an array,
  • numeric values, ...
Versions 17 and later
<Array>.Sum
New in version 17
<Array>.Sum
<Array>.Sum
Calculates the sum of the array elements.
Business / UI classification : Neutral code
Component : wd260vm.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment