Created
May 13, 2015 15:47
-
-
Save dbrockman/88e4e3258eed0617be7d to your computer and use it in GitHub Desktop.
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
function modulo(a, b) { | |
var r = a % b; | |
return (r * b < 0) ? r + b : r; | |
} | |
function nthArrayItem(array, n) { | |
return array[modulo(n, array.length)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment