Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
language:controlflow [2022/05/13 08:45]
rajit
language:controlflow [2022/07/17 08:07] (current)
rajit [Loops]
Line 75: Line 75:
 syntax). The ''&'' symbol separates the body of the loop that is syntax). The ''&'' symbol separates the body of the loop that is
 instantiated for different values of ''i'' instantiated for different values of ''i''
 +
 +The syntactic replication construct is written as follows:
 +<code act>
 +(sym id : range : body )
 +</code>
 +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>
 + body(id set to lo) sym body(id set to lo+1) sym ... sym body(id set to hi)
 +</code>
 +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''.