Re: [julia-users] Scope of Arrays
Thank you. This is very helpful. Howard On Saturday, January 3, 2015 11:53:12 PM UTC-5, Jiahao Chen wrote: On Sat, Jan 3, 2015 at 10:07 AM, Howard how...@zail.org javascript: wrote: a = test You may find John Myles White's blog post on this topic helpful: http://www.johnmyleswhite.com/notebook/2014/09/06/values-vs-bindings-the-map-is-not-the-territory/ Thanks, Jiahao Chen Staff Research Scientist MIT Computer Science and Artificial Intelligence Laboratory
[julia-users] Scope of Arrays
I have two snippets of code which I think should behave exactly the same, but they do not. In the first snippet, the variable test only changes in the i loop. In the second snippet, the variable test changes in the j loop which makes no sense to me. The only difference in the two sets of code is the second and fifth lines in each set. Any help would be much appreciated. ## Snippet 1: Correct for i in 1:4 test = i for j in 1:3 a = test a=j println(j loop: a $a; test $test) end println(i loop: test $test) end ## Snippet 2: Incorrect?? for i in 1:4 test = [i] for j in 1:3 a = test a[1]=j println(j loop: a $a; test $test) end println(i loop: test $test) end Thanks,