aboutsummaryrefslogtreecommitdiffstats
path: root/op.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 /op.go
parentbc774798c0805af43558cf61152a65772fc8bbc6 (diff)
downloadpfc-6817d5861986084f55785842b07639f7aeaacf0a.zip
accept e-notation
Diffstat (limited to 'op.go')
-rw-r--r--op.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/op.go b/op.go
index 6ccc6a8..3a193b6 100644
--- a/op.go
+++ b/op.go
@@ -5,9 +5,12 @@ import (
"math"
)
-// parseOperator returns a closure that performs the specified arithmetic operation,
-// or OpError if op is not a valid operator.
-func parseOperator(op byte) (func(lhs float64, rhs float64) float64, error) {
+// Op is a binary operator.
+type Op func(lhs, rhs float64) float64
+
+// parseOp parses a binary operator, returning a function that performs the operation, or
+// OpError if op is not a valid operator.
+func parseOperator(op byte) (Op, error) {
switch op {
case '+':
return func(lhs, rhs float64) float64 { return lhs + rhs }, nil