Skip to content

Instantly share code, notes, and snippets.

@kateinoigakukun
Created September 15, 2019 07:50
Show Gist options
  • Save kateinoigakukun/faf6a952e97d7710f7ee8f4515d6cf21 to your computer and use it in GitHub Desktop.
Save kateinoigakukun/faf6a952e97d7710f7ee8f4515d6cf21 to your computer and use it in GitHub Desktop.
infix operator |: MultiplicationPrecedence
infix operator ∧: MultiplicationPrecedence
infix operator ∨: MultiplicationPrecedence
infix operator ⊃: MultiplicationPrecedence
prefix operator ¬
func |(lhs: Bool, rhs: Bool) -> Bool {
switch (lhs, rhs) {
case (true, true): return false
case (true, false): return true
case (false, true): return true
case (false, false): return true
}
}
prefix func ¬(value: Bool) -> Bool {
return value | value
}
func ∧(lhs: Bool, rhs: Bool) -> Bool {
return (lhs | rhs) | (lhs | rhs)
}
func ∨(lhs: Bool, rhs: Bool) -> Bool {
return (lhs | lhs) | (rhs | rhs)
}
func ⊃(lhs: Bool, rhs: Bool) -> Bool {
return lhs | (rhs|rhs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment