how can I make a variable local inside "product"?



On 5/11/06, Fabrizio Caruso <caruso at posso.dm.unipi.it> wrote:

> If I redefine product and sum will I solve the problem?

OK, if you make up a new name for the function then there won't be
confusion. How about:

my_product (ee,ii,aa,bb) ::=
 block ([jj:?gensym()],
 ee: subst(jj,ii,ee),
 buildq ([ee,jj,aa,bb], product(ee,jj,aa,bb)));

Then

  test(n) := my_product(n+i,i,1,3);

  test (n - 2*j);
    => (n - 2 j + 1) (n - 2 j + 2) (n - 2 j + 3)

  test (n - 2*i);
    => (n - 2 i + 1) (n - 2 i + 2) (n - 2 i + 3)

I didn't try any other examples. Hope this helps,

Robert