Skip to content

Commit da4436d

Browse files
authored
docs: replace manual for loop in examples
PR-URL: #6689 Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent 2aadeb5 commit da4436d

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

lib/node_modules/@stdlib/math/base/assert/is-probability/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ bool = isProbability( NaN );
5757

5858
```javascript
5959
var uniform = require( '@stdlib/random/array/uniform' );
60+
var logEachMap = require( '@stdlib/console/log-each-map' );
6061
var isProbability = require( '@stdlib/math/base/assert/is-probability' );
6162

62-
var x = uniform( 100, -1.0, 1.0 );
63+
var opts = {
64+
'dtype': 'float64'
65+
};
66+
var x = uniform( 100, -1.0, 1.0, opts );
6367

64-
var i;
65-
for ( i = 0; i < x.length; i++ ) {
66-
console.log( '%d is %s', x[ i ], ( isProbability( x[ i ] ) ) ? 'a probability' : 'not a probability' );
68+
function isProbabilityWrapper( integer ) {
69+
return ( isProbability( integer ) ) ? 'a probability' : 'not a probability';
6770
}
71+
logEachMap( '%0.4f is %s', x, isProbabilityWrapper );
6872
```
6973

7074
</section>

lib/node_modules/@stdlib/math/base/assert/is-probability/examples/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@
1919
'use strict';
2020

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

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

26-
var i;
27-
for ( i = 0; i < x.length; i++ ) {
28-
console.log( '%d is %s', x[ i ], ( isProbability( x[ i ] ) ) ? 'a probability' : 'not a probability' );
30+
function isProbabilityWrapper( integer ) {
31+
return ( isProbability( integer ) ) ? 'a probability' : 'not a probability';
2932
}
33+
logEachMap( '%0.4f is %s', x, isProbabilityWrapper );

lib/node_modules/@stdlib/math/base/assert/is-probabilityf/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,18 @@ bool = isProbabilityf( NaN );
5757

5858
```javascript
5959
var uniform = require( '@stdlib/random/array/uniform' );
60+
var logEachMap = require( '@stdlib/console/log-each-map' );
6061
var isProbabilityf = require( '@stdlib/math/base/assert/is-probabilityf' );
6162

62-
var x = uniform( 100, -1.0, 1.0, {
63+
var opts = {
6364
'dtype': 'float32'
64-
});
65+
};
66+
var x = uniform( 100, -1.0, 1.0, opts );
6567

66-
var i;
67-
for ( i = 0; i < 100; i++ ) {
68-
console.log( '%d is %s', x[ i ], ( isProbabilityf( x[ i ] ) ) ? 'a probability' : 'not a probability' );
68+
function isProbabilityfWrapper( integer ) {
69+
return ( isProbabilityf( integer ) ) ? 'a probability' : 'not a probability';
6970
}
71+
logEachMap( '%0.4f is %s', x, isProbabilityfWrapper );
7072
```
7173

7274
</section>

lib/node_modules/@stdlib/math/base/assert/is-probabilityf/examples/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
'use strict';
2020

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

24-
var x = uniform( 100, -1.0, 1.0, {
25+
var opts = {
2526
'dtype': 'float32'
26-
});
27+
};
28+
var x = uniform( 100, -1.0, 1.0, opts );
2729

28-
var i;
29-
for ( i = 0; i < 100; i++ ) {
30-
console.log( '%d is %s', x[ i ], ( isProbabilityf( x[ i ] ) ) ? 'a probability' : 'not a probability' );
30+
function isProbabilityfWrapper( integer ) {
31+
return ( isProbabilityf( integer ) ) ? 'a probability' : 'not a probability';
3132
}
33+
logEachMap( '%0.4f is %s', x, isProbabilityfWrapper );

0 commit comments

Comments
 (0)