Int.of_string failure
Francois Berenger
francois.berenger.working at gmail.com
Fri Nov 16 02:45:40 GMT 2012
On Friday, November 16, 2012 11:33:26 AM UTC+9, Francois Berenger wrote:
>
> (also true for Caml.int_of_string):
>
> The following work:
> # Float.of_string " 3.12";;
> - : Core.Std.Float.t = 3.12
> # Float.of_string "3.12";;
> - : Core.Std.Float.t = 3.12
> Int.of_string "3";;
> - : Core.Std.Int.t = 3
>
> The following does not:
> Int.of_string " 3";;
> Exception: (Failure "Int.of_string: \" 3\"").
>
> I don't understand why. Bug?
>
> I guess a scanf will work.
I guessed wrong:
# Scanf.sscanf " 123" "%d" (fun i -> i);;
Exception:
(Scanf.Scan_failure
"scanf: bad input at char number 0: ``character ' ' is not a decimal
digit''").
> But I think Int.of_string should work too.
>
> Regards,
> F.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/core/attachments/20121115/d20655e9/attachment-0001.html>
More information about the core
mailing list