I want to create an array of arrays explicitly. Initially I thought that this would work:
julia> x = [ [1] [1,2]
[] [3,4,5] ]
but this does not work (I was expecting
2×2 Array{Any,2}:
[1] [1, 2]
Any[] [3, 4, 5]
of course).
Then I tried to use comas, semicolons, in different places, but I could not find any alternative that works. Is there one?
Just to contextualize: What I am facing is a didactic problem only. I am asking students to write a function which will deal with this array of arrays, and I want to provide that array as the input of the exercise. At this point I did not find any simpler way to initialize it than the somewhat cumbersome, for this purpose,
Unfortunately at this point, yes. This is the result of a toy example of classifying particles in cells, and each position of the matrix contains the list of particles in each cell. Not only we didn’t talk about tuples yet, also these lists can be large.
I only want to comment that I appreciate the care you’ve taken into declare this empty array as Int[] instead of simply []. Changing this solved a type instability that made the code about 5 times slower and led to a lot of memory allocations .