Last active
August 29, 2015 14:24
-
-
Save gchriswill/f273a09cc98726dc651f to your computer and use it in GitHub Desktop.
Extends Swift's Array structure by providing stepping functionality recursively using an external variable.
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
// Created on 6/2/15 by Christopher Gonzalez D.K.A. @gchriswill https://github.com/JWShroyer | |
// Reviewed and optimyzed by Josh Shroyer D.K.A @JWShroyer https://github.com/JWShroyer | |
// Last revision on 7/11/15 by @gchriswill and @JWShroyer | |
extension Array { | |
mutating func countForward(inout counter c: Int) -> Void { | |
var s = self.count - 1 | |
c = c < s && !(0 > c) ? (c + 1) : 0 | |
} | |
mutating func countBackward(inout counter c: Int) -> Void { | |
var s = self.count - 1 | |
c = 0 >= c || c > s ? s : (c - 1) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@JWShroyer, Here is the gist.
The protocol version will be uploaded through a separate file in this repository... 👾