虽然我相信我已经为我的函数(阶乘)找到了一个合理的算法,但我对它为什么无限循环感到非常困惑。这是我的代码:
declare
fun{Fact N}
local M=1 in %I suppose it loops from here??
local FactT in %But the function call starts from here
fun{FactT N Acc} % which doesn't include the local declaration of M
if M==N then
{Browse M}
Acc
else
%{Browse M} %displays infinite lines of 1s
%{Browse N}
%{Browse Acc} %They form a continuously growing list of 1s
{FactT (M+1) (M|Acc)}end
end
{FactT N nil}
end
end
end
{Browse {Fact 3}}