Daniel Fischer wrote:

Hi,
I have recently come across the curious phenomenon that ghci is sometimes much slower than hugs.


[...]

ms as = zipWith (+) (zipWith (*) as (1:ms as)) (0:1:ms as)


Hugs has(**) a specific optimisation for the case where the left hand side of the declaration occurs as a subexpression in the right hand side.


You can get a similar benefit under ghci if you share the common subexpression by hand:

   ms' as = let bs = ms' as in
            zipWith (+) (zipWith (*) as (1:bs)) (0:1:bs)

(**) I haven't actually seen the code in question, and am repeating something which was on one of the mailing lists a few years ago. So please don't treat this as authoritative!

Regards,
Tom


_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to