unapply
returns an operator from an expression and arguments
MakeFunction
Calling Sequence
Parameters
Options
Description
Examples
References
Compatibility
MakeFunction(expr, x, y, ..)
MakeFunction(expr, x, y, .., options)
MakeFunction(expr, l)
MakeFunction(expr, l, options)
unapply(expr, x, y, ..)
unapply(expr, x, y, .., options)
unapply(expr, l)
unapply(expr, l, options)
expr
-
expression
x, y, ..
variable names, or names with type specifiers
l
list of variable names
options
list of optional arguments
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 MakeFunction (that is, in either the list or the specified variable names). With this option, MakeFunction 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 ⅆⅆxf⁡x or DEsol structures.
Providing the optional argument numeric is simply a shortcut for numeric=variables.
proc_options=keywords
This option must be a keyword, or list or set of keywords. The MakeFunction 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 MakeFunction command implements the lambda-expressions of lambda calculus.
The unapply command is an alias for MakeFunction; the two commands are the same in all respects.
The result of MakeFunction(expr, x) is a functional operator. Applying this operator to x gives the original expression.
MakeFunctionexpr,xx→expr
In particular, for a function f⁡x,
MakeFunctionfx,x→f
To construct a multi-argument operator from a multi-variate expression, list all the variables as arguments to MakeFunction or explicitly put all variables in a list and pass it as the second argument to MakeFunction.
Use the MakeFunction command when constructing an operator using contents of variables or evaluated expressions.
The variable names may be simple names of type symbol (e.g., x, y, z), or names with type specifiers using :: (e.g, x::numeric, y::integer, z::float).
p≔x2+sin⁡x+1
f≔MakeFunction⁡p,x
f≔x↦x2+sin⁡x+1
f⁡π6
π236+32
q≔x2+y3+1
q≔y3+x2+1
f≔unapply⁡q,x
f≔x↦y3+x2+1
f⁡2
y3+5
g≔MakeFunction⁡q,x,y
g≔x,y↦y3+x2+1
g⁡2,3
32
h≔MakeFunction⁡q,x,y
h≔x,y↦y3+x2+1
h⁡2,3
Example of MakeFunction with the numeric option:
f1≔MakeFunction⁡x2+1,x,numeric
f1 ≔ procxlocalunnamed;iftype⁡evalf⁡x,'numeric'thenx^2+1elifprocname<>'unknown'andnotmember⁡sprintf⁡%a,procname,%,%%,%%%then'procname'⁡xelseunnamed ≔ pointto⁡36893628798392729284[1];'unnamed'⁡xend ifend proc
f1⁡1
2
f1⁡x
This behavior is different from specification of the type with the variable
f2≔MakeFunction⁡x2+1,x::numeric
f2≔x::numeric↦x2+1
f2⁡1
f2⁡x
Error, invalid input: f2 expects its 1st argument, x, to be of type numeric, but received x
Example of MakeFunction with specified options:
f := proc() lprint(`called`); 0; end proc;
f ≔ proclprint⁡called;0end proc
pol≔MakeFunction⁡x2+3⁢x+1+f⁡,x,proc_options=arrow,operator,remember
pol≔x↦x2+3⋅x+1+f⁡
pol⁡1
called
5
pol⁡2
11
Gonnet, G.H. "An Implementation of Operators for Symbolic Algebra Systems" SYMSAC. July 1986.
The MakeFunction command was introduced in Maple 2023.
For more information on Maple 2023 changes, see Updates in Maple 2023.
See Also
apply
examples/functionaloperators
operators[D]
operators[functional]
Download Help Document