Skip to content

Commit 0395909

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

File tree

10 files changed

+70
-70
lines changed

10 files changed

+70
-70
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,16 @@ v = heaviside( 0.0, 'right-continuous' );
148148
<!-- eslint no-undef: "error" -->
149149

150150
```javascript
151-
var linspace = require( '@stdlib/array/base/linspace' );
151+
var uniform = require( '@stdlib/random/array/uniform' );
152+
var logEachMap = require( '@stdlib/console/log-each-map' );
152153
var heaviside = require( '@stdlib/math/base/special/heaviside' );
153154

154-
var x = linspace( -10.0, 10.0, 101 );
155+
var opts = {
156+
'dtype': 'float64'
157+
};
158+
var x = uniform( 101, -10.0, 10.0, opts );
155159

156-
var i;
157-
for ( i = 0; i < x.length; i++ ) {
158-
console.log( 'H(%d) = %d', x[ i ], heaviside( x[ i ] ) );
159-
}
160+
logEachMap( 'H(%0.4f) = %0.4f', x, heaviside );
160161
```
161162

162163
</section>

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

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

1919
'use strict';
2020

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

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

26-
var i;
27-
for ( i = 0; i < x.length; i++ ) {
28-
console.log( 'H(%d) = %d', x[ i ], heaviside( x[ i ] ) );
29-
}
30+
logEachMap( 'H(%0.4f) = %0.4f', x, heaviside );

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,16 @@ v = heavisidef( 0.0, 'right-continuous' );
148148
<!-- eslint no-undef: "error" -->
149149

150150
```javascript
151-
var linspace = require( '@stdlib/array/base/linspace' );
151+
var uniform = require( '@stdlib/random/array/uniform' );
152+
var logEachMap = require( '@stdlib/console/log-each-map' );
152153
var heavisidef = require( '@stdlib/math/base/special/heavisidef' );
153154

154-
var x = linspace( -10.0, 10.0, 101 );
155+
var opts = {
156+
'dtype': 'float32'
157+
};
158+
var x = uniform( 101, -10.0, 10.0, opts );
155159

156-
var i;
157-
for ( i = 0; i < x.length; i++ ) {
158-
console.log( 'H(%d) = %f', x[ i ], heavisidef( x[ i ] ) );
159-
}
160+
logEachMap( 'H(%0.4f) = %0.4f', x, heavisidef );
160161
```
161162

162163
</section>

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

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

1919
'use strict';
2020

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

24-
var x = linspace( -10.0, 10.0, 101 );
25+
var opts = {
26+
'dtype': 'float32'
27+
};
28+
var x = uniform( 101, -10.0, 10.0, opts );
2529

26-
var i;
27-
for ( i = 0; i < x.length; i++ ) {
28-
console.log( 'H(%d) = %f', x[ i ], heavisidef( x[ i ] ) );
29-
}
30+
logEachMap( 'H(%0.4f) = %0.4f', x, heavisidef );

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,19 @@ v = hyp2f1( NaN, 3.0, 2.0, 0.5 );
9999
<!-- eslint no-undef: "error" -->
100100

101101
```javascript
102-
var linspace = require( '@stdlib/array/base/linspace' );
102+
var uniform = require( '@stdlib/random/array/uniform' );
103+
var logEachMap = require( '@stdlib/console/log-each-map' );
103104
var hyp2f1 = require( '@stdlib/math/base/special/hyp2f1' );
104105

105-
var a = linspace( -50.0, 50.0, 100 );
106-
var b = linspace( -50.0, 50.0, 100 );
107-
var c = linspace( -50.0, 50.0, 100 );
108-
var x = linspace( -50.0, 50.0, 100 );
106+
var opts = {
107+
'dtype': 'float64'
108+
};
109+
var a = uniform( 100, -50.0, 50.0, opts );
110+
var b = uniform( 100, -50.0, 50.0, opts );
111+
var c = uniform( 100, -50.0, 50.0, opts );
112+
var x = uniform( 100, -50.0, 50.0, opts );
109113

110-
var i;
111-
for ( i = 0; i < x.length; i++ ) {
112-
console.log( 'a: %d, b: %d, c: %d, x: %d, 2F1(a,b;c;x): %d', a[ i ], b[ i ], c[ i ], x[ i ], hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] ) );
113-
}
114+
logEachMap( 'a: %0.4f, b: %0.4f, c: %0.4f, x: %0.4f, 2F1(a,b;c;x): %0.4f', a, b, c, x, hyp2f1 );
114115
```
115116

116117
</section>

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

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

1919
'use strict';
2020

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

24-
var a = linspace( -50.0, 50.0, 100 );
25-
var b = linspace( -50.0, 50.0, 100 );
26-
var c = linspace( -50.0, 50.0, 100 );
27-
var x = linspace( -50.0, 50.0, 100 );
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var a = uniform( 100, -50.0, 50.0, opts );
29+
var b = uniform( 100, -50.0, 50.0, opts );
30+
var c = uniform( 100, -50.0, 50.0, opts );
31+
var x = uniform( 100, -50.0, 50.0, opts );
2832

29-
var i;
30-
for ( i = 0; i < x.length; i++ ) {
31-
console.log( 'a: %d, b: %d, c: %d, x: %d, 2F1(a,b;c;x): %d', a[ i ], b[ i ], c[ i ], x[ i ], hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] ) );
32-
}
33+
logEachMap( 'a: %0.4f, b: %0.4f, c: %0.4f, x: %0.4f, 2F1(a,b;c;x): %0.4f', a, b, c, x, hyp2f1 );

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ h = hypot( 5.0, NaN );
120120

121121
```javascript
122122
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
123+
var logEachMap = require( '@stdlib/console/log-each-map' );
123124
var hypot = require( '@stdlib/math/base/special/hypot' );
124125
125-
var len = 100;
126-
var x = discreteUniform( len, -50, 50 );
127-
var y = discreteUniform( len, -50, 50 );
126+
var opts = {
127+
'dtype': 'float64'
128+
};
129+
var x = discreteUniform( 100, -50, 50, opts );
130+
var y = discreteUniform( 100, -50, 50, opts );
128131
129-
var i;
130-
for ( i = 0; i < len; i++ ) {
131-
console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], hypot( x[ i ], y[ i ] ) );
132-
}
132+
logEachMap( 'h(%d,%d) = %0.4f', x, y, hypot );
133133
```
134134

135135
</section>

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

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

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

24-
var len = 100;
25-
var x = discreteUniform( len, -50, 50 );
26-
var y = discreteUniform( len, -50, 50 );
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = discreteUniform( 100, -50, 50, opts );
29+
var y = discreteUniform( 100, -50, 50, opts );
2730

28-
var i;
29-
for ( i = 0; i < len; i++ ) {
30-
console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], hypot( x[ i ], y[ i ] ) );
31-
}
31+
logEachMap( 'h(%d,%d) = %0.4f', x, y, hypot );

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,16 @@ h = hypotf( 5.0, NaN );
8484

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

89-
var len = 100;
9090
var opts = {
9191
'dtype': 'float32'
9292
};
93-
var x = discreteUniform( len, -50, 50, opts );
94-
var y = discreteUniform( len, -50, 50, opts );
93+
var x = discreteUniform( 100, -50, 50, opts );
94+
var y = discreteUniform( 100, -50, 50, opts );
9595

96-
var i;
97-
for ( i = 0; i < len; i++ ) {
98-
console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], hypotf( x[ i ], y[ i ] ) );
99-
}
96+
logEachMap( 'h(%d,%d) = %0.4f', x, y, hypotf );
10097
```
10198

10299
</section>

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

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

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

24-
var len = 100;
2525
var opts = {
2626
'dtype': 'float32'
2727
};
28-
var x = discreteUniform( len, -50, 50, opts );
29-
var y = discreteUniform( len, -50, 50, opts );
28+
var x = discreteUniform( 100, -50, 50, opts );
29+
var y = discreteUniform( 100, -50, 50, opts );
3030

31-
var i;
32-
for ( i = 0; i < len; i++ ) {
33-
console.log( 'h(%d,%d) = %d', x[ i ], y[ i ], hypotf( x[ i ], y[ i ] ) );
34-
}
31+
logEachMap( 'h(%d,%d) = %0.4f', x, y, hypotf );

0 commit comments

Comments
 (0)