Skip to content

Commit 75cbf89

Browse files
hrshyastdlib-bot
andauthored
chore: replace manual for loop in examples
PR-URL: #6308 Co-authored-by: stdlib-bot <[email protected]> Reviewed-by: Athan Reines <[email protected]> Reviewed-by: Karan Anand <[email protected]> Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent 442efb4 commit 75cbf89

File tree

16 files changed

+130
-146
lines changed

16 files changed

+130
-146
lines changed

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

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

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

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

92-
for ( i = 0; i < 100; i++ ) {
93-
x = randu() * 10.0;
94-
console.log( 'j0(%d) = %d', x, j0( x ) );
95-
}
95+
logEachMap( 'besselj0(%0.4f) = %0.4f', x, besselj0 );
9696
```
9797

9898
</section>

lib/node_modules/@stdlib/math/base/special/besselj0/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 besselj0 = require( './../lib' );
2324

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

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

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

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

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

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

92-
for ( i = 0; i < 100; i++ ) {
93-
x = randu() * 10.0;
94-
console.log( 'j1(%d) = %d', x, j1( x ) );
95-
}
95+
logEachMap( 'besselj1(%0.4f) = %0.4f', x, besselj1 );
9696
```
9797

9898
</section>

lib/node_modules/@stdlib/math/base/special/besselj1/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 besselj1 = require( './../lib' );
2324

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

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

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

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

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

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

99-
for ( i = 0; i < 100; i++ ) {
100-
x = randu() * 10.0;
101-
console.log( 'y0(%d) = %d', x, y0( x ) );
102-
}
102+
logEachMap( 'bessely0(%0.4f) = %0.4f', x, bessely0 );
103103
```
104104

105105
</section>

lib/node_modules/@stdlib/math/base/special/bessely0/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 bessely0 = require( './../lib' );
2324

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

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

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ v = y1( NaN );
9191
<!-- eslint no-undef: "error" -->
9292

9393
```javascript
94-
var randu = require( '@stdlib/random/base/randu' );
95-
var y1 = require( '@stdlib/math/base/special/bessely1' );
94+
var uniform = require( '@stdlib/random/array/uniform' );
95+
var logEachMap = require( '@stdlib/console/log-each-map' );
96+
var bessely1 = require( '@stdlib/math/base/special/bessely1' );
9697

97-
var x;
98-
var i;
98+
var opts = {
99+
'dtype': 'float64'
100+
};
101+
var x = uniform( 100, 0.0, 100.0, opts );
99102

100-
for ( i = 0; i < 100; i++ ) {
101-
x = randu() * 10.0;
102-
console.log( 'y1(%d) = %d', x, y1( x ) );
103-
}
103+
logEachMap( 'bessely1(%0.4f) = %0.4f', x, bessely1 );
104104
```
105105

106106
</section>

lib/node_modules/@stdlib/math/base/special/bessely1/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 bessely1 = require( './../lib' );
2324

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

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

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,18 @@ var y = betainc( 0.5, 2.0, -2.0 );
102102
<!-- eslint no-undef: "error" -->
103103

104104
```javascript
105-
var randu = require( '@stdlib/random/base/randu' );
105+
var uniform = require( '@stdlib/random/array/uniform' );
106+
var logEachMap = require( '@stdlib/console/log-each-map' );
106107
var betainc = require( '@stdlib/math/base/special/betainc' );
107108

108-
var i;
109-
var x;
110-
var a;
111-
var b;
112-
113-
for ( i = 0; i < 100; i++ ) {
114-
x = randu();
115-
a = randu() * 10.0;
116-
b = randu() * 10.0;
117-
console.log( 'x: %d, \t a: %d, \t b: %d, \t f(x,a,b): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), betainc( x, a, b ).toFixed( 4 ) );
118-
}
109+
var opts = {
110+
'dtype': 'float64'
111+
};
112+
var x = uniform( 100, 0.0, 1.0, opts );
113+
var a = uniform( 100, 0.0, 10.0, opts );
114+
var b = uniform( 100, 0.0, 10.0, opts );
115+
116+
logEachMap( 'x: %0.4f, \t a: %0.4f, \t b: %0.4f, \t f(x,a,b): %0.4f', x, a, b, betainc );
119117
```
120118

121119
</section>

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@
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 betainc = require( './../lib' );
2324

24-
var i;
25-
var x;
26-
var a;
27-
var b;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = uniform( 100, 0.0, 1.0, opts );
29+
var a = uniform( 100, 0.0, 10.0, opts );
30+
var b = uniform( 100, 0.0, 10.0, opts );
2831

29-
for ( i = 0; i < 100; i++ ) {
30-
x = randu();
31-
a = randu() * 10.0;
32-
b = randu() * 10.0;
33-
console.log( 'x: %d, \t a: %d, \t b: %d, \t f(x,a,b): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), betainc( x, a, b ).toFixed( 4 ) );
34-
}
32+
logEachMap( 'x: %0.4f, \t a: %0.4f, \t b: %0.4f, \t f(x,a,b): %0.4f', x, a, b, betainc );

0 commit comments

Comments
 (0)