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 function (see also 6.39.10).
The sommet command finds the top of an expression.
Examples.
sin |
+ |
The op command finds the list of the leaves
of an expression.
feuille is a synonym for op.
Examples.
x+2 |
x,2 y |
If the top of an expression expr is an infixed operator, the left hand side will be expr[1] and the right hand side will be expr[2]. The left and right commands are alternative commands to find the sides (see Section 6.3.4, Section 6.37.1, Section 6.38.2, Section 6.40.6, Section 6.55.4 and Section 6.55.5 for specific uses of left and right.)
Examples.
= |
y |
x2 |
Remark.
If a function is defined by a program (see Section 12.1.2) then
the top will be the function ’program’ and the leaves will be
a sequence consisting of the arguments of the defined function,
followed by a sequence of 0s (one for each argument) followed
by the body of the function. For example, define the pgcd
function:
Then:
Input:
Output:
program |
Input:
or:
Output:
a,b |
Input:
or:
Output:
0,0 |
Input:
or:
Output:
|