- open Batteries
- class type number = object ('a)
- (* method plus: 'a -> 'a *)
- end
- class int_wrap (i: int) = object
- val i = i
- end
- class float_wrap (f: float) = object
- val f = f
- end
- let parse: string -> number = fun s ->
- if String.exists s "." then
- float_of_string s |> new float_wrap
- else
- int_of_string s |> new int_wrap