I often find myself in a situation where it is convenient to create matrices or arrays with various objects in them. For vectors, the syntax
[a,b,c] will create a vector that holds variables a, b, and c, no matter what the types of these object are. I would like to know if there is some similar way of creating matrices or higher-dimensional arrays.
;; and so on can be used to concatenate in various dimensions (which is useful in its own right), but this will not always work to create an array of e.g., strings or functions. For example, in julia v1.7.3
["A" "B"; "C" "D"]
["A";"C";;"B";"D"] does not (it used to in v1.7.2). If you want a matrix with arrays in it, say
[ [1,2] [1,2,3] [2,4,5] [7,8,9,10] ]
the best I’ve come up with is
reshape( [ [1,2] , [2,4,5] , [1,2,3] , [7,8,9,10] ] , 2 , 2 )
None of this functionality is strictly necessary, but I construct objects like these often enough that I was curious if anyone knows any syntax, or possibly a macro, that would make constructing such objects more convenient.