1 | ###
|
2 | Partition a term
|
3 |
|
4 | Input stack:
|
5 |
|
6 | term (factor or product of factors)
|
7 |
|
8 | free variable
|
9 |
|
10 | Output stack:
|
11 |
|
12 | constant expression
|
13 |
|
14 | variable expression
|
15 | ###
|
16 |
|
17 |
|
18 |
|
19 | partition = ->
|
20 | save()
|
21 |
|
22 | p2 = pop()
|
23 | p1 = pop()
|
24 |
|
25 | push_integer(1)
|
26 |
|
27 | p3 = pop()
|
28 | p4 = p3
|
29 |
|
30 | p1 = cdr(p1)
|
31 |
|
32 | while (iscons(p1))
|
33 | if (Find(car(p1), p2))
|
34 | push(p4)
|
35 | push(car(p1))
|
36 | multiply()
|
37 | p4 = pop()
|
38 | else
|
39 | push(p3)
|
40 | push(car(p1))
|
41 | multiply()
|
42 | p3 = pop()
|
43 | p1 = cdr(p1)
|
44 |
|
45 | push(p3)
|
46 | push(p4)
|
47 |
|
48 | restore()
|