On Fri 27 Aug, Simon Peyton-Jones wrote: 
> > func n = map (func' n) [1..10]
> > func' x y = nfib x
> 
> There isn't a free subexpression to lift out of func.

I had always imagined that in a fully lazy language a function like Mike
Thyers example would get transformed into something like this..

func n = map (func' n) [1..10]
func' = \x -> (\y -> nfib x)   -- nfib x is free in \y...???
      = \x -> let u = nfib x
              in \y -> u

So..
func' n = let u = nfib n
          in  \y -> u

So (nfib n) should get evaluated only once.
Have I gone wrong somewhere?

Regards
-- 
Adrian Hey



Reply via email to