aboutsummaryrefslogtreecommitdiffstats
path: root/calc.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-10-04 13:56:56 -0400
committerSam Anthony <sam@samanthony.xyz>2025-10-04 13:56:56 -0400
commit6817d5861986084f55785842b07639f7aeaacf0a (patch)
tree5cbe9f9867dbea5df99f168f6c350a84e58f11cd /calc.go
parentbc774798c0805af43558cf61152a65772fc8bbc6 (diff)
downloadpfc-6817d5861986084f55785842b07639f7aeaacf0a.zip
accept e-notation
Diffstat (limited to 'calc.go')
-rw-r--r--calc.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/calc.go b/calc.go
index 67794aa..1e0e598 100644
--- a/calc.go
+++ b/calc.go
@@ -61,17 +61,13 @@ func (c *Calculator) negate() {
}
}
-// performOp performs the specified arithmetic operation.
-func (c *Calculator) performOperation(operator byte) {
- fn, err := parseOperator(operator)
- if err != nil {
- return
- }
+// operate performs a binary arithmetic operation on the stored values.
+func (c *Calculator) operate(op Op) {
lhs, rhs, err := c.operands()
if err != nil {
return
}
- c.stack.push(fn(lhs, rhs))
+ c.stack.push(op(lhs, rhs))
c.buf = ""
}