From a642e93ea637d3187d983722b7d13953971277b2 Mon Sep 17 00:00:00 2001 From: John Meacham Date: Fri, 8 Jun 2007 18:23:53 +0000 Subject: [PATCH] Speed up number printing and remove the need for Array by using the standard 'intToDigit' routine --- Text/Printf.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Text/Printf.hs b/Text/Printf.hs index ee0b51c..14f57da 100644 --- a/Text/Printf.hs +++ b/Text/Printf.hs @@ -18,7 +18,6 @@ module Text.Printf( ) where import Prelude -import Data.Array import Data.Char import Numeric(showEFloat, showFFloat, showGFloat) import System.IO @@ -221,14 +220,13 @@ itos n = let (q, r) = quotRem n 10 in itos q ++ [toEnum (fromEnum '0' + toInt r)] -chars = array (0,15) (zipWith (,) [0..] "0123456789abcdef") itosb :: Integer -> Integer -> String itosb b n = if n < b then - [chars!n] + [intToDigit $ fromInteger n] else let (q, r) = quotRem n b in - itosb b q ++ [chars!r] + itosb b q ++ [intToDigit $ fromInteger r] stoi :: Int -> String -> (Int, String) stoi a (c:cs) | isDigit c = stoi (a*10 + fromEnum c - fromEnum '0') cs -- 1.7.10.4