function make_counter(x) return (delta) -> begin x[1] += delta x end end
x = [0] c0 = make_counter(x) c1 = make_counter(x) c0(1) # [1] c1(1) # [2] c0(1) # [3] c1(1) # [4] That seems to be the case with scalars, but not with a vector (or other objects I assume). See the above code