On 6/22/2010 10:45 AM, Robert Dodier wrote:
> On Tue, Jun 22, 2010 at 11:04 AM, Grigory Sarnitskiy
> <sargrigory at yandex.ru> wrote:
>
>
>> Imagine I need a function f, such that
>>
>> f(a*b) = f(g(a) * g(b))
>>
>> I don't want maxima to evaluate it ad infinitum, only n steps
>>
>> so if
>>
>> n = 1 then f(a*b) = f(g(a) * g(b))
>> n = 2 then f(a*b) = f(g(g(a)) * g(g(b)))
>> n = 3 then f(a*b) = f(g(g(g(a))) * g(g(g(b))))
>>
>
You want to do a simplification that depends on context without carrying
along the context.
How about this:
f(a,b,n):= if n<0 then f(g(a),g(b),n-1);
Here you express the context as an extra argument.
Think about it this way and see where it goes.
RJF