Little fix after the last commit (mostly a git fail)
[eigenmath-fx.git] / partition.cpp
blob5171af7e599f450013244f69230e363c0f5b60de
1 /* Partition a term
3 Input stack:
5 term (factor or product of factors)
7 free variable
9 Output stack:
11 constant expression
13 variable expression
16 #include "stdafx.h"
17 #include "defs.h"
19 void
20 partition(void)
22 save();
24 p2 = pop();
25 p1 = pop();
27 push_integer(1);
29 p3 = pop();
30 p4 = p3;
32 p1 = cdr(p1);
34 while (iscons(p1)) {
35 if (find(car(p1), p2)) {
36 push(p4);
37 push(car(p1));
38 multiply();
39 p4 = pop();
40 } else {
41 push(p3);
42 push(car(p1));
43 multiply();
44 p3 = pop();
46 p1 = cdr(p1);
49 push(p3);
50 push(p4);
52 restore();