Created
September 28, 2017 20:54
-
-
Save JudeMolloy/c4abae4363b358bc2e37f2b3f4774369 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private mutating func performPendingBinaryOperation() { | |
if pbo != nil && accumulator != nil { | |
accumulator = pbo!.perform(with: accumulator!) | |
pbo = nil | |
} | |
} | |
private var pbo: PendingBinaryOperation? | |
private struct PendingBinaryOperation { | |
let function: (Double, Double) -> Double | |
let firstOperand: Double | |
func perform(with secondOperand: Double) -> Double { | |
return function(firstOperand, secondOperand) | |
} | |
} | |
mutating func setOperand(_ operand: Double) { | |
accumulator = operand | |
} | |
var result: Double? { | |
get { | |
return accumulator | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment