You could also fudge the input:

{-# LANGUAGE NoMonomorphismRestriction #-}

log10 = floor . logBase 10 . (0.5+) . fromIntegral

numDigits n | n < 0 = 1 + numDigits (-n)
numDigits 0         = 1
numDigits n         = 1 + log10 n

-- checked [0..10^8], finding a counter-example is left as an exercise :P
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to