Skip to content

Commit 76ad4ca

Browse files
hrshyakgrytestdlib-bot
authored
docs: replace manual for loop in examples
PR-URL: #6623 Co-authored-by: Athan Reines <[email protected]> Co-authored-by: hrshya <[email protected]> Co-authored-by: stdlib-bot <[email protected]> Reviewed-by: Athan Reines <[email protected]> Signed-off-by: Athan <[email protected]>
1 parent 8972a22 commit 76ad4ca

File tree

10 files changed

+72
-82
lines changed

10 files changed

+72
-82
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,16 @@ v = floor10( NaN );
9898
<!-- eslint no-undef: "error" -->
9999

100100
```javascript
101-
var randu = require( '@stdlib/random/base/randu' );
101+
var uniform = require( '@stdlib/random/array/uniform' );
102+
var logEachMap = require( '@stdlib/console/log-each-map' );
102103
var floor10 = require( '@stdlib/math/base/special/floor10' );
103104
104-
var x;
105-
var v;
106-
var i;
105+
var opts = {
106+
'dtype': 'float64'
107+
};
108+
var x = uniform( 100, -50.0, 50.0, opts );
107109
108-
for ( i = 0; i < 100; i++ ) {
109-
x = (randu()*100.0) - 50.0;
110-
v = floor10( x );
111-
console.log( 'Value: %d. Rounded: %d.', x, v );
112-
}
110+
logEachMap( 'x: %0.4f. Rounded: %d.', x, floor10 );
113111
```
114112

115113
</section>

lib/node_modules/@stdlib/math/base/special/floor10/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 floor10 = 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 = floor10( x );
31-
console.log( 'x: %d. Rounded: %d.', x, v );
32-
}
30+
logEachMap( 'x: %0.4f. Rounded: %d.', x, floor10 );

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

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

65-
var x;
66-
var i;
66+
var opts = {
67+
'dtype': 'float32'
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( 'floorf(%d) = %d', x, floorf( x ) );
71-
}
71+
logEachMap( 'floorf(%0.4f) = %d', x, floorf );
7272
```
7373

7474
</section>

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

24-
var x;
25-
var i;
25+
var opts = {
26+
'dtype': 'float32'
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( 'floorf(%d) = %d', x, floorf( x ) );
30-
}
30+
logEachMap( 'floorf(%0.4f) = %d', x, floorf );

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,16 @@ v = floorsd( 0.0313, 2, 2 );
6565
<!-- eslint no-undef: "error" -->
6666

6767
```javascript
68-
var randu = require( '@stdlib/random/base/randu' );
68+
var uniform = require( '@stdlib/random/array/uniform' );
69+
var logEachMap = require( '@stdlib/console/log-each-map' );
6970
var floorsd = require( '@stdlib/math/base/special/floorsd' );
7071

71-
var x;
72-
var y;
73-
var i;
72+
var opts = {
73+
'dtype': 'float32'
74+
};
75+
var x = uniform( 100, -5000.0, 5000.0, opts );
7476

75-
for ( i = 0; i < 100; i++ ) {
76-
x = (randu()*10000.0) - 5000.0;
77-
y = floorsd( x, 5, 10 );
78-
console.log( 'x: %d. Rounded: %d.', x, y );
79-
}
77+
logEachMap( 'x: %0.4f. y: %d. z: %d. Rounded: %0.4f.', x, 5, 10, floorsd );
8078
```
8179

8280
</section>

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

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

28-
for ( i = 0; i < 100; i++ ) {
29-
x = (randu()*10000.0) - 5000.0;
30-
y = floorsd( x, 5, 10 );
31-
console.log( 'x: %d. Rounded: %d.', x, y );
32-
}
30+
logEachMap( 'x: %0.4f. y: %d. z: %d. Rounded: %0.4f.', x, 5, 10, floorsd );

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

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

8585
```javascript
86-
var randu = require( '@stdlib/random/base/randu' );
87-
var round = require( '@stdlib/math/base/special/round' );
86+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
87+
var logEachMap = require( '@stdlib/console/log-each-map' );
8888
var fmod = require( '@stdlib/math/base/special/fmod' );
8989

90-
var x;
91-
var y;
92-
var i;
90+
var opts = {
91+
'dtype': 'float64'
92+
};
93+
var x = discreteUniform( 100, 0, 10, opts );
94+
var y = discreteUniform( 100, -5, 5, opts );
9395

94-
for ( i = 0; i < 100; i++ ) {
95-
x = round( randu() * 10.0 );
96-
y = round( randu() * 10.0 ) - 5.0;
97-
console.log( '%d%%%d = %d', x, y, fmod( x, y ) );
98-
}
96+
logEachMap( '%d%%%d = %d', x, y, fmod );
9997
```
10098

10199
</section>

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

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

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var round = require( '@stdlib/math/base/special/round' );
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
2323
var fmod = require( './../lib' );
2424

25-
var x;
26-
var y;
27-
var i;
25+
var opts = {
26+
'dtype': 'float64'
27+
};
28+
var x = discreteUniform( 100, 0, 10, opts );
29+
var y = discreteUniform( 100, -5, 5, opts );
2830

29-
for ( i = 0; i < 100; i++ ) {
30-
x = round( randu() * 10.0 );
31-
y = round( randu() * 10.0 ) - 5.0;
32-
console.log( '%d%%%d = %d', x, y, fmod( x, y ) );
33-
}
31+
logEachMap( '%d%%%d = %d', x, y, fmod );

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,16 @@ v = fmodf( NaN, NaN );
8484

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

89-
var x = discreteUniform( 10, 0.0, 100.0 );
90-
var y = discreteUniform( 10, -50.0, 50.0 );
91-
var i;
90+
var opts = {
91+
'dtype': 'float32'
92+
};
93+
var x = discreteUniform( 100, 0, 100, opts );
94+
var y = discreteUniform( 100, -50, 50, opts );
9295

93-
for ( i = 0; i < 10; i++ ) {
94-
console.log( '%f%%%f = %f', x[ i ], y[ i ], fmodf( x[ i ], y[ i ] ) );
95-
}
96+
logEachMap( '%d%%%d = %d', x, y, fmodf );
9697
```
9798

9899
</section>

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

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

24-
var x = discreteUniform( 10, 0.0, 100.0 );
25-
var y = discreteUniform( 10, -50.0, 50.0 );
26-
var i;
25+
var opts = {
26+
'dtype': 'float32'
27+
};
28+
var x = discreteUniform( 100, 0, 100, opts );
29+
var y = discreteUniform( 100, -50, 50, opts );
2730

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

0 commit comments

Comments
 (0)