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 /op.go | |
| parent | bc774798c0805af43558cf61152a65772fc8bbc6 (diff) | |
| download | pfc-6817d5861986084f55785842b07639f7aeaacf0a.zip | |
accept e-notation
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 |