MODULE Showcase23; (* Showcase: a generic doubly linked list. DList(T) is instantiated as IntList = DList(INTEGER); the program builds a list, walks it with Get(i), reverses it and sums it. Prints, then exits with the sum. *) IMPORT SysIO, IntList; VAR l : IntList.List; i, sum, ExitCode : INTEGER; PROCEDURE Show(pfx : ARRAY OF CHAR); BEGIN SysIO.Write(pfx); i := 0; WHILE i < IntList.Count(l) DO SysIO.Write(" "); SysIO.WriteInt(IntList.Get(l, i)); i := i + 1 END; SysIO.WriteLn END Show; BEGIN IntList.Init(l); IntList.Append(l, 10); IntList.Append(l, 20); IntList.Prepend(l, 5); Show("list:"); IntList.Reverse(l); Show("reversed:"); sum := 0; i := 0; WHILE i < IntList.Count(l) DO sum := sum + IntList.Get(l, i); i := i + 1 END; SysIO.Write("sum="); SysIO.WriteInt(sum); SysIO.WriteLn; ExitCode := sum (* 35 *) END Showcase23.