Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |
language:controlflow [2022/07/17 12:06] – [Loops] rajit | language:controlflow [2022/07/17 12:07] (current) – [Loops] rajit |
---|
The syntactic replication construct is written as follows: | The syntactic replication construct is written as follows: |
<code act> | <code act> |
(sym id : range : body(id) ) | (sym id : range : body ) |
</code> | </code> |
The ''sym'' (symbol) might be empty. ''id'' is a variable that can be used in ''body(id)'', and takes the range specified by ''range''. ''range'' can be either an integer-valued expression or ''start .. end'' to indicate a start and end index. The result of the replication is | The ''sym'' (symbol) might be empty. ''id'' is a variable that can be used in ''body'', and takes the range specified by ''range''. ''range'' can be either an integer-valued expression or ''start .. end'' to indicate a start and end index. The result of the replication is |
<code act> | <code act> |
body(lo) sym body(lo+1) sym ... sym body(hi) | body(id set to lo) sym body(id set to lo+1) sym ... sym body(id set to hi) |
</code> | </code> |
where ''lo'' is the starting index of the range, and ''hi'' is the ending index. | where ''lo'' is the starting index of the range, and ''hi'' is the ending index, and ''body(id set to x)'' means ''body'' with the value of ''x'' substituted by the constant ''id''. |
| |
| |