op
extract operands from an expression
nops
number of operands of an expression
Calling Sequence
Parameters
Description
Thread Safety
Examples
op(i, e)
op(i..j, e)
op(e)
op(list, e)
nops(e)
i, j
-
integers indicating positions of operands
e
expression
list
list of integers indicating positions of operands at increasing nesting levels of an expression
The op function extracts operands from an expression. The nops function returns the number of operands in an expression.
If the first argument to the op function is a positive integer i, then the ith operand of e is returned. If the operand does not exist, an error occurs.
If the first argument to op is a negative integer i, then the result is op⁡nops⁡e+i+1,e.
For some data structures, op(0, e) is defined as a special case (for more information, see the particular data structure help page). For an unevaluated function call, op(0, e) is the name of the function. For an indexed name, op(0, e) is the name without the index. For a series, op(0, e) is x-a where x is the variable and a is the expansion point of the series. If calculating op(0, series(exp(x), x=a)), x-a returns rather than a. For all other data structures, op(0, e) returns the type of e.
If the values of the operand selectors are not in the range −nops⁡e−1..nops⁡e, an error occurs.
If the first argument to op is a range i..j, then the result is a sequence of the ith to jth operands of e. Negative integers in the range are treated as described above; nops(e)+1 is added to them.
If the op function has only one argument, this is equivalent to op(1..nops(e), e).
If the first argument to op is a list, then the elements of the list refer to a sub-operand of e at increasing levels of nesting. This is merely a short-form notation. The expression op([a1, a2, ..., an], e) returns the same result as op(an, op(..., op(a2, op(a1, e))...)), but is more efficient to execute.
When the first argument is a list, the last element of the list can be a range. As stated above, this is merely a short-form notation. The expression op([a1, a2, ..., an1..an2], e) returns the same result as op(an1..an2, op(..., op(a2, op(a1, e))...)), but is more efficient to execute.
The op and nops commands are thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
u≔1,4,9
nops⁡u
3
op⁡2,u
4
op⁡2..3,u
4,9
op⁡u
1,4,9
op⁡−1,u
9
op⁡0,u
op⁡u,16
1,4,9,16
v≔f⁡x,y,z
nops⁡v
op⁡0,v
f
op⁡2,v
y
If you try to refer to an operand that is not there, an error is returned
op⁡4,v
Error, improper op or subscript selector
op⁡v
x,y,z
op⁡−1,v
z
y≔1.2
op⁡0,y
Float
op⁡1,y
12
op⁡2,y
−1
w≔f⁡g⁡a,b,h⁡c,d,e,j,k,l
op⁡1,op⁡2,w
c
op⁡2,1,w
op⁡2,2..4,w
d,e,j
op⁡−1,−1,w
l
z≔f13,15
op⁡0,z
nops⁡z
2
op⁡1,z
13
s≔series⁡sin⁡x,x=2,6
s≔sin⁡2+cos⁡2⁢x−2−12⁢sin⁡2⁢x−22−16⁢cos⁡2⁢x−23+124⁢sin⁡2⁢x−24+1120⁢cos⁡2⁢x−25+O⁡x−26
op⁡0,s
x−2
op⁡1,s
sin⁡2
g≔x3+3⁢x2+5⁢x−6
nops⁡g
nops⁡op⁡1,g
op⁡1,op⁡2,g
In this case, the coeff command is more efficient.
coeff⁡g,x2
See Also
applyop
map
numelems
subsop
type
type/series
Download Help Document