Artifact 4af3c4ccb9eff42b8e5d305f3119010df30cfa68
# I'm lazy. So I define only the primitives needed for tarai.
@@lazy(x) { fun(){x} };
@lazy - (x,y) { fun(){@value(@lazy(x)() - @lazy(y)()) } };
@lazy <= (x,y) { fun(){@value(@lazy(x)() <= @lazy(y)()) } };
@lazy if (c,t,e) { fun(){@value(if @lazy(c)() then @lazy(t())() else @lazy(e())()) } };
def tarai(x,y,z)
{
if x<=y then
y
else
tarai( tarai(x-1,y,z), tarai(y-1,z,x), tarai(z-1,x,y) )
};
# print( tarai(12, 6, 0) );
print( @lazy( tarai(12, 6, 0) )() );
#### Omake: only Z is made lazy.
def taraiZ(x,y,z @lazy)
{
if x<=y then
y
else
taraiZ( taraiZ(x-1,y,z), taraiZ(y-1,@lazy(z)(),x), taraiZ(@lazy(z)()-1,x,y) )
};
print( taraiZ(12,6,0) );