-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathnumerator.coffee
More file actions
38 lines (30 loc) · 841 Bytes
/
Copy pathnumerator.coffee
File metadata and controls
38 lines (30 loc) · 841 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
Eval_numerator = ->
push(cadr(p1))
Eval()
numerator()
numerator = ->
h = 0
theArgument = pop()
if (car(theArgument) == symbol(ADD))
push(theArgument)
#console.trace "rationalising "
rationalize()
theArgument = pop()
#console.log "rationalised: " + theArgument
if (car(theArgument) == symbol(MULTIPLY) and !isplusone(car(cdr(theArgument))))
h = tos
theArgument = cdr(theArgument)
#console.log "theArgument inside multiply: " + theArgument
#console.log "first term: " + car(theArgument)
while (iscons(theArgument))
push(car(theArgument))
numerator()
theArgument = cdr(theArgument)
multiply_all(tos - h)
else if (isrational(theArgument))
push(theArgument)
mp_numerator()
else if (car(theArgument) == symbol(POWER) && isnegativeterm(caddr(theArgument)))
push(one)
else
push(theArgument)