Skip to content

Commit 9687965

Browse files
authored
chore: address commit comments for commit 8b01d81
PR-URL: #10433 Closes: #10423 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
1 parent a545808 commit 9687965

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

lib/node_modules/@stdlib/utils/tabulate-by/README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,13 @@ The returned frequency table is an `array` of `arrays`. Each sub-array correspon
127127
<!-- eslint no-undef: "error" -->
128128

129129
```javascript
130-
var randu = require( '@stdlib/random/base/randu' );
131-
var floor = require( '@stdlib/math/base/special/floor' );
130+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
131+
var take = require( '@stdlib/array/take' );
132132
var tabulateBy = require( '@stdlib/utils/tabulate-by' );
133133

134134
var vals;
135135
var arr;
136136
var out;
137-
var i;
138-
var j;
139137

140138
function indicator( value ) {
141139
return value[ 0 ];
@@ -144,11 +142,7 @@ function indicator( value ) {
144142
vals = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ];
145143

146144
// Generate a random collection...
147-
arr = [];
148-
for ( i = 0; i < 100; i++ ) {
149-
j = floor( randu()*vals.length );
150-
arr.push( vals[ j ] );
151-
}
145+
arr = take( vals, discreteUniform( 100, 0, vals.length - 1 ) );
152146

153147
// Generate a frequency table:
154148
out = tabulateBy( arr, indicator );

lib/node_modules/@stdlib/utils/tabulate-by/examples/index.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var floor = require( '@stdlib/math/base/special/floor' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var take = require( '@stdlib/array/take' );
2323
var tabulateBy = require( './../lib' );
2424

2525
var vals;
2626
var arr;
2727
var out;
28-
var i;
29-
var j;
3028

3129
function indicator( value ) {
3230
return value[ 0 ];
@@ -35,11 +33,7 @@ function indicator( value ) {
3533
vals = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ];
3634

3735
// Generate a random collection...
38-
arr = [];
39-
for ( i = 0; i < 100; i++ ) {
40-
j = floor( randu()*vals.length );
41-
arr.push( vals[ j ] );
42-
}
36+
arr = take( vals, discreteUniform( 100, 0, vals.length - 1 ) );
4337

4438
// Generate a frequency table:
4539
out = tabulateBy( arr, indicator );

0 commit comments

Comments
 (0)