From 6817d5861986084f55785842b07639f7aeaacf0a Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Sat, 4 Oct 2025 13:56:56 -0400 Subject: accept e-notation --- op.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'op.go') 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 -- cgit v1.2.3