[Haskell-cafe] Re: problems with square roots...
Scherrer, Chad
Chad.Scherrer at pnl.gov
Wed Dec 21 15:26:21 EST 2005
------------
From: Daniel Carrera <daniel.carrera at zmsl.com>
Hey,
The sqrt function is not doing what I want. This is what I want:
round sqrt(2)
---------------------------------------------------
Daniel,
A lot of Haskell folks like to avoid parentheses as much as possible, and there's a really
convenient way to do this. There is a Prelude function
($) f x = f x
which is right-associative, so you can write
round $ sqrt x == round (sqrt x)
This becomes really convenient when multiple application is involved:
print $ round $ sqrt x == print (round (sqrt x))
-Chad
More information about the Haskell-Cafe
mailing list