How to write a function which may return noun form of itself in Maxima language



Richard, Robert, and Stavros,

Thanks for all the suggestions. I tried both Robert's and Richard's
suggestions and they worked great. I will also try simplifying pacakge
that Starvos has introduced. This also seems applicable for my issue.

Thank you very much!!
Yasuaki Honda

2011?8?7?7:15 Robert Dodier <robert.dodier at gmail.com>:

> On 8/6/11, ???? <yasuaki.honda at gmail.com> wrote:
>
> > Is there a suggested way to write a function in Maxima language which
> > may return its noun form if it cannot process the arguments?
>
> One way to handle it is to create a simplification rule for
> each case. Then any arguments aside from those cases
> are just left unmodified.
>
> e.g.
>
> matchdeclare (xx, numberp);
> tellsimp (foo (xx), xx^2);
>
> foo (123);
>  => 15129
>
> foo (x + y);
>  => foo(y + x)
>
> /* and here we make up another case that we can handle ... */
>
> matchdeclare (ll, listp);
> tellsimp (foo (ll), map (foo, ll));
>
> foo ([1, 2, %pi, x]);
>  => [1, 4, foo(%pi), foo(x)]
>
>
> Hope this helps,
>
> Robert Dodier
>