Iterative
Ï€-calculus has a notion of the repetitive process: !P = P | !P
. That means, you can always fork a new P
process if you need it.
In Aqua, two operations correspond to it: you can call a service function (it's just available when it's needed), and you can use for
loop to iterate on collections.
for
expression
for
expressionIn short, for
looks like the following:
Contract
Iterations of
for
loop are executed sequentially by default.Variables defined inside
for
loop are not available outside.for
loop's code has access to all variables above.for
can be executed on a variable of any Collection type.
Conditional for
for
For can be executed on a variable of any Collection type. You can make several trials in a loop, and break once any trial succeeded.
The contract is changed as in Parallel flow.
Parallel for
for
Running many operations in parallel is the most commonly used pattern for for
.
The contract is changed as in Conditional flow.
Export data from for
for
The way to export data from for
is the same as in Conditional return and Race patterns.
for
on streams
for
on streamsfor
on streams is one of the most advanced and powerful parts of Aqua. See CRDT streams for details.
Last updated
Was this helpful?