[Haskell-cafe] Folding Integrals

Lennart Augustsson lennart at augustsson.net
Wed Dec 12 16:42:22 EST 2007


Not "can", "should".  And it might even survive in th world of Unicode.

On Dec 12, 2007 4:17 PM, Brent Yorgey <byorgey at gmail.com> wrote:

>
> On Dec 12, 2007 10:36 AM, Arie Groeneveld <bradypus at xs4all.nl> wrote:
>
> > Reinier Lamers schreef:
> > >
> > > printint :: Int -> [Char]
> > > printint = map chr . map (+0x30) . reverse . map (`mod` 10) .
> > > takeWhile (>0) . iterate (`div`10)
> > >
> > Most of the time I use this:
> >
> > digits :: Integer -> [Int]
> > digits = map (flip(-)48.ord) . show
> >
>
> One can also use Data.Char.digitToInt in place of (flip (-) 48 . ord).
>
> -Brent
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071212/461c3be4/attachment.htm


More information about the Haskell-Cafe mailing list