Reputation: 19132
I am writing a macro that makes it easier to write function definitions in a specific case, and the output is an expression for an array. I have gotten pretty far, and currently I can parse input into an expression of arrays, like
x = Expr[:(ones(length(u[:,1])) - 0.5 * u[:,1]),:(ones(length(u[:,2])) - u[:,2])]
But I need to take this and have it define the array where the columns are those expressions, like
[(ones(length(u[:,1])) - 0.5 * u[:,1]) (ones(length(u[:,2])) - u[:,2])]
And be able to do that for an arbitrary length expression array x
. Is there a good way to construct this output?
Upvotes: 1
Views: 79
Reputation: 3207
The expression head for the form [a b]
is hcat
. So e.g. Expr(:hcat, x...)
should work.
Upvotes: 4