El martes, 5 de enero de 2016, 15:08:28 (UTC-6), Jamie Brandon escribió:
>
> julia> Vector[[1,2], [3, 4]] 
> 2-element Array{Array{T,1},1}: 
>  [1,2] 
>  [3,4] 
>
> julia> [[1,2] [3,4]] 
> 2x2 Array{Int64,2}: 
>  1  3 
>  2  4 
>
> julia> [[1,2], [3,4]] 
> WARNING: [a,b] concatenation is deprecated; use [a;b] instead 
>  in depwarn at deprecated.jl:73 
>  in oldstyle_vcat_warning at ./abstractarray.jl:29 
>  in vect at abstractarray.jl:32 
> while loading no file, in expression starting on line 0 
> 4-element Array{Int64,1}: 
>  1 
>  2 
>  3 
>  4 
>
> julia> [[1,2]; [3,4]] 
> 4-element Array{Int64,1}: 
>  1 
>  2 
>  3 
>  4 
>

This last behaviour is due to be changed in Julia v0.5 (the current 
development version) 
to do what you want, i.e. to make a vector of vectors.
 

>
> On 5 January 2016 at 19:38, Erik Schnetter <schn...@gmail.com 
> <javascript:>> wrote: 
> > I believe you have to first create an empty array, and then assign to 
> > each individual element. 
> > 
> > If the outer array is small, then you can take a work-around via a 
> tuple: 
> > 
> > collect(([1,2], [3,4])) 
> > 
> > -erik 
> > 
> > 
> > On Tue, Jan 5, 2016 at 2:28 PM, Alex <updat...@gmail.com <javascript:>> 
> wrote: 
> >> Hello, 
> >> 
> >> How to construct without push! equivalent vector of vectors? 
> >> 
> >> a=[] 
> >> push!(a, [1,2]) 
> >> push!(a, [2,3]) 
> >> 
> >> it gives: 
> >> # 2-element Array{Any,1}: 
> >> # [1,2] 
> >> # [2,3] 
> >> 
> >> If  i type 
> >> 
> >> a=[[1,2],[2,3]] 
> >> it gives me a 4-element array. 
> > 
> > 
> > 
> > -- 
> > Erik Schnetter <schn...@gmail.com <javascript:>> 
> > http://www.perimeterinstitute.ca/personal/eschnetter/ 
>

Reply via email to