It is not possible to make multidimensional repetitions using the current version of the Mjølner System. However, multidimensional repetitions are easily constructed, e.g. a repetition with dimension NxM can be declared like:
mul_table: [N*M] @Integer;
which is intended to realize a two-dimensional array of the form:
The following example shows how the multiplication table constructed in section 4 previously can be stored in a two-dimensional repetition:
ORIGIN '~beta/basiclib/betaenv' ---- program: descriptor ---- (# (* Multiplication Table 3 * * Objective: Store values in a repetition *) N,M: @Integer; do '\n\t** Multiplication Table ** \n\n'-> puttext; 'Enter dimensions (NxM): '->puttext; getint -> N; getint -> M; (# mul_table: [N*M] @Integer; do (* build table *) (for i: N repeat (for j: M repeat i*j -> mul_table[(i-1)*M + j]; for); for); (* print table *) newline; ' '->puttext; (for i: M repeat i -> screen.putint(# format::(# do 4-> width #)#); for); newline; (for i: N repeat i -> screen.putint(# format::(# do 4-> width #)#); (for j: M repeat mul_table[(i-1)*M + j] -> screen.putint(# format::(# do 4-> width #)#); for); newline; for) #); #)
Libraries Tutorial | © 1994-2004 Mjølner Informatics |
[Modified: Thursday October 19th 2000 at 14:10]
|