   ### 5.15.3  Top and leaves of an expression : sommet feuille op

An operator is an infixed function : for example ’+’ is an operator and ’sin’ is a function.
An expression can be represented by a tree. The top of the tree is either an operator, or a function and the leaves of the tree are the arguments of the operator or of the function (see also 5.40.11).
The instruction sommet (resp. feuille (or op)) returns the top (resp. the list of the leaves) of an expression.
Input :

sommet(sin(x+2))

Output :

’sin’

Input :

sommet(x+2*y)

Output :

’+’

Input :

feuille(sin(x+2))

or :

op(sin(x+2))

Output :

x+2

Input :

feuille(x+2*y)

or :

op(x+2*y)

Output :

(x,2*y)

Remark
Suppose that a function is defined by a program, for example let us define the pgcd function :

pgcd(a,b):={local r; while (b!=0) {r:=irem(a,b);a:=b;b:=r;} return a;}

Then input :

sommet(pgcd)

Output :

’program’

Then input :

feuille(pgcd)

Output :

(a,b)

Then input :

feuille(pgcd)

Output :

(0,0) or (15,25) if the last input was pgcd(15,25)

Then input :

feuille(pgcd)

Output :

The body of the program : {local r;....return(a);}   