Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

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:

YASS
$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.

YASS
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.

Comments
Feedback 👍
Comments are sent via email to me.