Reputation: 2574
I have a question about ocaml, i'm a beginner :-)
Here is an example of what i'm trying to do : (I know this is non-sense but it's not my real code, it's just an example)
let func a b = a
let func2 a b = b
let func_a a b =
if b < 0 then
func_b b a
else
func a b
let func_b a b =
if a < 0 then
func2 a b
else
func_a b a
The problem is:
Unbound value func_b in the first "if" in func_a...
If anyone could help?
Edit: I understand why this is unbound, but I dont know how to fix it.
Thanks a lot!
Max
Upvotes: 3
Views: 1113
Reputation: 41290
The keyword is mutually recursive functions:
let func a b = a
let func2 a b = b
let rec func_a a b =
if b < 0 then
func_b b a
else
func a b
and func_b a b =
if a < 0 then
func2 a b
else
func_a b a
Upvotes: 5