Friday, January 16, 2009

Ch1, Ex8

Acc is creating new cell with content 0 in each Accumulate call and losing the previous accumulated values. Here is the correct version:

declare
local Acc = {NewCell 0} in
fun {Accumulate N}
Acc:=@Acc+N
@Acc
end
end

No comments:

Post a Comment