Skip to content

Commit cd31c76

Browse files
📚 docs(sample/_fisheryates): Improve wording.
1 parent 8c8aa0b commit cd31c76

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/api/sample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import _fisheryates from '../kernel/_fisheryates.js';
22
import 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
*

src/kernel/_fisheryates.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
const _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;

0 commit comments

Comments
 (0)