How to initialize an array of AbstractArray?

Lets say you have a list of the sizes of each array, then you can use a comprehension:

julia> l = [ (2,2), (3,3), (3,3) ];

julia> m = [ zeros(s) for s in l ]
3-element Array{Array{Float64,2},1}:
 [0.0 0.0; 0.0 0.0]
 [0.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0]
 [0.0 0.0 0.0; 0.0 0.0 0.0; 0.0 0.0 0.0]
2 Likes