subst("+","-", - x);



Hello all,

I want to replace in an expression the minus sign by the plus sign.
But I can do that with subst("+", "-", expr).
I don't have found the way to do that with map function.

In fact the final goal is to compute the number of atom in an EXPANDed form of expression.

To do that I have tried:

ONE(EXPR):=BLOCK(
    MODE_DECLARE(EXPR,ANY),
    IF NUMBERP(EXPR) THEN RETURN(EXPR),
    IF ATOM(EXPR) THEN RETURN(1)
);

/*
 * Calcule le nombre d'atome dans la forme
 * EXPANDed de l'expression.
 *
 */
NATOMS(EXPR):=BLOCK(
    [EXPR1],
    MODE_DECLARE([EXPR,EXPR1],ANY),
    IF EXPR=0 THEN RETURN(0),
    IF ATOM(EXPR) THEN RETURN(1),
    EXPR1:SUBST("+", "-", EXPR),
    EXPR1:SUBST("+", "*", EXPR1),
    EXPR1:SUBST("*", "^", EXPR1),
    MAP(ONE,EXPR1)
);

Thanks for your help.

Laurent.