From 88bf9516752558207bd34c4fec73ce2632c22b2c Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Sat, 29 Jul 2023 10:41:57 -0230 Subject: use Stack push, pop methods --- calculator.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'calculator.go') 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 -- cgit v1.2.3