Last active
April 20, 2016 21:57
-
-
Save erica/5afb13c72ec372a09042bb29dbbd77a3 to your computer and use it in GitHub Desktop.
Revisions
-
erica revised this gist
Apr 20, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -40,8 +40,8 @@ prefix operator +++ {} prefix public func +++<T: IntegerArithmeticType>(inout x: T) -> T { x += x/x; return x } // CGFloat versions apparently need separate implementations //prefix public func +++(inout x: CGFloat) -> CGFloat { defer { x += 1 }; return x } //prefix public func +++(inout x: CGFloat) -> CGFloat { x += 1; return x } // via "torquato" -
erica revised this gist
Apr 20, 2016 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,3 +43,14 @@ prefix public func +++<T: IntegerArithmeticType>(inout x: T) -> T { x += x/x; re //prefix public func +++<T: IntegerArithmeticType>(inout x: CGFloat) -> CGFloat { defer { x += 1 }; return x } //prefix public func +++<T: IntegerArithmeticType>(inout x: CGFloat) -> CGFloat { x += 1; return x } // via "torquato" postfix operator ++++ {} postfix public func ++++<T: BidirectionalIndexType>(inout x: T) -> T { defer { x = x.successor() }; return x } prefix operator ++++ {} prefix public func ++++<T: BidirectionalIndexType>(inout x: T) -> T { x = x.successor(); return x } postfix operator ---- {} postfix public func ----<T: BidirectionalIndexType>(inout x: T) -> T { defer { x = x.predecessor() }; return x } prefix operator ---- {} prefix public func ----<T: BidirectionalIndexType>(inout x: T) -> T { x = x.predecessor(); return x } -
erica revised this gist
Apr 20, 2016 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -30,3 +30,16 @@ postfix operator -- {} postfix public func --(inout x: Int) -> Int { defer {x -= 1}; return x } // @discardableResult postfix public func --(inout x: UInt) -> UInt { defer {x -= 1}; return x } // Alternatively, deriving 1 // via Pilipenko Dima http://github.com/dimpiax postfix operator +++ {} postfix public func +++<T: IntegerArithmeticType>(inout x: T) -> T { defer { x += x/x }; return x } prefix operator +++ {} prefix public func +++<T: IntegerArithmeticType>(inout x: T) -> T { x += x/x; return x } // CGFloat versions apparently need separate implementations //prefix public func +++<T: IntegerArithmeticType>(inout x: CGFloat) -> CGFloat { defer { x += 1 }; return x } //prefix public func +++<T: IntegerArithmeticType>(inout x: CGFloat) -> CGFloat { x += 1; return x } -
erica revised this gist
Apr 20, 2016 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,3 +17,16 @@ postfix operator ++ {} postfix public func ++(inout x: Int) -> Int { defer {x += 1}; return x } // @discardableResult postfix public func ++(inout x: UInt) -> UInt { defer {x += 1}; return x } prefix operator -- {} // @discardableResult prefix public func --(inout x: Int) -> Int { x -= 1; return x } // @discardableResult prefix public func --(inout x: UInt) -> UInt { x -= 1; return x } postfix operator -- {} // @discardableResult postfix public func --(inout x: Int) -> Int { defer {x -= 1}; return x } // @discardableResult postfix public func --(inout x: UInt) -> UInt { defer {x -= 1}; return x } -
erica revised this gist
Apr 20, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,9 +7,9 @@ prefix operator ++ {} // @discardableResult prefix public func ++(inout x: Int) -> Int { x += 1; return x } // @discardableResult prefix public func ++(inout x: UInt) -> UInt { x += 1; return x } postfix operator ++ {} -
erica revised this gist
Apr 20, 2016 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,10 @@ /* ericasadun.com Sometimes letting go doesn't mean saying goodbye */ prefix operator ++ {} // @discardableResult prefix public func ++(inout x: Int) -> Int { x = x + 1; return x } -
erica revised this gist
Apr 20, 2016 . 1 changed file with 2 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,3 @@ prefix operator ++ {} // @discardableResult prefix public func ++(inout x: Int) -> Int { x = x + 1; return x } @@ -14,6 +7,6 @@ prefix public func ++(inout x: UInt) -> UInt { x = x + 1; return x } postfix operator ++ {} // @discardableResult postfix public func ++(inout x: Int) -> Int { defer {x += 1}; return x } // @discardableResult postfix public func ++(inout x: UInt) -> UInt { defer {x += 1}; return x } -
erica created this gist
Apr 19, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ /* ericasadun.com Sometimes letting go doesn't mean saying goodbye */ prefix operator ++ {} // @discardableResult prefix public func ++(inout x: Int) -> Int { x = x + 1; return x } // @discardableResult prefix public func ++(inout x: UInt) -> UInt { x = x + 1; return x } postfix operator ++ {} // @discardableResult postfix public func ++(inout x: Int) -> Int { x = x + 1; return x - 1 } // @discardableResult postfix public func ++(inout x: UInt) -> UInt { x = x + 1; return x - 1 }