diff options
Diffstat (limited to 'op.go')
| -rw-r--r-- | op.go | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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 |