I have several matrices
x1, ..., xn what’s a way to create a named tuple
(x1=x1, ..., xn=xn) without having to type all components one by one?
x1 = rand(2, 2)
x2 = rand(2, 2)
x3 = rand(2, 2)
lazyhelper(x1, x2, x3)
# returns (x1=x1, x2=x2, x3=x3)
(; x1, x2, x3) (needs Julia 1.6)
If you want to automate it for a large number of variables, you’ll either need to define a macro or create an expression and
I have a package AddToField.jl that makes the creation of a named tuple easier as well
@add m1 = ...
@add m2 = f(m1)