Difference between revisions of "Index..Do"
(Copied content from user's guide) |
|||
Line 2: | Line 2: | ||
{{stub}} | {{stub}} | ||
− | = | + | The construct, '''''Index i := seqExpr''''' defines an index local to the definition in which it is used. The expression ''seqExpr'' may be a sequence, literal list, or other expression that generates an unindexed array, as used to define a global index. For example: |
+ | Variable PowersOf2 | ||
+ | Definition: Index J := 0..5; | ||
+ | 2^J | ||
+ | The new Variable ''PowersOf2'' is an array of powers of two, indexed by the local index ''J'', with values from 0 to 5: | ||
+ | :PowersOf2 → [[image:PowersOf2.jpg]] | ||
+ | |||
+ | The [[A.I|dot operator]] let's you refer to a local index of an array. | ||
+ | |||
+ | = Syntactic Variations = | ||
Index I := seqExpr Do bodyExpr | Index I := seqExpr Do bodyExpr |
Revision as of 20:45, 7 March 2007
The construct, Index i := seqExpr defines an index local to the definition in which it is used. The expression seqExpr may be a sequence, literal list, or other expression that generates an unindexed array, as used to define a global index. For example:
Variable PowersOf2 Definition: Index J := 0..5; 2^J
The new Variable PowersOf2 is an array of powers of two, indexed by the local index J, with values from 0 to 5:
The dot operator let's you refer to a local index of an array.
Syntactic Variations
Index I := seqExpr Do bodyExpr
or
Index I := seqExpr; expr; expr; ...
To control the index name, separate from the local variable name:
Index I / nameExpr := seqExpr Do bodyExpr
See Also
Comments
Enable comment auto-refresher