123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- /* Partition a term
- Input stack:
- term (factor or product of factors)
- free variable
- Output stack:
- constant expression
- variable expression
- */
- #include "stdafx.h"
- #include "defs.h"
- void
- partition(void)
- {
- save();
- p2 = pop();
- p1 = pop();
- push_integer(1);
- p3 = pop();
- p4 = p3;
- p1 = cdr(p1);
- while (iscons(p1)) {
- if (find(car(p1), p2)) {
- push(p4);
- push(car(p1));
- multiply();
- p4 = pop();
- } else {
- push(p3);
- push(car(p1));
- multiply();
- p3 = pop();
- }
- p1 = cdr(p1);
- }
- push(p3);
- push(p4);
- restore();
- }
|