Created
December 18, 2012 05:15
-
-
Save jahfer/4325251 to your computer and use it in GitHub Desktop.
Sometimes you need to look ahead or behind the current element you're on when iterating through an array. This is a neat trick for doing that quickly, without stepping outside the bounds of your array.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I come back to this gist once in a while. I now understand why you need
((this % n) + n) % n