Prevent overriding an array

Try

function next_step(x, i)
    y = copy(x)
    y[i] = y[i]+1
    return y
end

I would strongly suggest having a look into the manual.

4 Likes