A.it erate()

Description:

Perform iterative loop on a record sequence and return the result of the last calculation of a given expression.

Syntax:

A.iterate(x,a,c)

Note:

The function loops through members of record sequence A to calculate expression x and returns the result of the last calculation of x. ~~ represents the previous value of x. Parameter a is the default initial value for each calculation, whose absence indicates a null initial value. Exit the loop once the result of expression c is true.

Parameter:

A

A sequence/record sequence

x

An expression

a

The initial value

c

A Boolean expression

Option:

@a

Return the results of calculating the expression over every member

Return value:

Result of expression x

Example:

 

A

 

1

[2,222,22,122,2222]

 

2

=A1.iterate(~*2)

4444

3

=A1.iterate@a(~*2)

[4,444,44,244,4444]

4

=A1.iterate(~~*2,3)

96

5

=A1.iterate(~~*2,5,~>500)

80

6

=demo.query("select * from SALES")

 

7

=A6.derive(A6.(AMOUNT).iterate(~~*2,5,~>20000):Cumulation)

Related function:

iterate()