Skip to content

Commit eb0c8c9

Browse files
authored
docs: replace manual for loop in examples
PR-URL: #6468 Reviewed-by: Athan Reines <[email protected]>
1 parent ef5a939 commit eb0c8c9

File tree

4 files changed

+28
-32
lines changed

4 files changed

+28
-32
lines changed

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

+7-8
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,16 @@ v = inv( NaN );
8383
<!-- eslint no-undef: "error" -->
8484

8585
```javascript
86-
var randu = require( '@stdlib/random/base/randu' );
87-
var round = require( '@stdlib/math/base/special/round' );
86+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
87+
var logEachMap = require( '@stdlib/console/log-each-map' );
8888
var inv = require( '@stdlib/math/base/special/inv' );
8989

90-
var x;
91-
var i;
90+
var opts = {
91+
'dtype': 'float64'
92+
};
93+
var x = discreteUniform( 100, -50, 50, opts );
9294

93-
for ( i = 0; i < 100; i++ ) {
94-
x = round( randu()*100.0 ) - 50.0;
95-
console.log( 'inv(%d) = %d', x, inv( x ) );
96-
}
95+
logEachMap( 'inv(%0.4f) = %0.4f', x, inv );
9796
```
9897

9998
</section>

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

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var round = require( '@stdlib/math/base/special/round' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2323
var inv = require( './../lib' );
2424

25-
var x;
26-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = discreteUniform( 100, -50, 50, opts );
2729

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

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

+7-8
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,16 @@ v = invf( NaN );
8383
<!-- eslint no-undef: "error" -->
8484

8585
```javascript
86-
var randu = require( '@stdlib/random/base/randu' );
87-
var round = require( '@stdlib/math/base/special/round' );
86+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
87+
var logEachMap = require( '@stdlib/console/log-each-map' );
8888
var invf = require( '@stdlib/math/base/special/invf' );
8989

90-
var x;
91-
var i;
90+
var opts = {
91+
'dtype': 'float32'
92+
};
93+
var x = discreteUniform( 100, -50, 50, opts );
9294

93-
for ( i = 0; i < 100; i++ ) {
94-
x = round( randu()*100.0 ) - 50.0;
95-
console.log( 'invf(%d) = %d', x, invf( x ) );
96-
}
95+
logEachMap( 'invf(%0.4f) = %0.4f', x, invf );
9796
```
9897

9998
</section>

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

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var round = require( '@stdlib/math/base/special/round' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2323
var invf = require( './../lib' );
2424

25-
var x;
26-
var i;
25+
var opts = {
26+
'dtype': 'float32'
27+
};
28+
var x = discreteUniform( 100, -50, 50, opts );
2729

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

0 commit comments

Comments
 (0)