June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,39 @@
|
|||
rmod(i, j) := mod(j, i)$
|
||||
rpow(x, y) := y^x$
|
||||
|
||||
rpn(sexpr) := (
|
||||
operands: [],
|
||||
expr: charlist(sexpr),
|
||||
|
||||
for token in expr do (
|
||||
if token = "+" then (
|
||||
push(pop(operands) + pop(operands), operands)
|
||||
)
|
||||
elseif token = "-" then (
|
||||
push(-1 * (pop(operands) - pop(operands)), operands)
|
||||
)
|
||||
elseif token = "*" then (
|
||||
push(pop(operands) * pop(operands), operands)
|
||||
)
|
||||
elseif token = "/" then (
|
||||
push(1 / (pop(operands) / pop(operands)), operands)
|
||||
)
|
||||
elseif token = "%" then (
|
||||
push(rmod(pop(operands), pop(operands)), operands)
|
||||
)
|
||||
elseif token = "^" then (
|
||||
push(rpow(pop(operands), pop(operands)), operands)
|
||||
)
|
||||
elseif token # " " then (
|
||||
push(parse_string(token), operands)
|
||||
),
|
||||
|
||||
if token # " " then (
|
||||
print(token, " : ", operands)
|
||||
)
|
||||
),
|
||||
|
||||
pop(operands)
|
||||
)$
|
||||
|
||||
rpn("3 4 2 * 1 5 - 2 3 ^ ^ / +"), numer;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
(%i5) ev(rpn("3 4 2 * 1 5 - 2 3 ^ ^ / +"),numer)
|
||||
3 : [3]
|
||||
4 : [4, 3]
|
||||
2 : [2, 4, 3]
|
||||
* : [8, 3]
|
||||
1 : [1, 8, 3]
|
||||
5 : [5, 1, 8, 3]
|
||||
- : [- 4, 8, 3]
|
||||
2 : [2, - 4, 8, 3]
|
||||
3 : [3, 2, - 4, 8, 3]
|
||||
^ : [8, - 4, 8, 3]
|
||||
^ : [65536, 8, 3]
|
||||
/ : [1.220703125e-4, 3]
|
||||
+ : [3.0001220703125]
|
||||
(%o5) 3.0001220703125
|
||||
Loading…
Add table
Add a link
Reference in a new issue