User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
algorithm:fisher-yates_shuffle [2014/05/04 16:25]
127.0.0.1 external edit
algorithm:fisher-yates_shuffle [2015/02/02 08:28] (current)
Line 1: Line 1:
-[algorithm ​Fisher-Yates shuffle]+======= λ Fisher-Yates shuffle ​======
  
-====== Algorithm ======+<​nowiki>​ 
 +======= Algorithm ​=======
 <syntax js> <syntax js>
 function shuffle(a) { function shuffle(a) {
Line 13: Line 14:
 </​syntax>​ </​syntax>​
  
-====== Support ======+======= Support ​=======
 <syntax js> <syntax js>
 function swap(a, i, j) { function swap(a, i, j) {
Line 23: Line 24:
 </​syntax>​ </​syntax>​
  
-====== Options ======+======= Tests ======= 
 +<syntax js> 
 +</​syntax>​ 
 + 
 +======= Options ​=======
 <syntax js> <syntax js>
 { {
 +    "​title":"​Fisher-Yates shuffle",​
     "​height":"​270px"​     "​height":"​270px"​
 } }
 </​syntax>​ </​syntax>​
  
-====== Visualisation ======+======= Visualisation ​=======
 <syntax html> <syntax html>
 <​html>​ <​html>​
Line 72: Line 78:
 } }
  
-function args() { +function args(forCloning) { 
-    return a;+    ​if (forCloning) { 
 +        var a2 = []; 
 +        for (var i=0, c=a.length; i<c; i++) { 
 +            a2.push(a[i].data);​ 
 +        } 
 +        return a2; 
 +    } 
 +    else { 
 +        ​return a; 
 +    }
 } }
  
Line 111: Line 126:
 </​html>​ </​html>​
 </​syntax>​ </​syntax>​
 +</​nowiki>​
algorithm/fisher-yates_shuffle.1399245925.txt.gz · Last modified: 2015/02/02 08:23 (external edit)