DIRECTORY BasicTime; Acker: CEDAR PROGRAM IMPORTS BasicTime = BEGIN depth: INT _ 0; maxDepth: INT _ 0; calls: INT _ 0; Ack: PROC [x,y: INT] RETURNS [ans: INT] = { calls _ calls + 1; depth _ depth + 1; IF depth > maxDepth THEN maxDepth _ depth; SELECT TRUE FROM x = 0 => ans _ 1; y = 0 => ans _ IF x = 1 THEN 2 ELSE x+2; ENDCASE => ans _ Ack[Ack[x-1, y], y-1]; depth _ depth - 1; }; Test: PROC [x: INT] RETURNS [INT, REAL] = { pulses: BasicTime.Pulses = BasicTime.GetClockPulses[]; z: INT = Ack[x, 2]; time: REAL = BasicTime.PulsesToSeconds[BasicTime.GetClockPulses[] - pulses]; RETURN [z, time]; }; END. |Acker.mesa Copyright c 1984 by Xerox Corporation. All rights reserved. Russ Atkinson, July 19, 1984 11:30:57 pm PDT ĘB˜šœ ™ Jšœ Ďmœ1™