loop
This is a low-level iterative construct that is not recommended for use in cloud applications. Use foreach
iteration over a container(s) wherever possible, with a collect
node to gather the results and trigger the continuation.
Name | Type | Description | Optional |
---|---|---|---|
init |
?0 |
number of iterations |
no |
next |
?0 |
when false, |
Name | Type | Description | Optional |
---|---|---|---|
If next
is a non-default value, echo it to the output
(init
is unmodified in this case). Otherwise, read init
and echo it to the output. The first next
input is discarded.
Deceptively simple, there is ample room here for both elegance and gross error. The example SpecialNodes/miniloop
illustrates the working of this node. The loop
circuit counts down from an initial count to zero, outputting a decremented value every iteration:
The loop
circuit is called from the test
circuit with two iteration counts, causing the loop to run twice, once for 10 iterations and once for 20:
The output of the example when Run
is this: