我应该证明两种算法以相同的顺序执行相同的语句。一个是另一个的尾递归版本。它们是用埃菲尔写的。
tail_rec(x:instance_type):result_type is
local
y:instance_type;
do
if b(x) then
Result :=c(x)
else
y:=d(x);
Result:=tail_rec(y)
end
end
然后是非尾递归版本。
non_rec(x:instance_type):result_type is
do
from until b(x) loop
x:= d(x)
end;
Result:= c(x)
end
其中 b(x)、c(x) 和 d(x) 分别是 BOOLEAN、result_type 和 instance_type 类型的任何函数。
这两种算法有何相似之处,它们如何以相同的顺序执行相同的语句?