On Mon, Feb 12, 2007 at 02:25:21PM -0800, Bryan O'Sullivan wrote:
> David Roundy wrote:
> >I'm rather curious (if you're sill interested) how this'll be affected by
> >the removal of the division from the inner loop. e.g.
> >
> >go :: Double -> Double -> Int -> IO ()
> >go !x !y !i
> >
David Roundy wrote:
I'm rather curious (if you're sill interested) how this'll be affected by
the removal of the division from the inner loop. e.g.
go :: Double -> Double -> Int -> IO ()
go !x !y !i
| i == 10 = printf "%.6f\n" (x+y)
| otherwise = go (x*y*(1
On Tue, Feb 13, 2007 at 08:18:25AM +1100, Donald Bruce Stewart wrote:
> Now, if we rewrite it to not use the temporary:
>
> go :: Double -> Double -> Int -> IO ()
> go !x !y !i
> | i == 10 = printf "%.6f\n" (x+y)
> | otherwise = go (x*y/3) (x*9) (i+1)
>
>
>
ewilligers:
> Eric Willigers wrote:
> >Do the two programs implement the same algorithm? The C program updates
> >x and y in sequence. The Haskell program updates x and y in parallel and
> >can be easier for the compiler to optimize.
>
>
> Hi Don,
>
> Expressing this in other words, do we want
Eric Willigers wrote:
Do the two programs implement the same algorithm? The C program updates
x and y in sequence. The Haskell program updates x and y in parallel and
can be easier for the compiler to optimize.
Hi Don,
Expressing this in other words, do we want the new y to be based on the
Donald Bruce Stewart wrote:
The following C program was described on #haskell
#include
int main()
{
double x = 1.0/3.0;
double y = 3.0;
int i= 1;
for (; i<=10; i++) {
x = x*y/3.0;
y = x*9.0;
}
print