Created
October 24, 2015 07:58
-
-
Save mzaks/12f5b8e90f06e5e4803f to your computer and use it in GitHub Desktop.
Initial implementation of boundaries operator in swift
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
| struct LowerBoundary<T : Comparable> { | |
| let ls : T | |
| let rs : T | |
| var part : T {return rs} | |
| var isTrue : Bool { return ls < rs } | |
| } | |
| infix operator <& { associativity left precedence 200 } | |
| func <& <Element: Comparable> (left: Element, right: Element) -> LowerBoundary<Element> { | |
| return LowerBoundary(ls: left, rs: right) | |
| } | |
| func < <T : Comparable>(left: LowerBoundary<T>, right: T) -> Bool { | |
| return left.isTrue && left.part < right | |
| } | |
| 12 <& 45 < 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment