Created
August 25, 2015 19:12
-
-
Save Nadohs/30f4ec3cb9806223b6f4 to your computer and use it in GitHub Desktop.
range comparing...
This file contains hidden or 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
<>, both not included in range, | |
<=>, both included | |
<==, left not included, | |
==> right not included | |
infix operator <> {} | |
infix operator <=> {} | |
infix operator ==> {} | |
infix operator <== {} | |
func <=> <T:Comparable>(lhs:T,rhs:(T,T)) -> Bool{ | |
if lhs < rhs.0{ | |
return false | |
} | |
if lhs > rhs.1{ | |
return false | |
} | |
return true | |
} | |
func <> <T:Comparable>(lhs:T,rhs:(T,T)) -> Bool{ | |
if lhs <= rhs.0{ | |
return false | |
} | |
if lhs >= rhs.1{ | |
return false | |
} | |
return true | |
} | |
func ==> <T:Comparable>(lhs:T,rhs:(T,T)) -> Bool{ | |
if lhs < rhs.0{ | |
return false | |
} | |
if lhs >= rhs.1{ | |
return false | |
} | |
return true | |
} | |
func <== <T:Comparable>(lhs:T,rhs:(T,T)) -> Bool{ | |
if lhs <= rhs.0{ | |
return false | |
} | |
if lhs > rhs.1{ | |
return false | |
} | |
return true | |
} | |
let x = 5 | |
let res = 5 <> (3, 5) | |
let res1 = 5 <=> (3, 5) | |
let res1b = 5 ==> (3, 5) | |
let res1c = 5 <== (3, 5) | |
let res2 = 5 <> (5, 7) | |
let res3 = 5 <=> (5, 7) | |
let res3b = 5 ==> (5, 7) | |
let res3c = 5 <== (5, 7) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
least recently edited gist lol