(* The Great Win32 Language Shootout http://dada.perl.it/shootout/ contributed by Isaac Gouy (Modula2 novice) To compile: xc =m ary3 To run: ary3 7000 *) MODULE Ary3; <* m2extensions + *> <* storage + *> <* ioverflow - *> <* noptralias + *> <* checkdindex - *> <* checknil - *> (* Prefer unqualified procedures *) FROM LanguageShootout IMPORT N; FROM STextIO IMPORT WriteString, WriteLn; FROM SWholeIO IMPORT WriteInt; TYPE Array_Type = ARRAY OF INTEGER; Array_Ptr_Type = POINTER TO Array_Type; VAR n, i, m, j: INTEGER; x, y: Array_Ptr_Type; BEGIN n := N(); NEW(x, n); NEW(y, n); FOR i := 0 TO INT(HIGH(x^)) DO x^[i] := i+1; y^[i] := 0; END; m := HIGH(y^); FOR j := 1 TO 1000 DO FOR i := 0 TO m DO INC(y^[i], x^[i]); END; END; WriteInt(y^[0],1); WriteInt(y^[HIGH(y^)],0); WriteLn; DISPOSE(x); DISPOSE(y); END Ary3.