Skip to content

Commit b834207

Browse files
hrshyastdlib-bot
andauthored
chore: replace manual for loop in examples
PR-URL: #6403 Co-authored-by: stdlib-bot <[email protected]> Reviewed-by: Athan Reines <[email protected]> Signed-off-by: Harsh <[email protected]>
1 parent 2366870 commit b834207

File tree

12 files changed

+84
-92
lines changed

12 files changed

+84
-92
lines changed

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

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

8484
```javascript
85-
var randu = require( '@stdlib/random/base/randu' );
85+
var uniform = require( '@stdlib/random/array/uniform' );
86+
var logEachMap = require( '@stdlib/console/log-each-map' );
8687
var exp = require( '@stdlib/math/base/special/exp' );
8788

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

91-
for ( i = 0; i < 100; i++ ) {
92-
x = (randu()*100.0) - 50.0;
93-
console.log( 'e^%d = %d', x, exp( x ) );
94-
}
94+
logEachMap( 'e^%0.4f = %0.4f', x, exp );
9595
```
9696

9797
</section>

lib/node_modules/@stdlib/math/base/special/exp/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 exp = 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( 'e^%d = %d', x, exp( x ) );
30-
}
30+
logEachMap( 'e^%0.4f = %0.4f', x, exp );

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ v = exp10( NaN );
5959
<!-- eslint no-undef: "error" -->
6060

6161
```javascript
62-
var randu = require( '@stdlib/random/base/randu' );
62+
var uniform = require( '@stdlib/random/array/uniform' );
63+
var logEachMap = require( '@stdlib/console/log-each-map' );
6364
var exp10 = require( '@stdlib/math/base/special/exp10' );
6465

65-
var x;
66-
var i;
66+
var opts = {
67+
'dtype': 'float64'
68+
};
69+
var x = uniform( 100, -50.0, 50.0, opts );
6770

68-
for ( i = 0; i < 100; i++ ) {
69-
x = (randu()*100.0) - 50.0;
70-
console.log( '10^%d = %d', x, exp10( x ) );
71-
}
71+
logEachMap( '10^%0.4f = %0.4f', x, exp10 );
7272
```
7373

7474
</section>

lib/node_modules/@stdlib/math/base/special/exp10/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 exp10 = 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( '10^%d = %d', x, exp10( x ) );
30-
}
30+
logEachMap( '10^%0.4f = %0.4f', x, exp10 );

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ v = exp2( NaN );
5959
<!-- eslint no-undef: "error" -->
6060

6161
```javascript
62-
var randu = require( '@stdlib/random/base/randu' );
62+
var uniform = require( '@stdlib/random/array/uniform' );
63+
var logEachMap = require( '@stdlib/console/log-each-map' );
6364
var exp2 = require( '@stdlib/math/base/special/exp2' );
6465

65-
var x;
66-
var i;
66+
var opts = {
67+
'dtype': 'float64'
68+
};
69+
var x = uniform( 100, -50.0, 50.0, opts );
6770

68-
for ( i = 0; i < 100; i++ ) {
69-
x = (randu()*100.0) - 50.0;
70-
console.log( '2^%d = %d', x, exp2( x ) );
71-
}
71+
logEachMap( '2^%0.4f = %0.4f', x, exp2 );
7272
```
7373

7474
</section>

lib/node_modules/@stdlib/math/base/special/exp2/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 exp2 = 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( '2^%d = %d', x, exp2( x ) );
30-
}
30+
logEachMap( '2^%0.4f = %0.4f', x, exp2 );

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ v = expit( 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 expit = require( '@stdlib/math/base/special/expit' );
8889

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

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

9898
</section>

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

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

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

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ v = expm1( NaN );
5959
<!-- eslint no-undef: "error" -->
6060

6161
```javascript
62-
var randu = require( '@stdlib/random/base/randu' );
62+
var uniform = require( '@stdlib/random/array/uniform' );
63+
var logEachMap = require( '@stdlib/console/log-each-map' );
6364
var expm1 = require( '@stdlib/math/base/special/expm1' );
6465

65-
var x;
66-
var i;
66+
var opts = {
67+
'dtype': 'float64'
68+
};
69+
var x = uniform( 100, -5.0, 5.0, opts );
6770

68-
for ( i = 0; i < 100; i++ ) {
69-
x = (randu()*10.0) - 5.0;
70-
console.log( 'e^%d - 1 = %d', x, expm1( x ) );
71-
}
71+
logEachMap( 'e^%0.4f - 1 = %0.4f', x, expm1 );
7272
```
7373

7474
</section>

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

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

27-
for ( i = 0; i < 100; i++ ) {
28-
x = (randu()*10.0) - 5.0;
29-
console.log( 'e^%d - 1 = %d', x, expm1( x ) );
30-
}
30+
logEachMap( 'e^%0.4f - 1 = %0.4f', x, expm1 );

0 commit comments

Comments
 (0)