Inserting global list to a function, change the global list

I have an information on a global list variables. I want to use this information and make some manipulation with it. But I don’t want to change this global list. Right now any manipulation I make change this global list. I have already a long code code with this global list.
The following example represents my bug difficulty:

function Dont_Change_Global_List(L)
Manipulating_List = L
deleteat!(Manipulating_List,2)
return Manipulating_List
end

global s = [1,2,3,4,5]

println("function result: ",Dont_Change_Global_List(s))
println(“global list”, s)

I get:

function result: [1, 3, 4, 5]
global list[1, 3, 4, 5]

Is there anything I can do without changing the global list s but still make a manipulations?

Use Manipulating_list = copy(L) in your function.

1 Like

also please use ``` to wrap your code.

1 Like

See here

1 Like

x-ref: https://stackoverflow.com/questions/58149672/julia-language-inserting-global-list-to-a-function-change-the-global-list

1 Like