If the function "copy" is implemented for z: z = ... newfun = let zz = copy(z); (x, y) -> f(zz, x, y) end
I think I understood that lambdas are less efficient than functions so this may be faster: let zz = copy(z) global newfun newfun(x, y) = f(zz, x, y) end