Thursday, January 29, 2009

Ch3, Ex11

%Run this
declare Append
fun {Append D1 D2}
S1#E1=D1
S2#E2=D2
E1=S2
in
S1#E2
end
local E1 E2 D1 D2 in
D1 = (1|2|3|E1)#E1
D2 = (4|5|6|E2)#E2
{Browse {Append {Append D1 D2} D2}}
end

%and then, this
local E in
E = 1|2|3|E
{Browse E}
end

You realize that you create a cyclic structure when you append the same list again as {Append D1 D2} results in (1|2|3|4|5|6|E2)#E2 and then you're appending (4|5|6|E2)#E2 to it.

No comments:

Post a Comment