In [1]:
x=5; y=7; #Defined globally
function scopeTest(z)
x += z #Changes global value
y = Vector{Float64}(1) #Declares a variable, local scope
y[1] = 2
return x + y + z
end
Out[1]:
However, what is happening here, and why?
In [6]:
using Distributed
addprocs(1)
function f1()
@distributed for i = 1:100
x = 10
if x < 100
x = x + 1
end
end
x = x + 100 + 10
return x
end
f1()
In [7]:
function f2()
@distributed for i = 1:100
x = 10
if x < 100
x = x + 1
end
end
return x
end
f2()
Out[7]: