Question

I have two functions, f and g, which call each other recursively. Unfortunately, when f calls g, it has not yet been declared, so I get an "unbound variable" error. How can I prototype (or whatever the equivalent vocabulary is) this function in SML/NJ?

Was it helpful?

Solution

Use and:

fun f x = ... 
and g x = ...

More info here.

OTHER TIPS

Mutual Recursion. Use and instead of fun between the two functions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top