I want to declare a 2d array which takes the form of zigzag shape as follows:
***
************
******
*
*
**
where each star denotes an integer. This means that the lengths of its rows differ top to bottom. A vector of a vector seems to fit in this case and my code is:
struct In
cols :: Vector{Int};
end
struct Out
nlen :: Int;
rows :: Vector{In};
function Out(n)
o = new(n, Vector{In}(undef,n));
for i in 1:n
o.rows(i).cols = Vector{Int}(undef,i);
end
return o
end
end
myarray = Out(5);
Running the above code results in the error:
LoadError("main.jl", 24, MethodError(In[#undef, #undef, #undef, #undef, #undef], (1,), 0x0000000000006a05))
I wonder what is wrong with the implementation and hope to know other ways to meet the need here.