To use this website fully, you first need to accept the use of cookies. By agreeing to the use of cookies you consent to the use of functional cookies. For more information read this page.

Official ZPE/YASS documentationInline iteration

Inline iteration was added in ZPE 1.11.2 (OmegaY, February 2023) and it brings about a few new simplicities.

What is inline iteration?

Inline iteration is similar to the match statement in it's purpose. The match statement allowed for conditional evaluation to take place within assignment and expression evaluation. Inline iteration carries out a similar purpose, allowing iteration to take place within assignment and expression evaluation.

Firstly, within the context of list declarations, it becomes much easier to define a list of numbers ranging from a lower to upper number:

$nums = from 5 to 15

Further to this, using lambda functions, it is possible to define a sequence of expression generation within the context of the array.

print(from 0 to 1000 : function ($x) { return $x * 2 })
evaluate(from 0 to 1000 : function ($x) { print($x) })

When using a lambda function with this, the first parameter, if provided, will contain the iteration number that the loop is at.

The result in both cases is a ZPEList of n elements as defined.

Code previewClose
Feedback 👍
Comments are sent via email to me.