Reputation: 1875
Having a really hard time figuring out what is wrong with my function, even with the help of the ocaml.org docs.
let dist (x1, y1) (x2, y2) =
let x = (x2 - x1)^2 in
let y = (y2 - y1)^2 in
(x + y) ^ (.5);; //line 13
And I'm getting
File "ish.ml", line 13, characters 12-13:
Error: Syntax error
What is going on?
Upvotes: 1
Views: 60
Reputation: 66823
You need to write floating constants with at least one digit before the decimal point.
Note that in OCaml ^
is a string operation, not exponentiation. You can use **
for exponentiation:
# ( ** );;
- : float -> float -> float = <fun>
# 3.0 ** 0.5;;
- : float = 1.73205080756887719
Upvotes: 2