Skip to content

Instantly share code, notes, and snippets.

@gchriswill
Last active August 29, 2015 14:24

Revisions

  1. gchriswill revised this gist Jul 11, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion steppers
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    // 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
  2. gchriswill created this gist Jul 11, 2015.
    25 changes: 25 additions & 0 deletions steppers
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@

    // 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)

    }

    }