op - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Expressions : Structure : op

op

extract operands from an expression

nops

number of operands of an expression

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

Calling Sequence

op(i, e)

op(i..j, e)

op(e)

op(list, e)

nops(e)

Parameters

i, j

-

integers indicating positions of operands

e

-

expression

list

-

list of integers indicating positions of operands at increasing nesting levels of an expression

Description

• 

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 opnopse+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 nopse1..nopse, 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.

Thread Safety

• 

The op and nops commands are thread-safe as of Maple 15.

• 

For more information on thread safety, see index/threadsafe.

Examples

u1,4,9

u:=1,4,9

(1)

nopsu

3

(2)

op2,u

4

(3)

op2..3,u

4,9

(4)

opu

1,4,9

(5)

op1,u

9

(6)

op0,u

list

(7)

opu,16

1,4,9,16

(8)

vfx,y,z

v:=fx,y,z

(9)

nopsv

3

(10)

op0,v

f

(11)

op2,v

y

(12)

If you try to refer to an operand that is not there, an error is returned

op4,v

Error, improper op or subscript selector

opv

x,y,z

(13)

op1,v

z

(14)

y1.2

y:=1.2

(15)

op0,y

Float

(16)

op1,y

12

(17)

op2,y

1

(18)

wfga,b,hc,d,e,j,k,l

w:=fga,b,hc,d,e,j,k,l

(19)

op1,op2,w

c

(20)

op2,1,w

c

(21)

op2,2..4,w

d,e,j

(22)

op1,1,w

l

(23)

xf13,15

x:=f13,15

(24)

op0,x

f

(25)

nopsx

2

(26)

op1,x

13

(27)

sseriessinx,x=2,6

s:=sin2+cos2f13,15212sin2f13,152216cos2f13,1523+124sin2f13,1524+1120cos2f13,1525+Of13,1526

(28)

op0,s

f13,152

(29)

op1,s

sin2

(30)

gx3+3x2+5x6

g:=f13,153+3f13,152+5f13,156

(31)

nopsg

4

(32)

nopsop1,g

2

(33)

op1,op2,g

3

(34)

In this case, the coeff command is more efficient.

coeffg,x2

3

(35)

See Also

applyop

map

numelems

subsop

type

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam