Algorithms and Data Structures © N. Wirth 1985 (Oberon version: August 2004). § 1.4 FOR iteration by array MODULE For; CONST N* = 100; VAR a*: ARRAY N OF REAL; PROCEDURE Sum*(): REAL; VAR sum: REAL; i: INTEGER; BEGIN sum := 0.0; FOR i := 0 TO N-1 DO sum := a[i] + sum END RETURN sum END Sum; PROCEDURE Max*(): INTEGER; VAR max: REAL; i, k: INTEGER; BEGIN k := 0; max := a[0]; FOR i := 1 TO N-1 DO IF max < a[i] THEN k := i; max := a[k] END END RETURN k END Max; PROCEDURE Init; VAR i: INTEGER; BEGIN FOR i := 0 TO N - 1 DO a[i] := FLT(10*i - i*i) END END Init; BEGIN Init END For.