Consider a value repetition:
where T is a basic pattern.
A repetition object may be constructed and assigned to R 
in the following way:
where E1, E2, ... En  are evaluations of type T.
A repetition object with range = n is constructed and 
R[i] = Ei, i in [1,n].
A repetition object consisting of one element may be constructed
using:
The following is an example of using repetitions constructors:
| (# a,b: @integer;
   R:[1] @integer
do 10->a; 20 -> b
   (a,b,a+b) -> R;
   (for i: R.range repeat R[i] -> putint; ' '-> put for)
#) | 
The above example will print the sequence
Repetitions may be used to define patterns with a limited form
of a variable number of parameters. Consider the following example:
| foo:
   (# S: ^stream;
      V: [1] @integer;
      sep: @char
   enter(S[],V,sep)
   do (for i: V.range repeat
           V[i] -> S.putint; sep -> S.put
      for)
   #) | 
Pattern foo may be used in the following way:
| (screen[],(1,2,3,4,5),'-') -> foo | 
which will print the following sequence to the screen:
| BETA Language Modifications - Reference Manual | © 1999-2002 Mjølner Informatics | [Modified: Thursday December 5th 2002 at 11:20]
 |