Reputation: 572
Is there a way to go from an expression of a list to a list of expressions in julia without having to evaluate the intermediaries?
i.e.
julia> l = :([1, 2+x, 5, 3/x])
:([1, 2 + x, 5, 3 / x])
julia> @eval [$(quote e end) for e in $l]
ERROR: UndefVarError: x not defined
The ideal state would be:
[1, :(2 + x), 5, :(3 / x)])
Upvotes: 2
Views: 127
Reputation: 69869
This is the way to do it (if I understand correctly what you want):
julia> l.args
4-element Array{Any,1}:
1
:(2 + x)
5
:(3 / x)
Upvotes: 3