How do you pass two arrays to a function so that the function can copy one 
to the other, and return the values in place? Of course, a=b won't work, 
but neither does a=copy(b). See the following example:

julia> function copytest!(a,b)
           b=copy(a)
           println ("copytest: a,b ",a,b)
           nothing
       end
copytest! (generic function with 1 method)

julia> a=ones(2,2)
2x2 Array{Float64,2}:
 1.0  1.0
 1.0  1.0

julia> b=zeros(2,2)
2x2 Array{Float64,2}:
 0.0  0.0
 0.0  0.0

julia> copytest!(a,b)
copytest: a,b [1.0 1.0
 1.0 1.0][1.0 1.0
 1.0 1.0]

julia> println ("copytest: a,b ",a,b)
copytest: a,b [1.0 1.0
 1.0 1.0][0.0 0.0
 0.0 0.0]

The first println shows that b WAS changed inside the copytest function. 
The second println shows that it WASN'T changed on return. I've also tried 
with do loops, but this causes a segmentation fault.

Reply via email to