当我试图编译这段代码时,Oz编译器会启动一个异常“缺失的其他条款”,有人能告诉我为什么吗?这是我的代码:
declare
fun {Numero x y}
local NumeroAux in
fun {NumeroAux x y Acc}
if {And (x == 0) (y == 0)} then Acc
else
if y == 0 then {NumeroAux 0 x-1 Acc+1}
else
{NumeroAux x+1 y-1 Acc+1}
end
end
end
{NumeroAux x y 0}
end
end
{Browse {Numero 0 0}}在我看来,在这段代码中没有遗漏一个there子句!我的函数总是会返回一些东西。
发布于 2015-06-21 22:09:50
在Oz语言中,所有变量都需要大写。小写是atom的小写。因此,如果您试图用大写字母运行代码:
declare
fun {Numero X Y}
local NumeroAux in
fun {NumeroAux X Y Acc}
if {And (X == 0) (Y == 0)} then Acc
else
if Y == 0 then {NumeroAux 0 X-1 Acc+1}
else
{NumeroAux X+1 Y-1 Acc+1}
end
end
end
{NumeroAux Y X 0}
end
end
{Browse {Numero 0 0}}这将像预期的那样浏览0。
https://stackoverflow.com/questions/26166548
复制相似问题