Library with some functions for reading and converting numeric tokens.
Exported Functions: readBin, readHex, readInt, readNat, readOct
readInt
:: String -> [(Int, String)]
Read a (possibly negative) integer as a first token in a string.
The string might contain leadings blanks and the integer is read
up to the first non-digit.
On success returns [(v,s)]
, where v
is the value of the integer
and s
is the remaing string without the integer token.
readNat
:: String -> [(Int, String)]
Read a natural number as a first token in a string.
The string might contain leadings blanks and the number is read
up to the first non-digit.
On success returns [(v,s)]
, where v
is the value of the number
and s is the remaing string without the number token.
readHex
:: String -> [(Int, String)]
Read a hexadecimal number as a first token in a string.
The string might contain leadings blanks and the number is read
up to the first non-hexadecimal digit.
On success returns [(v,s)]
, where v
is the value of the number
and s is the remaing string without the number token.
readOct
:: String -> [(Int, String)]
Read an octal number as a first token in a string.
The string might contain leadings blanks and the number is read
up to the first non-octal digit.
On success returns [(v,s)]
, where v
is the value of the number
and s is the remaing string without the number token.
readBin
:: String -> [(Int, String)]
Read a binary number as a first token in a string.
The string might contain leadings blanks and the number is read
up to the first non-binary digit.
On success returns [(v,s)]
, where v
is the value of the number
and s is the remaing string without the number token.