Created
November 16, 2015 23:00
-
-
Save tetsu-miyagawa/88b2e240ac25f0070cb4 to your computer and use it in GitHub Desktop.
CTMCP Section 2.9 Exercise 9 (a)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare Sum1 Sum2 | |
Sum1 = proc {$ N ?R} | |
local T in | |
T=N==0 | |
if T then R=0 | |
else | |
local S M in | |
S=N-1 | |
{Sum1 S M} | |
R=N+M | |
end | |
end | |
end | |
end | |
Sum2 = proc {$ N S ?R} | |
local T in | |
T=N==0 | |
if T then R=S | |
else | |
local X Y in | |
X=N-1 | |
Y=N+S | |
{Sum2 X Y R} | |
end | |
end | |
end | |
end | |
declare R1 R2 | |
{Sum1 4 R1} | |
{Browse R1} | |
{Sum2 5 0 R2} | |
{Browse R2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment