mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-26 18:48:43 +02:00
Update CalculatorBrain.swift
Added an "AC" function, as well as a modulus ("%") function - in the calculator.swift I changed the layout as well, not sure if it was really wanted but got bored
This commit is contained in:
@@ -33,7 +33,9 @@ struct CalculatorBrain {
|
|||||||
"÷" : Operation.binary({ $0 / $1 }),
|
"÷" : Operation.binary({ $0 / $1 }),
|
||||||
"+" : Operation.binary({ $0 + $1 }),
|
"+" : Operation.binary({ $0 + $1 }),
|
||||||
"−" : Operation.binary({ $0 - $1 }),
|
"−" : Operation.binary({ $0 - $1 }),
|
||||||
"=" : Operation.equals
|
"=" : Operation.equals,
|
||||||
|
"%" : Operation.binary({$0.truncatingRemainder(dividingBy: $1)}),
|
||||||
|
"AC" : Operation.constant(0)
|
||||||
]
|
]
|
||||||
|
|
||||||
mutating func performOperation(_ symbol: String) {
|
mutating func performOperation(_ symbol: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user