1 /* Transform an expression using table look-up
3 The expression and free variable are on the stack.
5 The argument s is a null terminated list of transform rules.
7 For example, see itab.cpp
9 Internally, the following symbols are used:
13 X free variable, i.e. F of X
19 C list of conditional expressions
43 // save symbol context in case eval(B) below calls transform
45 push(get_binding(symbol(METAA
)));
46 push(get_binding(symbol(METAB
)));
47 push(get_binding(symbol(METAX
)));
49 set_binding(symbol(METAX
), X
);
51 // put constants in F(X) on the stack
57 polyform(); // collect coefficients of x, x^2, etc.
85 set_binding(symbol(METAX
), pop());
86 set_binding(symbol(METAB
), pop());
87 set_binding(symbol(METAA
), pop());
94 // search for a METAA and METAB such that F = A
100 for (i
= h
; i
< tos
; i
++) {
101 set_binding(symbol(METAA
), stack
[i
]);
102 for (j
= h
; j
< tos
; j
++) {
103 set_binding(symbol(METAB
), stack
[j
]);
104 p1
= C
; // are conditions ok?
113 if (iscons(p1
)) // no, try next j