aboutsummaryrefslogtreecommitdiffstats
path: root/calculator.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2023-07-29 10:41:57 -0230
committerSam Anthony <sam@samanthony.xyz>2023-07-29 10:41:57 -0230
commit88bf9516752558207bd34c4fec73ce2632c22b2c (patch)
tree814aaa9195138aac5388bd84146b2e3dc00b7463 /calculator.go
parent0e1cd2b6a328887c1a630eae0b34366a607bb1b8 (diff)
downloadpfc-88bf9516752558207bd34c4fec73ce2632c22b2c.zip
use Stack push, pop methods
Diffstat (limited to 'calculator.go')
-rw-r--r--calculator.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/calculator.go b/calculator.go
index b5dae10..8afc43a 100644
--- a/calculator.go
+++ b/calculator.go
@@ -56,8 +56,7 @@ func (c *Calculator) performOp(op byte) error {
} else if fl, err := strconv.ParseFloat(c.buf, 64); err == nil {
fn(&c.stack[len(c.stack)-1], fl)
} else if len(c.stack) > 1 {
- fn(&c.stack[len(c.stack)-2], c.stack[len(c.stack)-1])
- c.stack = c.stack[:len(c.stack)-1]
+ fn(&c.stack[len(c.stack)-2], *c.stack.pop())
}
c.buf = ""
return nil