StuYYY
StuYYY

Reputation: 107

Ocaml error unbound Value

When i try to evaluate line 2 or 5 of this program, i get "Unbound value carre" or "Unbound value bis". To evaluate it i use emacs with tuareg, could it be related ?

let carre x = x*x;;
carre(9);;

let bis y = y^y;;
bis("ab");;

For example, here is what i get for line 2 :

# Characters 0-5:
  carre(9);;
  ^^^^^
Error: Unbound value carre
# 

The code is very simple so i feel like the problem comes from emacs. I've tried to change function names, variables names, but nothing worked. Does anybody see what's wrong here ?

Upvotes: 0

Views: 6475

Answers (1)

PatJ
PatJ

Reputation: 6144

You need to evaluate the first line of your program before the second.

The interpretor doesn't know the definition of carre or bis until you've evaluated it.

Upvotes: 1

Related Questions