-
-
Save ml242/832aca34a096eee3f0ed to your computer and use it in GitHub Desktop.
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
# Adapted from the javascript implementation at http://sedition.com/perl/javascript-fy.html | |
# Randomizes the order of elements in the passed in array in place. | |
fisherYates = (arr) -> | |
i = arr.length; | |
if i == 0 then return false | |
while --i | |
j = Math.floor(Math.random() * (i+1)) | |
tempi = arr[i] | |
tempj = arr[j] | |
arr[i] = tempj | |
arr[j] = tempi | |
return arr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment