Sponsored links: Algebra eBooks
 

Related

macroexpand

? macroexpand;

Calculate

macroexpand

? macroexpand;

Calculate

macroexpand

Run Example
(%i1)gensym();
(%o1)                              gensym()
(%i2) f(l, x) ::= buildq([l : l, x : x, z : abad9987629%],sublist_indices(l, lambda([z], z =  x)));
(%o2) f(l, x) ::= buildq([l : l, x : x, z : abad9987629%], 
                                        sublist_indices(l, lambda([z], z = x)))
(%i3) f([x,y,z],a);
(%o3)                                 []
(%i4) f([x,y,z],x);
(%o4)                                 [1]
(%i5) macroexpand(f([x,y,z],a));
(%o5) sublist_indices([x, y, z], lambda([abad9987629%], abad9987629% = a))
(%i6) macroexpand(f([x,y,z],x));
(%o6) sublist_indices([x, y, z], lambda([abad9987629%], abad9987629% = x))
(%i7) 
Run Example
diffform(vars, expr) ::= block(    [indexofvar],    indexofvar: 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]            )        )    ),    buildq([expr, indexofvar, t: ?gensym()],        map(lambda([t], [t[1], map(indexofvar, t[2])]), expr)    ));
(%o1) diffform(vars, expr) ::= block([indexofvar], 
indexofvar : 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
buildq([expr, indexofvar, t : gensym()], 
map(lambda([t], [t , map(indexofvar, t )]), expr)))
                  1                   2
(%i2) macroexpand( diffform([x,y,z], [[2*x, [x,y]], [y, [y,z]]]) );
(%o2) map(lambda([g33272], [g33272 , map(lambda([g33270], 
                                  1
block([matches : sublist_indices([x, y, z], 
lambda([g33271], g33271 = g33270))], if length(matches) = 0 then unknown
 else matches )), g33272 )]), [[2 x, [x, y]], [y, [y, z]]])
             1          2
(%i3)              diffform([x,y,z], [[2*x, [x,y]], [y, [y,z]]])  ;
(%o3)                    [[2 x, [1, 2]], [y, [2, 3]]]
(%i4) 
Run Example
gensym();
(%o1)                              gensym()
(%i2) f(l, x) ::= buildq([l,x,z:?gensym()],sublist_indices(l, lambda([z], z =  x)));
(%o2) f(l, x) ::= buildq([l, x, z : gensym()], 
                                        sublist_indices(l, lambda([z], z = x)))
(%i3) macroexpand(f([x,y,z],a));
(%o3)      sublist_indices([x, y, z], lambda([g33270], g33270 = a))
(%i4) macroexpand(f([x,y,z],x));
(%o4)      sublist_indices([x, y, z], lambda([g33271], g33271 = x))
(%i5) f([x,y,z],a);
(%o5)                                 []
(%i6) f([x,y,z],x);
(%o6)                                 [1]
(%i7) 

Related Help

Help for Macroexpand