
Hi Eugene,
Clever solution.
It didn't come right back so I interrupted it. Guess it would do all those multiplies by zero.
Does anyone know how to define it to avoid that?
Thanks.
Michael
--- On Mon, 4/20/09, Eugene Kirpichov
I've been looking at CPS in Haskell and wondering how many multiplications the product function performs if it encounters a zero somewhere in the input list. Zero?
Does anyone know the definition of the product function?
Michael
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Eugene Kirpichov Web IR developer, market.yandex.ru

On Apr 20, 2009, at 4:32 PM, michael rice wrote:
Hi Eugene,
Clever solution.
It didn't come right back so I interrupted it. Guess it would do all those multiplies by zero.
Does anyone know how to define it to avoid that?
Thanks.
Michael
--- On Mon, 4/20/09, Eugene Kirpichov
wrote: From: Eugene Kirpichov
Subject: Re: [Haskell-cafe] CPS and the product function To: "michael rice" Cc: haskell-cafe@haskell.org Date: Monday, April 20, 2009, 9:40 AM Check that by experiment in ghci or by looking at the source:
Prelude*> product [0..]
Or search "product" at http://holumbus.fh-wedel.de/hayoo/hayoo.html and click on one of the Source links.
I've been looking at CPS in Haskell and wondering how many multiplications the product function performs if it encounters a zero somewhere in
2009/4/20 michael rice
: the input list. Zero?
Does anyone know the definition of the product function?
Michael Eugene Kirpichov
Making multiplication non-strict?

Hello michael, Monday, April 20, 2009, 6:32:47 PM, you wrote: something like 0*_ = 0 x*y = x *# y or vice versa _*0 = 0 x*y = x *# y where *# is original (*) definition. current ghc definiton just performs cpu-level operation w/o checking for 0 since this is rarely useful and need some time OTOH, boolean operations are expected to short-circuit, so they are defined properly. try and (iterate [True,False])
Hi Eugene,
Clever solution.
It didn't come right back so I interrupted it. Guess it would do all those multiplies by zero.
Does anyone know how to define it to avoid that?
Thanks.
Michael
--- On Mon, 4/20/09, Eugene Kirpichov
wrote:
From: Eugene Kirpichov
Subject: Re: [Haskell-cafe] CPS and the product function To: "michael rice" Cc: haskell-cafe@haskell.org Date: Monday, April 20, 2009, 9:40 AM
Check that by experiment in ghci or by looking at the source:
Prelude*>> product [0..]
Or search "product" at http://holumbus.fh-wedel.de/hayoo/hayoo.html and click on one of the Source links.
2009/4/20 michael rice
: I've been looking at CPS in Haskell and wondering how many multiplications the product function performs if it encounters a zero somewhere in the input list. Zero?
Does anyone know the definition of the product function?
Michael
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (3)
-
Bulat Ziganshin
-
michael rice
-
Sebastiaan Visser