Example: Repetitive Evaluation Using Loops
For-Loop
This example illustrates the use of a for-loop in xmlmath. A for-loop operator creates an iterator variable of type long and increments it after each evaluation of the expression in its <do> tag.
The for-loop collects all values returned after the repetitive evaluation of the expression in its <do> tag and returns them as a list. In this example, this list is fed to <toString>, which returns a string representation of the list.
The iterator variable is initialized with the long value represented by the expression in the <start> tag and is incremented until it reaches the value represented by the <end> tag. The latter is exclusive. Hence, this example returns the string: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].
<expression xmlns="http://xmlmath.org/1.0">
<toString>
<for iterator="i">
<start>
<long value="0"/>
</start>
<end>
<long value="10"/>
</end>
<do>
<linkLong name="i"/>
</do>
</for>
</toString>
</expression>
|
For brevity, it is allowed to omit the <start>, <end> and <do> tags.

