on 4e2fd2c help sign in
2 files changed+1−20
since splitsnapshots
unifiedsplit
Truther/Operator.swift+1−1 Truther/Truther.swift−19
Truther/Operator.swift+1−1
@@ -44,7 +44,7 @@ enum Operator {
4444 case .f7:
4545 return {$0 || $1}
4646 case .f8:
47− return {!($0 || $1)}
47+ return {!($0 && $1)}
4848 case .f9:
4949 return {$0 == $1}
5050 case .f10:
Truther/Truther.swift−19
@@ -45,12 +45,6 @@ struct Formula {
4545 return startingLeft
4646 }
4747 var ns = s.trimmingCharacters(in: .whitespaces)
48− if ns == "0" {
49− return .constant(false)
50− }
51− if ns == "1" {
52− return .constant(true)
53− }
5448 if ns.trimmingCharacters(in: .whitespaces).reduce(true, {$0 && CharacterSet.letters.contains($1.unicodeScalars.first!)}) {
5549 vars.insert(String(s))
5650 return .variable(String(s))
@@ -65,16 +59,6 @@ struct Formula {
6559 print("Internal error: weird variable name first charecter \(ns.first!)")
6660 exit(1)
6761 }
68− switch ns.first! {
69− case "0":
70− ns = ns.dropFirst().trimmingCharacters(in: .whitespaces)
71− return "0"
72− case "1":
73− ns = ns.dropFirst().trimmingCharacters(in: .whitespaces)
74− return "1"
75− default:
76− break
77− }
7862 var i = ns.startIndex
7963 while i < ns.endIndex {
8064 if !CharacterSet.letters.contains(ns[i].unicodeScalars.first!) {
@@ -139,7 +123,6 @@ private func extractBrackets(from s: String) -> (wasInside: Substring, after: Su
139123private typealias Variable = String
140124private indirect enum FormulaElement {
141125 case variable(Variable)
142− case constant(Bool)
143126 case operation(FormulaElement, Operator, FormulaElement)
144127 func evaluate(with variables: [Variable: Bool]) -> Bool {
145128 switch self {
@@ -152,8 +135,6 @@ private indirect enum FormulaElement {
152135 }
153136 case .operation(let l, let op, let r):
154137 return op.value(l.evaluate(with: variables), r.evaluate(with: variables))
155− case .constant(let b):
156− return b
157138 }
158139 }
159140}