Skip to content

Commit 220f055

Browse files
authored
chore: replace manual for loop in examples
PR-URL: #6491 Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent a81d6c3 commit 220f055

File tree

12 files changed

+90
-100
lines changed

12 files changed

+90
-100
lines changed

lib/node_modules/@stdlib/math/base/special/rcbrtf/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,16 @@ v = rcbrtf( Infinity );
8686
<!-- eslint no-undef: "error" -->
8787

8888
```javascript
89-
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
89+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
90+
var logEachMap = require( '@stdlib/console/log-each-map' );
9091
var rcbrtf = require( '@stdlib/math/base/special/rcbrtf' );
9192

92-
var x;
93-
var i;
94-
for ( i = 0; i < 100; i++ ) {
95-
x = discreteUniform( 0.0, 100.0 );
96-
console.log( 'rcbrtf(%d) = %d', x, rcbrtf( x ) );
97-
}
93+
var opts = {
94+
'dtype': 'float32'
95+
};
96+
var x = discreteUniform( 100, 0, 100, opts );
97+
98+
logEachMap( 'rcbrtf(%d) = %0.4f', x, rcbrtf );
9899
```
99100

100101
</section>

lib/node_modules/@stdlib/math/base/special/rcbrtf/examples/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818

1919
'use strict';
2020

21-
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var rcbrtf = require( './../lib' );
2324

24-
var x;
25-
var i;
26-
for ( i = 0; i < 100; i++ ) {
27-
x = discreteUniform( 0.0, 100.0 );
28-
console.log( 'rcbrtf(%d) = %d', x, rcbrtf( x ) );
29-
}
25+
var opts = {
26+
'dtype': 'float32'
27+
};
28+
var x = discreteUniform( 100, 0, 100, opts );
29+
30+
logEachMap( 'rcbrtf(%d) = %0.4f', x, rcbrtf );

lib/node_modules/@stdlib/math/base/special/round/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ v = round( NaN );
9090
<!-- eslint no-undef: "error" -->
9191

9292
```javascript
93-
var randu = require( '@stdlib/random/base/randu' );
93+
var uniform = require( '@stdlib/random/array/uniform' );
94+
var logEachMap = require( '@stdlib/console/log-each-map' );
9495
var round = require( '@stdlib/math/base/special/round' );
9596

96-
var x;
97-
var i;
97+
var opts = {
98+
'dtype': 'float64'
99+
};
100+
var x = uniform( 100, -50.0, 50.0, opts );
98101

99-
for ( i = 0; i < 100; i++ ) {
100-
x = (randu()*100.0) - 50.0;
101-
console.log( 'Value: %d. Rounded: %d.', x, round( x ) );
102-
}
102+
logEachMap( 'Value: %0.4f. Rounded: %0.4f.', x, round );
103103
```
104104

105105
</section>

lib/node_modules/@stdlib/math/base/special/round/examples/index.js

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

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var round = require( './../lib' );
2324

24-
var x;
25-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = uniform( 100, -50.0, 50.0, opts );
2629

27-
for ( i = 0; i < 100; i++ ) {
28-
x = (randu()*100.0) - 50.0;
29-
console.log( 'Value: %d. Rounded: %d.', x, round( x ) );
30-
}
30+
logEachMap( 'Value: %0.4f. Rounded: %0.4f.', x, round );

lib/node_modules/@stdlib/math/base/special/round10/README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,16 @@ v = round10( NaN );
8383
<!-- eslint no-undef: "error" -->
8484

8585
```javascript
86-
var randu = require( '@stdlib/random/base/randu' );
86+
var uniform = require( '@stdlib/random/array/uniform' );
87+
var logEachMap = require( '@stdlib/console/log-each-map' );
8788
var round10 = require( '@stdlib/math/base/special/round10' );
8889

89-
var x;
90-
var v;
91-
var i;
90+
var opts = {
91+
'dtype': 'float64'
92+
};
93+
var x = uniform( 100, -50.0, 50.0, opts );
9294

93-
for ( i = 0; i < 100; i++ ) {
94-
x = (randu()*100.0) - 50.0;
95-
v = round10( x );
96-
console.log( 'Value: %d. Rounded: %d.', x, v );
97-
}
95+
logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, round10 );
9896
```
9997

