Haskell question

Scott Turner p.turner@computer.org
Thu, 28 Dec 2000 18:55:25 -0500

Scott <adric@wipcradio.cc> wrote:
>[[x,y] | x<-[1..50],y<-[1..50],z<-[1..50],x**2+y**2==z**2]
>expect it to return a number of results, but it shows:
>My question is where is [3.0,4.0,5.0],[5.0,12.0,13.0]?
>Maybe a rounding error somewhere?

That's right.  Haskell has 3 exponentiation operators.  If you replace **
with ^ or ^^ then you'll get the results you expect.  

The ** operator is the one which is defined for floating point numbers.
The easy implementation of a**b begins by finding the log of a, so it's
going to give approximate results unless you're in some very sophisticated
and rigorous numeric environment.  In my Hugs on a PC, I get
   Prelude> 5.0 ** 2.0 == 25.0

Scott Turner
p.turner@computer.org       http://www.ma.ultranet.com/~pkturner