RosettaCodeData/Task/Determine-if-a-string-is-numeric/OCaml/determine-if-a-string-is-numeric.ml
2024-10-16 18:07:41 -07:00

9 lines
188 B
OCaml

let is_int s =
try ignore (int_of_string s); true
with _ -> false
let is_float s =
try ignore (float_of_string s); true
with _ -> false
let is_numeric s = is_int s || is_float s