[Haskell-cafe] How to calculate de number of digits of an
integer? (was: Is logBase right?)
Bulat Ziganshin
bulat.ziganshin at gmail.com
Tue Aug 25 10:16:49 EDT 2009
Hello Henning,
Tuesday, August 25, 2009, 6:11:00 PM, you wrote:
>> digits = iterate (`div` 10) >>> takeWhile (>0) >>> length
> This needs quadratic time with respect to the number of digits, doesn't
> it?
why?
i think that `show` uses pretty the same way to build list of
digits, so we just omit unneeded computations
--
Best regards,
Bulat mailto:Bulat.Ziganshin at gmail.com
More information about the Haskell-Cafe
mailing list