ch.iterate()

Description:

Perform interative loop on record sequences in a channel and return the result of the last calculation of a given expression.

Syntax:

ch.iterate(x,a,c)

Note:

The function loops through record sequences in channel ch 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.

Parameters:

ch

A channel

x

An expression

a

Initial value

c

An expression returns true/false

Return value:

Result of expression x

Example:

 

A

 

1

=[2,222,22,122,2222]

 

2

=channel()

 

3

=channel()

 

4

=A2.iterate(~*2)

 

5

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

 

6

=A1.push(A2,A3)

 

7

=A2.result()

4444

8

=A3.result()

96

9

=[100,200,800,2000]

 

10

=channel()

 

11

=A10.iterate(~~*3,10,~>250)

 

12

=A9.push(A10)

 

13

=A10.result()

90