0

I have a question about using a local function in a global function.
I tried to write the function which appears in the picture, but an error said

unbound value of f

It's strange that this error occurs. It should not appear because I defined the definition of the function enf in affichage.

Here is a picture of a relevant part of my code:

click here to see the picture of program

What can be the reason of this error?

zx485
  • 28,498
  • 28
  • 50
  • 59
Amar Dje
  • 5
  • 1
  • 4
  • 1
    You'd better try to reduce your function you are trying to write, and provide the error on SO with the exact piece of code that is going wrong with the exact error message you got as well. – Pierre G. Nov 18 '18 at 18:55
  • 2
    Try to make a [mcve] and post your code as text instead of as an image. You are much more likely to get an answer if you make it easy for potential answerers to do so. See also [ask]. – glennsl Nov 18 '18 at 19:03
  • 2
    Please post the code of your program in your question, instead of providing a link to a painting of it. – Bergi Nov 18 '18 at 20:46

1 Answers1

1

enf is not defined when affichage is defined, so since the body of affichage refers to enf, this results in an unbound value error. In order to have mutually recursive functions, you'll need something of the form

let rec affichage (* ... *) =
  (* ... *)
and enf (* ... *) =
  (* ... *)
in
  (* ... *)
;;
Kevin Ji
  • 10,479
  • 4
  • 40
  • 63