A simple question about the 'FUNCTION format.



Stavros Macrakis wrote:

>>func(a,b) := 'func(a,b);
>>ev(sum(func(a,b),a,1,2),func);
>>    
>>
>
>I think you will get what you want simply with
>
>   sum(func(a,b),a,1,2)
>
>which gives
>
>   func(2, b) + func(1, b)
>
>The ev(...,func) means "evaluate all the instances of func in the
>expression".  That is what is leading to the infinite recursion, since
>evaluating func leads to a new instance of func.
>
>Why are you using ev here?  If you must use ev, you can also use the
>"noun form" facility:
>
>   func(a,b):= ('func)(a,b);
>
>but this is rather obscure (see below).
>
>What exactly are you trying to accomplish?
>
I think i have found what i needed with the ('func) notation. This seems 
very powerful indeed !

I have another question :
When you evaluate
sum(func(a,b),a,1,1000)
        to
func(1000, b) + ... + func(2, b) + func(1, b)

is there a way to avoid the complete development, and let the sum 
untouched if no simplification is possible at this moment of calculum ?
I thought of replacing 1000 by a variable, and then substituting the 
variable with the real value, but that's not very clean.

>
>[Very interesting and useful explanations] 
>  
>
That is *exactly* what i was looking for. Thank you very much. Perhaps 
it could be included in the documentation, i think it would be very 
useful for new maxima users.

>By the way....
>
>  
>
>>(C2) func(a,b) := block([],return('func(a,b)));
>>(D2)                FUNC(A, B) := BLOCK([], RETURN('FUNC(A, B)))
>>    
>>
>
>You don't need the block or the return here.  Maxima is Lisp-like, so
>the following will work:
>
>   FUNC(A, B) := BLOCK([], 'FUNC(A, B));
>
>or simply
>
>   FUNC(A, B) := 'FUNC(A, B);
>
>Not relevant to your particular problem, but....
>  
>
thank you, that's worth being noted. At this time, i'm not very fluent 
in Lisp and Maxima, but i'am learning !


--
Mathieu Avila
mavila@irisa.fr