repo.or.cz
/
eigenmath-fx.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Little fix after the last commit (mostly a git fail)
[eigenmath-fx.git]
/
partition.cpp
blob
5171af7e599f450013244f69230e363c0f5b60de
1
/* Partition a term
2
3
Input stack:
4
5
term (factor or product of factors)
6
7
free variable
8
9
Output stack:
10
11
constant expression
12
13
variable expression
14
*/
15
16
#include
"stdafx.h"
17
#include
"defs.h"
18
19
void
20
partition
(
void
)
21
{
22
save
();
23
24
p2
=
pop
();
25
p1
=
pop
();
26
27
push_integer
(
1
);
28
29
p3
=
pop
();
30
p4
=
p3
;
31
32
p1
=
cdr
(
p1
);
33
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
();
45
}
46
p1
=
cdr
(
p1
);
47
}
48
49
push
(
p3
);
50
push
(
p4
);
51
52
restore
();
53
}