print ints as ints instead of floats

i.e. no trailing dot
This commit is contained in:
Moritz Gmeiner 2024-08-26 01:57:08 +02:00
commit 222de81a19

View file

@ -4,7 +4,7 @@ type lox_value = String of string | Number of float | Bool of bool | Nil
let string_of_lox_value lox_value = let string_of_lox_value lox_value =
match lox_value with match lox_value with
| String s -> s | String s -> s
| Number x -> string_of_float x | Number x -> if Float.is_integer x then string_of_int (Int.of_float x) else string_of_float x
| Bool b -> string_of_bool b | Bool b -> string_of_bool b
| Nil -> "nil" | Nil -> "nil"