Skip to content

Commit 48f3de7

Browse files
hrshyakgryte
andauthored
docs: replace manual for loop in examples
PR-URL: #6622 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]> Signed-off-by: Athan Reines <[email protected]>
1 parent 2db6f19 commit 48f3de7

File tree

10 files changed

+76
-90
lines changed

10 files changed

+76
-90
lines changed

lib/node_modules/@stdlib/math/base/special/falling-factorial/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,18 @@ v = fallingFactorial( 3.0, -2 );
8181
<!-- eslint no-undef: "error" -->
8282

8383
```javascript
84-
var randu = require( '@stdlib/random/array/uniform' );
84+
var uniform = require( '@stdlib/random/array/uniform' );
85+
var logEachMap = require( '@stdlib/console/log-each-map' );
8586
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
8687
var fallingFactorial = require( '@stdlib/math/base/special/falling-factorial' );
8788

88-
var x = randu( 100, -20.0, 20.0 );
89-
var n = discreteUniform( 100, 0, 20 );
89+
var opts = {
90+
'dtype': 'float64'
91+
};
92+
var x = uniform( 100, -20.0, 20.0, opts );
93+
var n = discreteUniform( 100, 0, 20, opts );
9094

91-
var i;
92-
for ( i = 0; i < 100; i++ ) {
93-
console.log( 'fallingFactorial(%d,%d) = %d', x[ i ], n[ i ], fallingFactorial( x[ i ], n[ i ] ) );
94-
}
95+
logEachMap( 'fallingFactorial(%0.4f,%0.4f) = %d', x, n, fallingFactorial );
9596
```
9697

9798
</section>

lib/node_modules/@stdlib/math/base/special/falling-factorial/examples/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818

1919
'use strict';
2020

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

25-
var x = randu( 100, -20.0, 20.0 );
26-
var n = discreteUniform( 100, 0, 20 );
26+
var opts = {
27+
'dtype': 'float64'
28+
};
29+
var x = uniform( 100, -20.0, 20.0, opts );
30+
var n = discreteUniform( 100, 0, 20, opts );
2731

28-
var i;
29-
for ( i = 0; i < 100; i++ ) {
30-
console.log( 'fallingFactorial(%d,%d) = %d', x[ i ], n[ i ], fallingFactorial( x[ i ], n[ i ] ) );
31-
}
32+
logEachMap( 'fallingFactorial(%0.4f,%d) = %0.4f', x, n, fallingFactorial );

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,18 @@ z = flipsign( 0.0, -1.0 );
7575
<!-- eslint no-undef: "error" -->
7676

7777
```javascript
78-
var randu = require( '@stdlib/random/base/randu' );
78+
var uniform = require( '@stdlib/random/array/uniform' );
79+
var logEachMap = require( '@stdlib/console/log-each-map' );
7980
var flipsign = require( '@stdlib/math/base/special/flipsign' );
8081

81-
var x;
82-
var y;
83-
var z;
84-
var i;
82+
var opts = {
83+
'dtype': 'float64'
84+
};
85+
var x = uniform( 100, -50.0, 50.0, opts );
86+
var y = uniform( 100, -5.0, 5.0, opts );
8587

8688
// Generate random numbers `x` and `y` and flip the sign of `x` only if `y` is negative...
87-
for ( i = 0; i < 100; i++ ) {
88-
x = (randu()*100.0) - 50.0;
89-
y = (randu()*10.0) - 5.0;
90-
z = flipsign( x, y );
91-
console.log( 'x: %d, y: %d => %d', x, y, z );
92-
}
89+
logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, flipsign );
9390
```
9491

9592
</section>

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

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

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

2931
// Generate random numbers `x` and `y` and flip the sign of `x` only if `y` is negative...
30-
for ( i = 0; i < 100; i++ ) {
31-
x = (randu()*100.0) - 50.0;
32-
y = (randu()*10.0) - 5.0;
33-
z = flipsign( x, y );
34-
console.log( 'x: %d, y: %d => %d', x, y, z );
35-
}
32+
logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, flipsign );

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,18 @@ z = flipsignf( 0.0, -1.0 );
7575
<!-- eslint no-undef: "error" -->
7676

7777
```javascript
78-
var randu = require( '@stdlib/random/base/randu' );
78+
var uniform = require( '@stdlib/random/array/uniform' );
79+
var logEachMap = require( '@stdlib/console/log-each-map' );
7980
var flipsignf = require( '@stdlib/math/base/special/flipsignf' );
8081

81-
var x;
82-
var y;
83-
var z;
84-
var i;
82+
var opts = {
83+
'dtype': 'float32'
84+
};
85+
var x = uniform( 100, -50.0, 50.0, opts );
86+
var y = uniform( 100, -5.0, 5.0, opts );
8587

8688
// Generate random numbers `x` and `y` and flip the sign of `x` only if `y` is negative...
87-
for ( i = 0; i < 100; i++ ) {
88-
x = (randu()*100.0) - 50.0;
89-
y = (randu()*10.0) - 5.0;
90-
z = flipsignf( x, y );
91-
console.log( 'x: %d, y: %d => %d', x, y, z );
92-
}
89+
logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, flipsignf );
9390
```
9491

9592
</section>

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

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

24-
var x;
25-
var y;
26-
var z;
27-
var i;
25+
var opts = {
26+
'dtype': 'float32'
27+
};
28+
var x = uniform( 100, -50.0, 50.0, opts );
29+
var y = uniform( 100, -5.0, 5.0, opts );
2830

2931
// Generate random numbers `x` and `y` and flip the sign of `x` only if `y` is negative...
30-
for ( i = 0; i < 100; i++ ) {
31-
x = (randu()*100.0) - 50.0;
32-
y = (randu()*10.0) - 5.0;
33-
z = flipsignf( x, y );
34-
console.log( 'x: %d, y: %d => %d', x, y, z );
35-
}
32+
logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, flipsignf );

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ v = floor( 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 floor = require( '@stdlib/math/base/special/floor' );
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( 'floor(%d) = %d', x, floor( x ) );
71-
}
71+
logEachMap( 'floor(%0.4f) = %d', x, floor );
7272
```
7373

7474
</section>

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

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

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

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

93-
for ( i = 0; i < 100; i++ ) {
94-
x = (randu()*100.0) - 50.0;
95-
v = floor2( x );
96-
console.log( 'Value: %d. Rounded: %d.', x, v );
97-
}
95+
logEachMap( 'x: %0.4f. Rounded: %d.', x, floor2 );
9896
```
9997

10098
</section>

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

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

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

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

0 commit comments

Comments
 (0)