-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathdenominator.coffee
More file actions
50 lines (39 loc) · 984 Bytes
/
Copy pathdenominator.coffee
File metadata and controls
50 lines (39 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
### denominator =====================================================================
Tags
----
scripting, JS, internal, treenode, general concept
Parameters
----------
x
General description
-------------------
Returns the denominator of expression x.
###
Eval_denominator = ->
push(cadr(p1))
Eval()
denominator()
denominator = ->
h = 0
theArgument = pop()
#console.trace "denominator of: " + theArgument
if (car(theArgument) == symbol(ADD))
push(theArgument)
rationalize()
theArgument = pop()
if (car(theArgument) == symbol(MULTIPLY) and !isplusone(car(cdr(theArgument))))
h = tos
theArgument = cdr(theArgument)
while (iscons(theArgument))
push(car(theArgument))
denominator()
theArgument = cdr(theArgument)
multiply_all(tos - h)
else if (isrational(theArgument))
push(theArgument)
mp_denominator()
else if (car(theArgument) == symbol(POWER) && isnegativeterm(caddr(theArgument)))
push(theArgument)
reciprocate()
else
push(one)