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)
function biggen(x::Expr)
Meta.isexpr(x, :call) || error("Only works for calls right now")
for i in 2:length(x.args)
x.args[i] = biggen(x.args[i])
end
return x
end
Then
julia> biggen(:(a + b + (a/c)))
:(big(a) + big(b) + big(a) / big(c))
You'll need to define a method for numbers as well. HTH. (there may be
better approaches...)