[Haskell-cafe] Number formatting

2010-02-08 Thread Günther Schmidt
Hello, is there a function which will format a number with separators, something that will turn 14509.8674 into 14,509.86? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Number formatting

2010-02-08 Thread Anton van Straaten
Günther Schmidt wrote: is there a function which will format a number with separators, something that will turn 14509.8674 into 14,509.86? There's a small function to do it here: http://bluebones.net/2007/02/formatting-decimals-in-haskell/ ___

Re: [Haskell-cafe] Number formatting

2010-02-08 Thread Stephen Tetley
Hello All Alternatively, less dependencies and a bit less golf (but not much testing...): Best wishes Stephen import Data.List import Numeric formatDecimal :: RealFloat a = a - String formatDecimal d = let s = showFFloat (Just 2) d (a,b) = break (=='.') s

Re: [Haskell-cafe] Number formatting

2010-02-08 Thread Stephen Tetley
Hi Günther Ahem... *FormatDecimal formatDecimal (888.005) ,888.01 I'll post a revision shortly (that handles negatives as well) ... On 8 February 2010 13:09, Stephen Tetley stephen.tet...@gmail.com wrote: Hello All Alternatively, less dependencies and a bit less golf (but not much

Re: [Haskell-cafe] Number formatting

2010-02-08 Thread Stephen Tetley
Hello I'd overlooked that the left-to-right behaviour of the paramorphism when I needed to go right-to-left, here's a version with a rather horrible right fold (different seeds for the counter, ho-hum, but easily testable): import Data.List import Numeric formatDecimal :: RealFloat a = a -