## Maxima – 202 – Definire funzioni – 3 Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.609.

`macroexpand1 (expr)`
Returns the macro expansion of `expr` without evaluating it, when `expr` is a macro function call. Otherwise, `macroexpand1` returns `expr`.

`macroexpand1` quotes its argument. However, if the expansion of a macro function call has side effects, those side effects are executed.

If the expansion of `expr` yields another macro function call, that macro function call is not expanded.

See also `::=`, `macros`, and `macroexpand`.

``````(%i1) g (x) ::= x / 99;
x
(%o1)                             g(x) ::= --
99
(%i2) h (x) ::= buildq ([x], g (x - a));
(%o2)                   h(x) ::= buildq([x], g(x - a))
(%i3) a: 1234;
(%o3)                                1234
(%i4) macroexpand1 (h (y));
(%o4)                              g(y - a)
(%i5) h (y);
y - 1234
(%o5)                              --------
99``````

Differenza rispetto `macroexpand`: solo in `%o4`.

`macros`
Default value: `[]`.

`macros` is the list of user-defined macro functions. The macro function definition operator `::=` puts a new macro function onto this list, and `kill`, `remove`, and `remfunction` remove macro functions from the list.

See also `infolists`.

`splice (a)`
Splices (interpolates) the list named by the atom `a` into an expression, but only if `splice` appears within `buildq`; otherwise, `splice` is treated as an undefined function. If appearing within `buildq` as `a` alone (without `splice`), `a` is substituted (not interpolated) as a list into the result. The argument of `splice` can only be an atom; it cannot be a literal list or an expression which yields a list.

Typically `splice` supplies the arguments for a function or operator. For a function `f`, the expression `f (splice (a))` within `buildq` expands to `f (a, a, a, ...)`. For an operator `o`, the expression `"o"` `(splice (a))` within `buildq` expands to `"o" (a, a, a, ...)`, where `o` may be any type of operator (typically one which takes multiple arguments). Note that the operator must be enclosed in double quotes `"`.

``````(%i6) buildq ([x: [1, %pi, z - y]], foo (splice (x)) / length (x));
foo(1, %pi, z - y)
(%o6)                       -----------------------
length([1, %pi, z - y])
(%i7) buildq ([x: [1, %pi]], "/" (splice (x)));
1
(%o7)                                 ---
%pi
(%i8) matchfix ("<>", "<>");
(%o8)                                 <>
(%i9) buildq ([x: [1, %pi, z - y]], "<>" (splice (x)));
(%o9)                          <>1, %pi, z - y<>``````

Posta un commento o usa questo indirizzo per il trackback.