File tree 2 files changed +3
-5
lines changed
2 files changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import _fisheryates from '../kernel/_fisheryates.js';
2
2
import randint from './randint.js' ;
3
3
4
4
/**
5
- * Take a sample of size n (without repetitions ) from the items i through
5
+ * Take a sample of size n (without replacement ) from the items i through
6
6
* j-1 of the input array. This is done in-place. The sample can be retrieved
7
7
* from position i to i+n.
8
8
*
Original file line number Diff line number Diff line change 24
24
*/
25
25
const _fisheryates = ( randint ) => {
26
26
/**
27
- * Take a sample of size n (without repetitions ) from the items i through
27
+ * Take a sample of size n (without replacement ) from the items i through
28
28
* j-1 of the input array. This is done in-place. The sample can be
29
29
* retrieved from position i to i+n.
30
30
*
@@ -42,11 +42,9 @@ const _fisheryates = (randint) => {
42
42
43
43
for ( ; i < k ; ++ i ) {
44
44
// Choose any index p in the remaining array
45
-
46
45
const p = randint ( i , j ) ;
47
46
48
- // Swap element at index p with first element in the array
49
-
47
+ // Swap selected element with the first remaining element.
50
48
const tmp = a [ i ] ;
51
49
a [ i ] = a [ p ] ;
52
50
a [ p ] = tmp ;
You can’t perform that action at this time.
0 commit comments