10098
</section>

lib/node_modules/@stdlib/math/base/special/round10/examples/index.js

Lines changed: 7 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' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var round10 = require( './../lib' );
2324

24-
var x;
25-
var v;
26-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = uniform( 100, -50.0, 50.0, opts );
2729

28-
for ( i = 0; i < 100; i++ ) {
29-
x = (randu()*100.0) - 50.0;
30-
v = round10( x );
31-
console.log( 'x: %d. Rounded: %d.', x, v );
32-
}
30+
logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, round10 );

lib/node_modules/@stdlib/math/base/special/round2/README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,16 @@ v = round2( NaN );
8383
<!-- eslint no-undef: "error" -->
8484

8585
```javascript
86-
var randu = require( '@stdlib/random/base/randu' );
86+
var uniform = require( '@stdlib/random/array/uniform' );
87+
var logEachMap = require( '@stdlib/console/log-each-map' );
8788
var round2 = require( '@stdlib/math/base/special/round2' );
8889

89-
var x;
90-
var v;
91-
var i;
90+
var opts = {
91+
'dtype': 'float64'
92+
};
93+
var x = uniform( 100, -50.0, 50.0, opts );
9294

93-
for ( i = 0; i < 100; i++ ) {
94-
x = (randu()*100.0) - 50.0;
95-
v = round2( x );
96-
console.log( 'Value: %d. Rounded: %d.', x, v );
97-
}
95+
logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, round2 );
9896
```
9997

10098
</section>

lib/node_modules/@stdlib/math/base/special/round2/examples/index.js

Lines changed: 7 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' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var round2 = require( './../lib' );
2324

24-
var x;
25-
var v;
26-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = uniform( 100, -50.0, 50.0, opts );
2729

28-
for ( i = 0; i < 100; i++ ) {
29-
x = (randu()*100.0) - 50.0;
30-
v = round2( x );
31-
console.log( 'x: %d. Rounded: %d.', x, v );
32-
}
30+
logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, round2 );

lib/node_modules/@stdlib/math/base/special/roundf/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ v = roundf( NaN );
9090
<!-- eslint no-undef: "error" -->
9191

9292
```javascript
93-
var randu = require( '@stdlib/random/base/randu' );
93+
var uniform = require( '@stdlib/random/array/uniform' );
94+
var logEachMap = require( '@stdlib/console/log-each-map' );
9495
var roundf = require( '@stdlib/math/base/special/roundf' );
9596

96-
var x;
97-
var i;
97+
var opts = {
98+
'dtype': 'float32'
99+
};
100+
var x = uniform( 100, -50.0, 50.0, opts );
98101

99-
for ( i = 0; i < 100; i++ ) {
100-
x = ( randu() * 100.0 ) - 50.0;
101-
console.log( 'Value: %d. Rounded: %d.', x, roundf( x ) );
102-
}
102+
logEachMap( 'Value: %0.4f. Rounded: %0.4f.', x, roundf );
103103
```
104104

105105
</section>

lib/node_modules/@stdlib/math/base/special/roundf/examples/index.js

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

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
21+
var uniform = require( '@stdlib/random/array/uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2223
var roundf = require( './../lib' );
2324

24-
var x;
25-
var i;
25+
var opts = {
26+
'dtype': 'float32'
27+
};
28+
var x = uniform( 100, -50.0, 50.0, opts );
2629

27-
for ( i = 0; i < 100; i++ ) {
28-
x = ( randu() * 100.0) - 50.0;
29-
console.log( 'Value: %d. Rounded: %d.', x, roundf( x ) );
30-
}
30+
logEachMap( 'Value: %0.4f. Rounded: %0.4f.', x, roundf );

0 commit comments

Comments
 (0)