unapply - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Operations : Operators : unapply

unapply

returns an operator from an expression and arguments

 

Calling Sequence

Parameters

Description

Examples

References

Calling Sequence

unapply(expr, x, y, ..)

unapply(expr, x, y, .., options)

unapply(expr, l)

unapply(expr, l, options)

Parameters

expr

-

expression

x, y, ..

-

variable names

l

-

list of variable names

options

-

list of optional arguments

Description

• 

The result of unapply(expr, x) is a functional operator. Applying this operator to x gives the original expression.

unapplyexpr,xxexpr

• 

In particular, for a function fx,

unapplyfx,xf

• 

To construct a multi-argument operator from a multi-variate expression, list all the variables as arguments to unapply or explicitly put all variables in a list and pass it as the second argument to unapply.

• 

Use the unapply command when constructing an operator using contents of variables or evaluated expressions.

  

The following optional arguments are available.

• 

numeric=variables

  

For this option variables must be a set or list of variable names, or a single variable name, all of which must correspond to a variable in the input for unapply (that is, in either the list or the specified variable names). With this option, unapply constructs an operator that returns unevaluated whenever the specified variables do not evaluate to numeric values.

  

Note: This option cannot be used for inputs containing derivatives, such as ⅆⅆxfx or DEsol structures.

• 

numeric

  

This is simply a shortcut for numeric=variables, which places all the variables in the numeric list.

• 

proc_options=keywords

  

This option must be a keyword, or list or set of keywords. The unapply command constructs the operator with the specified keywords as options. By default, the options {operator,arrow} are used, but any of arrow, inline, operator, remember, or system are valid keywords.

• 

The unapply command implements the lambda-expressions of lambda calculus.

Examples

px2+sinx+1

p:=x2+sinx+1

(1)

funapplyp,x

f:=x→x2+sinx+1

(2)

fπ6

136π2+32

(3)

qx2+y3+1

q:=y3+x2+1

(4)

funapplyq,x

f:=x→y3+x2+1

(5)

f2

y3+5

(6)

gunapplyq,x,y

g:=x,y→y3+x2+1

(7)

g2,3

32

(8)

hunapplyq,x,y

h:=x,y→y3+x2+1

(9)

h2,3

32

(10)

Example of unapply with the numeric option:

f1unapplyx2+1,x,numeric

f1:=procxlocalunnamed&semi;iftypeevalfx&comma;&apos;numeric&apos;thenx&Hat;2&plus;1elifprocname<>&apos;unknown&apos;andnotmembersprintf%a&comma;procname&comma;%&comma;%%&comma;%%%then&apos;procname&apos;xelseunnamed:=pointto`Array(1..1, {(1) = 18446884435337559926})`&lsqb;1&rsqb;&semi;&apos;unnamed&apos;xend ifend proc

(11)

f11

2

(12)

f1x

f1x

(13)

This behavior is different from specification of the type with the variable

f2unapplyx2&plus;1&comma;x::numeric

f2:=x::numeric&rarr;x2&plus;1

(14)

f21

2

(15)

f2x

Error, invalid input: f2 expects its 1st argument, x, to be of type numeric, but received x

Example of unapply with specified options:

f := proc() lprint(`called`); 0; end proc;

f:=proclprintcalled&semi;0end proc

(16)

polunapplyx2&plus;3x&plus;1&plus;&apos;f&apos;&comma;x&comma;proc_options&equals;remember&comma;operator&comma;arrow

pol:=x&rarr;x2&plus;3x&plus;1&plus;f

(17)

pol1

called

5

(18)

pol2

called

11

(19)

pol1

5

(20)

References

  

Gonnet, G.H. "An Implementation of Operators for Symbolic Algebra Systems" SYMSAC. July 1986.

See Also

apply

examples/functionaloperators

operators[D]

operators[functional]

 


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