Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Macroexpand Calculator

Macroexpand

Function: macroexpand (<expr>) Returns the macro expansion of <expr> without evaluating it, when expr is a macro function call. Otherwise, macroexpand returns <expr>.

diffform(vars, expr) ::= block(    [varstoindices, firstindexof],    firstindexof: buildq([vars, y: ?gensym(), z: ?gensym()],        lambda([y],            block([matches: sublist_indices(vars, lambda([z], z = y))],                if length(matches) = 0 then unknown else matches[1]            )        )    ),    varstoindices: buildq([firstindexof, x: ?gensym()],        lambda([x], map(firstindexof, x))    )/*,    buildq([expr, varstoindices, t: ?gensym()],        map(lambda([t], [t[1], map(varstoindices, t[2])]), expr)    )*/);
macroexpand( diffform([x,y,z], [[2*x, [x,y]], [y, [y,z]]]) );

If the expansion of <expr> yields another macro function call, that macro function call is also expanded.

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

See also ::=, macros, and macroexpand1.

Examples

          (%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) macroexpand (h (y));
                                        y - a
          (%o4)                         -----
                                         99
          (%i5) h (y);
                                      y - 1234
          (%o5)                       --------
                                         99

There are also some inexact matches for macroexpand. Try ?? macroexpand to see them.

(%o1)                                true
(%i2) 

Macroexpand Example

Related Examples

macroexpand

? macroexpand;

Calculate

macroexpand

? macroexpand;

Calculate