nod*_*ddy 2 function sml function-declaration
我想以"循环"方式使用函数,如以下示例所示:
fun cll1 (s)= cll2(s);
fun cll2 (s)= cll3(s);
fun cll3 (s)= cll(s);
Run Code Online (Sandbox Code Playgroud)
写这个会在SML中产生错误,构造函数cll2
是未绑定的.有人可以帮我写这些内容吗?它可能在C; 我想用SML编写它.
你想要and
关键字.
fun cll1 s = cll2 s
and cll2 s = cll3 s
and cll3 s = cll s
Run Code Online (Sandbox Code Playgroud)
显然这些定义不会发生,因为它是无限递归(通常你会在一个或多个函数中测试基本情况),但这是一般形式.