Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of "and" for multiple mutual recursive functions in Ocaml

So I have three functions in OCaml

let my_A = my_C
let my_B = my_A
let my_C = my_B

Function A calls function C. Function B calls function A. Function C calls function B.

I tried to use "and" to make them mutually recursive (so they can call each other), as in:

let my_A = my_C
and
my_B = my_A
and
my_C = my_B

but it says

"unbound value my_C in line __"

It's basically saying "hey you can't call my_C in my_A" but I don't understand why? Am I not allowed to chain three functions together?

like image 750
Solace Avatar asked Dec 10 '25 19:12

Solace


1 Answers

You must say let rec ... and ... and .... You don't have the rec.

like image 183
Jeffrey Scofield Avatar answered Dec 12 '25 10:12

Jeffrey Scofield