Proposal: Make digitToInt and intToDigit work up to base 36

Christian Maeder Christian.Maeder at
Tue Jul 3 11:21:24 CEST 2012

Am 02.07.2012 19:17, schrieb Bryan O'Sullivan:
> It already surprised me that digitToInt accepted hex digits;

This indicates that digitToInt is broken anyway (or should be named 

For the decimal case you would need to use "isDigit" anyway and then 
could use just "ord c - ord '0'" instead of "digitToInt".

So a (more) total implementation of intToDigit could avoid some tests
leaving it to the programmer to decide between speed and safety.

Cheers Christian

   | c <= '9' = ord c - ord '0'
   | c >= 'a' = ord c - ord 'a' + 10
   | otherwise = ord c - ord 'A' + 10

More information about the Libraries mailing list