Oops, the second method was a mutating biggen! It should have been
function biggen(x::Expr)
Meta.isexpr(x, :call) || error("Only works for calls right now")
x = copy(x) ## Otherwise we'll rewrite the arguments of the original
expression
for i in 2:length(x.args)
x.args[i] = biggen(x.args[i])
end
return x
end
On Friday, September 19, 2014 9:57:00 AM UTC-5, Gray Calhoun wrote:
> On Friday, September 19, 2014 9:32:09 AM UTC-5, David P. Sanders wrote:
>>
>> El viernes, 19 de septiembre de 2014 09:26:09 UTC-5, David P. Sanders
>> escribió:
>>>
>>> El viernes, 19 de septiembre de 2014 08:58:56 UTC-5, Isaiah escribió:
>>>>
>>>> To do what you want, very briefly:
>>>>
>>>> > x.args[3] == :pi && x.args[3] = Expr(:call, :BigFloat, :pi)
>>>> ...
>>>>
>>> Yes, that's what I need, thanks. Now I need to iterate over the (in
>>> principle arbitrarily complex, i.e. nested) syntax tree and do this
>>> everywhere.
>>> Is there a standard method for this kind of iteration?
>>>
>>
>> I guess some kind of recursion. I'll give it a go...
>>
>
> This might help you get started:
>
> biggen(x::Symbol) = Expr(:call, :big, x)
>
[...cut...]