Using eval to evaluate a variable inside an expression when string interpolation is not ok

Note that you can also do A = [1 4; 2 5; 3 6] instead of first constructing 1d arrays and concatenating them.

You can use

julia> using Random # for shuffle

julia> mapslices(shuffle, A, dims=1)
3×2 Matrix{Int64}:
 2  5
 3  4
 1  6

Metaprogramming (generating code) can be a powerful tool, but it’s also a specialized one that is used rarely in practice — it’s not something I would typically recommend for starting users. See How to warn new users away from metaprogramming - #22 by stevengj

1 Like