[Haskell-cafe] Folding Integrals
Henning Thielemann
lemming at henning-thielemann.de
Wed Dec 12 06:15:35 EST 2007
On Wed, 12 Dec 2007, Reinier Lamers wrote:
> Back in my Introduction to Functional Programming course, Daan Leijen
> demonstrated how to print integers in Haskell using function
> composition. Something along the lines of:
>
> printint :: Int -> [Char]
> printint = map chr . map (+0x30) . reverse . map (`mod` 10) . takeWhile
> (>0) . iterate (`div`10)
Nice, that is even without 'unfoldr'. It might be a bit better style to
use
map (+ ord '0')
More information about the Haskell-Cafe
mailing list