Re: problems with square roots...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: problems with square roots...

Chad Scherrer-2
------------
From: Daniel Carrera <[hidden email]>


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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re: problems with square roots...

Creighton Hogg
On Wed, 21 Dec 2005, Scherrer, Chad wrote:

> ------------
> From: Daniel Carrera <[hidden email]>
>
>
> 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))

Doesn't it sometimes feel like the $ operator is Haskell's
way of saying "We're not with those Lisp guys, seriously"?
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe