Acker.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Russ Atkinson, July 19, 1984 11:30:57 pm PDT
Russ Atkinson (RRA) May 28, 1986 11:35:10 am PDT
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];
};
Loop:
PROC [x, times:
INT]
RETURNS [
INT,
REAL] = {
pulses: BasicTime.Pulses = BasicTime.GetClockPulses[];
z: INT;
time: REAL;
THROUGH [0..times)
DO
z ← Ack[x, 2];
ENDLOOP;
time ← BasicTime.PulsesToSeconds[BasicTime.GetClockPulses[] - pulses];
RETURN [z, time];
};
END.