Download code/test/JavaScript/0052687_permute.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 400 Bytes
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/test/JavaScript/0052687_permute.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/code/test/JavaScript/0052687_permute.js
-
curl -L -o 0052687_permute.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/test/JavaScript/0052687_permute.js
400 Bytes
| var assert = require('assert'); | |
| //randomly permutate a given set in place | |
| //REFERENCE http://en.wikipedia.org/wiki/Knuth_shuffle | |
| function fisher_yates_permute(arr) { | |
| assert(arr instanceof Array); | |
| var tmp; | |
| for (var i = arr.length - 1; i >= 1; i--) { | |
| var j = Math.round(Math.random() * i); | |
| tmp = arr[j]; | |
| arr[j] = arr[i]; | |
| arr[i] = tmp; | |
| } | |
| }; | |
| module.exports = exports = fisher_yates_permute; |