Usage
for x in a repeat { ...}
for x in generator a repeat { ...}
Signature
generator: % Generator T
Parameter | Type | Description |
---|---|---|
a | % | a finite data structure |
Description
This function allows a structure to be iterated independently of its representation. This generator yields the elements of a in some order, which is determined by the actual type.
Example
The following code computes the sum of all the elements of an array of machine integers:
sum(a:Array MachineInteger, n:MachineInteger):MachineInteger == { s:MachineInteger := 0; for x in a repeat s := s + x; s; }