
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.
b
On Apr 20, 2014, at 3:00 PM, Tom Ellis
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.
Tom _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe