Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

string_to_int

Lib.string_to_int : string -> int

Translates from a string to an integer.

An application string_to_int s returns the integer denoted by s, if such exists.

Failure

If the string cannot be translated to an integer.

Example

> string_to_int "123";
val it = 123: int

> string_to_int "~123";
val it = ~123: int

> string_to_int "foo";
Exception- HOL_ERR (at Lib.string_to_int: not convertable) raised

Comments

Similar functionality can be obtained from the Standard ML Basis Library function Int.fromString.

See also

Lib.int_to_string