I would like to do something like this:
fun f () =
let
fun a() = b()
and
fun b() = a()
in
()
end
where a and b are sensible mutually recursive functions. However, this gives:
Error: syntax error: replacing AND with SEMICOLON
Is there any way to do this?
In mathematics and computer science, mutual recursion is a form of recursion where two mathematical or computational objects, such as functions or datatypes, are defined in terms of each other.
The rec keyword is used together with the let keyword to define a recursive function.
Declaration of mutually recursive functions in SML is marked by a fun ... and ...
block:
fun f () =
let
fun a() = b()
and b() = a() (* There is no 'fun' keyword before b() *)
in
()
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With