私は自分の関数 (階乗) の適切なアルゴリズムを見つけたと信じていますが、それが無限にループする理由について非常に混乱しています。これが私のコードです:
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}}