problem with recursive functions



Robert Dodier <robert.dodier <at> gmail.com> writes:

> The body of a lambda expression is not evaluated; it is not even simplified
> (so stuff like 1 + 1 appears verbatim in a lambda expression).
> As noted by Stavros it is necessary to substitute d - 1 into the
> lambda expression to get the hoped-for result. Here is another
> version. I like buildq better than subst in this context because
> buildq does not evaluate its arguments. Also buildq makes
> substitutions in parallel (although that is not relevant here).
> 
> f[d] := if d=1 then lambda ([x], makelist (i, i, 1, x))
>            else buildq ([d1 : d - 1], lambda ([x], 2 * f[d1](x)));
> 
Hi Robert,

Thanks for your input. I realize I have to do some serious learning with Maxima.
As I have written to Stavros, I found that I can easily do what I want with
something like:

f[d,x] := if d=1 then makelist( i, i, 1, x ) else do_something( f[d-1,x] );

Regards,
Norbert