# Inserting global list to a function, change the global list

**URL:** <https://discourse.julialang.org/t/inserting-global-list-to-a-function-change-the-global-list/29275>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 28, 2019, 7:16pm UTC](https://discourse.julialang.org/t/inserting-global-list-to-a-function-change-the-global-list/29275 "2019-09-28T19:16:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamuzd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamuzd/32/8803_2.png) [@Tamuzd](https://discourse.julialang.org/u/Tamuzd)\
**Post date:** [September 28, 2019, 7:16pm UTC](https://discourse.julialang.org/t/inserting-global-list-to-a-function-change-the-global-list/29275/1 "2019-09-28T19:16:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jkbest2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jkbest2/32/7350_2.png) [@jkbest2](https://discourse.julialang.org/u/jkbest2)\
**Post date:** [September 28, 2019, 7:28pm UTC](https://discourse.julialang.org/t/inserting-global-list-to-a-function-change-the-global-list/29275/2 "2019-09-28T19:28:28Z")

</div>

Use `Manipulating_list = copy(L)` in your function.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [September 28, 2019, 8:08pm UTC](https://discourse.julialang.org/t/inserting-global-list-to-a-function-change-the-global-list/29275/3 "2019-09-28T20:08:39Z")

</div>

also please use ``` to wrap your code.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [September 29, 2019, 12:35am UTC](https://discourse.julialang.org/t/inserting-global-list-to-a-function-change-the-global-list/29275/4 "2019-09-29T00:35:48Z")

</div>

[See here](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [September 29, 2019, 2:13am UTC](https://discourse.julialang.org/t/inserting-global-list-to-a-function-change-the-global-list/29275/5 "2019-09-29T02:13:47Z")

</div>

x-ref: [Julia language: Inserting global list to a function, change the global list - Stack Overflow](https://stackoverflow.com/questions/58149672/julia-language-inserting-global-list-to-a-function-change-the-global-list)
