Maxima Operator
:=
The function definition operator.
f(x_1, ..., x_n) := expr
defines a function named f with arguments x_1, ..., x_n and function body expr.
:=
never evaluates the function body (unless explicitly evaluated by quote-quote '@w'
).
The function so defined may be an ordinary Maxima function (with arguments enclosed in parentheses)
or an array function (with arguments enclosed in square brackets).
When the last or only function argument x_n is a list of one element,
the function defined by :=
accepts a variable number of arguments.
Actual arguments are assigned one-to-one to formal arguments x_1, ..., x_(n - 1),
and any further actual arguments, if present, are assigned to x_n as a list.
All function definitions appear in the same namespace;
defining a function f
within another function g
does not limit the scope of f
to g
.
If some formal argument x_k is a quoted symbol,
the function defined by :=
does not evaluate the corresponding actual argument.
Otherwise all actual arguments are evaluated.
Examples:
:=
never evaluates the function body (unless explicitly evaluated by quote-quote).
(%i1) expr : cos(y) - sin(x); (%o1) cos(y) - sin(x) (%i2) F1 (x, y) := expr; (%o2) F1(x, y) := expr (%i3) F1 (a, b); (%o3) cos(y) - sin(x) (%i4) F2 (x, y) := ''expr; (%o4) F2(x, y) := cos(y) - sin(x) (%i5) F2 (a, b); (%o5) cos(b) - sin(a)
The function defined by :=
may be an ordinary Maxima function or an array function.
(%i1) G1 (x, y) := x.y - y.x; (%o1) G1(x, y) := x . y - y . x (%i2) G2 [x, y] := x.y - y.x; (%o2) G2 := x . y - y . x x, y
When the last or only function argument x_n is a list of one element,
the function defined by :=
accepts a variable number of arguments.
(%i1) H ([L]) := apply ("+", L); (%o1) H([L]) := apply("+", L) (%i2) H (a, b, c); (%o2) c + b + a