Int.of_string failure
Dominick LoBraico
dj at lobraico.com
Fri Nov 16 05:56:53 GMT 2012
String.strip
On Thursday, November 15, 2012 8:45:41 PM UTC-6, Francois Berenger wrote:
>
>
>
> 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/87425649/attachment-0001.html>
More information about the core
mailing list