Last active
January 31, 2017 22:13
-
-
Save vinivendra/4ce5b8b502ec57b2ce3c 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
precedencegroup ComparisonChainPrecedence { | |
higherThan: ComparisonPrecedence | |
associativity: right | |
} | |
// | |
infix operator ≤: ComparisonChainPrecedence | |
func ≤ (left: Int, right: Int) -> Int { | |
if left < right { | |
return left | |
} else { | |
return Int.min | |
} | |
} | |
// | |
infix operator ≤=: ComparisonChainPrecedence | |
func ≤= (left: Int, right: Int) -> Int { | |
if left <= right { | |
return left | |
} else { | |
return Int.min | |
} | |
} | |
// | |
infix operator ≥: ComparisonChainPrecedence | |
func ≥ (left: Int, right: Int) -> Int { | |
if left > right { | |
return left | |
} else { | |
return Int.max | |
} | |
} | |
// | |
infix operator ≥=: ComparisonChainPrecedence | |
func ≥= (left: Int, right: Int) -> Int { | |
if left >= right { | |
return left | |
} else { | |
return Int.max | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment