diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-10-04 13:56:56 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-10-04 13:56:56 -0400 |
| commit | 6817d5861986084f55785842b07639f7aeaacf0a (patch) | |
| tree | 5cbe9f9867dbea5df99f168f6c350a84e58f11cd /calc.go | |
| parent | bc774798c0805af43558cf61152a65772fc8bbc6 (diff) | |
| download | pfc-6817d5861986084f55785842b07639f7aeaacf0a.zip | |
accept e-notation
Diffstat (limited to 'calc.go')
| -rw-r--r-- | calc.go | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -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 = "" } |