I'm trying to do and show a Matrix Multiplication in Typst. I implemented the basic O(n³) algorithm for matmul and it's working. My return value is an array of arrays. Now I want to show the content of the matrix as a $ mat() $.
I looked here and something very similar to what I want is being done, but with a table.
table(
columns: C.len(),
rows: C.first().len(),
..for row in C {
for cell in row {
(str(cell),)
}
}
)
However, that ..for destructuring seems not to be possible on $ mat() $.
So how do I pass a matrix (array of arrays) to a $ mat() $ function to be typeset?
Full source code: https://typst.app/project/rGXaEQsB1LzGgXw9KO39Dv
Like so:
$ #math.mat(..C) $. You need to use the spreading operator but it only works in code mode which we reenter with#here.