[Haskell-cafe] Problem with percentage function?
midfield at gmail.com
Mon Apr 21 00:53:34 UTC 2014
since this seems to come up with some regularity, i'm curious, does the haskell standard or ghc implement
Florian Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with Integers"
for floating types? it seems like that would go a long way towards preventing this kind of confusion. i seem to recall brian o'sullivan using this algorithm for aeson or something.
On Apr 20, 2014, at 3:00 PM, Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
> On Sun, Apr 20, 2014 at 09:50:43PM +0000, Chapman, Anthony Sergio wrote:
>> Now it seems a bit peculiar to me that in your functions, you didn't
>> define the input ie toPerc = printf "%.2f" . (*100) instead of toPerc
>> number = printf "%.2f" . (*100)
> This expression uses the composition operator (.) rather than using function
> application directly. Note that for any functions 'f' and 'g', 'f . g' is
> defined to be the function '\x -> f (g x)'. Thus writing
> toPerc = printf "%.2f" . (*100)
> just means
> toPerc = \x -> printf "%.2f" ((*100) x)
> Desugaring the operator section gives
> toPerc = \x -> printf "%.2f" (x * 100)
> and moving the lambda to become an argument of 'toPerc' gives
> toPerc x = printf "%.2f" (x * 100)
> which is now in a form probably more familiar to you.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4885 bytes
Desc: not available
More information about the Haskell-Cafe