NUMBERATOMEXPR(3)

NAME
numberAtomExpr - returns the number of atoms in an expression

SYNOPSYS
#include "logmmm.h"
int numberAtomExpr(expr)
chain_list *expr;

PARAMETER

expr
    expression

DESCRIPTION
numberAtomExpr() returns the number of atoms of expr.

EXAMPLE
#include "mutnnn.h"		/* mbk utilities */
#include "logmmm.h"
chain_list *expr1,*expr2;
expr1 = createExpr(OR);
addQExpr(expr1,createAtom("a"));
addQExpr(expr1,createAtom("b"));
expr2 = createExpr(OR);
addQExpr(expr2,createAtom("c"));
addQExpr(expr2,createAtom("d"));
addQExpr(expr1,expr2);
printf("%d",numberAtomExpr(expr1));
/* it will display
4
*/
freeExpr(expr1);		/* don't free expr2 ! */

PROGRAM
int numberAtomExpr(expr)
chain_list *expr;
{
if (ATOM(expr))
   return(1)
else
   {
   int cpt = 0;
   while (expr = CDR(expr))
      cpt = cpt + numberAtomExpr(CAR(expr));
   return(cpt);
   }
}

SEE ALSO
log(1), abl(1), profExpr(3), lengthExpr(3), equalExpr(3), equalVarExpr(3), searchExpr(3), searchOperExpr(3).