"
Init
" actually defines the accumulator's behaviour.
It must take a function or box on lambda mode, with two inputs :
one for the element to collect,
one for the initial value.
Example : Subtracting a List of Numbers
We want to subtract numbers successively – for instance (100-8-2-3-9). For this, we need an initial value, x, a list of numbers, the om- function on "lambda" mode, and acum.
The initial value of acum is 100. Om- is set on "lambda" mode it is connected to the third output of acum. It is applied recursively to the elements of the list and to the initial value. We get (100 - a - b - c - d).
Listloop returns the successive elements of the list to acum.
At each step of the iteration, the first print box prints the
successive current values
of acum : 100 ; 100-8 = 92 ; 92-2 = 90 ; ...
At each step of the iteration, the second print box prints the result of the subtraction, which is then stored as
the new current value
of accum.
When the iteration is over, Finally returns the final state of acum.