File tree Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Expand file tree Collapse file tree 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';
22import randint from './randint.js' ;
33
44/**
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
66 * j-1 of the input array. This is done in-place. The sample can be retrieved
77 * from position i to i+n.
88 *
Original file line number Diff line number Diff line change 2424 */
2525const _fisheryates = ( randint ) => {
2626 /**
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
2828 * j-1 of the input array. This is done in-place. The sample can be
2929 * retrieved from position i to i+n.
3030 *
@@ -42,11 +42,9 @@ const _fisheryates = (randint) => {
4242
4343 for ( ; i < k ; ++ i ) {
4444 // Choose any index p in the remaining array
45-
4645 const p = randint ( i , j ) ;
4746
48- // Swap element at index p with first element in the array
49-
47+ // Swap selected element with the first remaining element.
5048 const tmp = a [ i ] ;
5149 a [ i ] = a [ p ] ;
5250 a [ p ] = tmp ;
You can’t perform that action at this time.
0 commit comments