MODULE Showcase23; (* Showcase: a generic doubly linked list. DList(T) is instantiated as IntList = DList(INTEGER). Exercises three things: a type parameter, arithmetic over it (Sum), and a procedure parameter (ForEach with an imported visitor). Prints, then exits with the sum. *) IMPORT SysIO, IntList; VAR l : IntList.List; i, sum, acc, 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:"); sum := IntList.Sum(l); SysIO.Write("sum="); SysIO.WriteInt(sum); SysIO.WriteLn; acc := 0; IntList.ForEach(l, Visitor.Add, acc); SysIO.Write("foreach="); SysIO.WriteInt(acc); SysIO.WriteLn; IntList.Reverse(l); Show("reversed:"); ExitCode := sum (* 35 *) END Showcase23.