matrix = [ Int64[] for i=1:2, j=1:2 ]

Friday, February 26, 2016 at 11:51:09 AM UTC+11, Ilya Orson wrote:
>
> Hello everyone,
>
> I am working with a matrix of initially empty vectors and wanted to fill 
> each vector with specific elements using push!, but I get a weird result:
>
>
> matrix = fill(Int64[],2,2) 
>
> 2x2 Array{Array{Int64,1},2}:
>  Int64[]  Int64[]
>  Int64[]  Int64[]
>
>
>
> push!(matrix[1,1],3,2)
>
> 2-element Array{Int64,1}:
>  3
>  2
>
>
>
> But this results in:
>
>
> matrix
>
> 2x2 Array{Array{Int64,1},2}:
>  [3,2]  [3,2]
>  [3,2]  [3,2]
>
>
>
> I wanted something like this:
>
>
> matrix
>
> 2x2 Array{Array{Int64,1},2}:
>   [3,2]   Int64[]
>  Int64[]  Int64[]
>
>
>
> Is this behaviour to be expected? 
>
>
> I am using julia 0.4.2 and  append! does the same thing. 
>
>
> Any advice or workarounds would be apreciated!
>
>
>

Reply via email to