I have an n*m
sized array A
, and I would like to create a grid of its elements. The output should look something like:
B = (A[1,1], A[2,1]
A[1,1], A[2,2]
...
A[1,1], A[2,m]
A[1,2], A[2,1]
A[1,2], A[2,2]
...
A[1,2], A[2,m]
...
A[n,1], A[n,m])
My first approach would be to do something like this:
A = [1 5;
2 6;
3 7;
4 8]
B = collect(Iterators.product(A))
However, this only returns
4×2 Matrix{Tuple{Int64}}:
(1,) (5,)
(2,) (6,)
(3,) (7,)
(4,) (8,)
Instead of the desired output above.
Any ideas?