| |
comp.lang.haskell |
Assume that the evaluation of a function 'expensive' takes a lot of
time. Hence I want to avoid unnecessary evaluations of 'expensive'.
expensive :: Int -> (Int,Int)
expensive x = (x,x)
f :: Int -> Int
f x = fst (expensive x) + snd (expensive x)
Will 'expensive x' be evaluated twice to compute 'f x'?
If so, how can I avoid it?