What is the kernel language representation of N + {Add N - 1}
following the stub
local I1 in
// the code
end
end
end
the procedure definition of function {Add N}
is as follows
proc {Add N R}
if N == 0 then R = 0
else N + {Add N - 1}
end
end
In the kernel language, you have to define a new identifier for each operation. One for the N-1
operation, another to retrieve the result of the procedure Add
and a third one to store the result of N + {Add N-1}
. Also you have to declare each local variable separately.
So you get something like this :
local I1 in
local I2 in
local I3 in
I1 = 1
I2 = N - I1
{Add I2 I3}
R = N + I3
end
end
end
Then I3
contains the value N + {Add N-1}