Hello,
I have a time-consuming function f :: Int -> Int and I have to do for example x * f i for numerous values of x and i. Since x can be zero, I want to avoid the evaluation of f i in these cases. Here is what I did:
times x (f i)
where
times x y = if x == 0 then 0 else x * y
Could you please confirm that this avoids the evaluation of f i when x = 0?