Skip to content

Commit 1bb6df3

Browse files
authored
docs: replace manual for loop in examples
PR-URL: #6611 Reviewed-by: Athan Reines <[email protected]>
1 parent 4a76339 commit 1bb6df3

File tree

10 files changed

+74
-80
lines changed

10 files changed

+74
-80
lines changed

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

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

7474
```javascript
75-
var randu = require( '@stdlib/random/base/randu' );
75+
var uniform = require( '@stdlib/random/array/uniform' );
76+
var logEachMap = require( '@stdlib/console/log-each-map' );
7677
var copysign = require( '@stdlib/math/base/special/copysign' );
7778

78-
var x;
79-
var y;
80-
var z;
81-
var i;
79+
var opts = {
80+
'dtype': 'float64'
81+
};
82+
var x = uniform( 100, -50.0, 50.0, opts );
83+
var y = uniform( 100, -5.0, 5.0, opts );
8284

8385
// Generate random double-precision floating-point numbers `x` and `y` and copy the sign of `y` to `x`...
84-
for ( i = 0; i < 100; i++ ) {
85-
x = (randu()*100.0) - 50.0;
86-
y = (randu()*10.0) - 5.0;
87-
z = copysign( x, y );
88-
console.log( 'x: %d, y: %d => %d', x, y, z );
89-
}
86+
logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, copysign );
9087
```
9188

9289
</section>

lib/node_modules/@stdlib/math/base/special/copysign/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 copysign = 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 double-precision floating-point numbers `x` and `y` and copy the sign of `y` to `x`...
30-
for ( i = 0; i < 100; i++ ) {
31-
x = (randu()*100.0) - 50.0;
32-
y = (randu()*10.0) - 5.0;
33-
z = copysign( 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, copysign );

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

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

7474
```javascript
75-
var randu = require( '@stdlib/random/base/randu' );
75+
var uniform = require( '@stdlib/random/array/uniform' );
76+
var logEachMap = require( '@stdlib/console/log-each-map' );
7677
var copysignf = require( '@stdlib/math/base/special/copysignf' );
7778

78-
var x;
79-
var y;
80-
var z;
81-
var i;
79+
var opts = {
80+
'dtype': 'float32'
81+
};
82+
var x = uniform( 100, -50.0, 50.0, opts );
83+
var y = uniform( 100, -5.0, 5.0, opts );
8284

8385
// Generate random numbers `x` and `y` and copy the sign of `y` to `x`...
84-
for ( i = 0; i < 100; i++ ) {
85-
x = (randu()*100.0) - 50.0;
86-
y = (randu()*10.0) - 5.0;
87-
z = copysignf( x, y );
88-
console.log( 'x: %d, y: %d => %d', x, y, z );
89-
}
86+
logEachMap( 'x: %0.4f, y: %0.4f => %0.4f', x, y, copysignf );
9087
```
9188

9289
</section>

lib/node_modules/@stdlib/math/base/special/copysignf/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 copysignf = 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 copy the sign of `y` to `x`...
30-
for ( i = 0; i < 100; i++ ) {
31-
x = (randu()*100.0) - 50.0;
32-
y = (randu()*10.0) - 5.0;
33-
z = copysignf( 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, copysignf );

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

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

6161
```javascript
62-
var linspace = require( '@stdlib/array/base/linspace' );
62+
var uniform = require( '@stdlib/random/array/uniform' );
63+
var logEachMap = require( '@stdlib/console/log-each-map' );
6364
var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
6465
var cos = require( '@stdlib/math/base/special/cos' );
6566

66-
var x = linspace( 0.0, TWO_PI, 100 );
67+
var opts = {
68+
'dtype': 'float64'
69+
};
70+
var x = uniform( 100, 0.0, TWO_PI, opts );
6771

68-
var i;
69-
for ( i = 0; i < x.length; i++ ) {
70-
console.log( cos( x[ i ] ) );
71-
}
72+
logEachMap( 'cos(%0.4f) = %0.4f', x, cos );
7273
```
7374

7475
</section>

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
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 TWO_PI = require( '@stdlib/constants/float64/two-pi' );
2324
var cos = require( './../lib' );
2425

25-
var x = linspace( 0.0, TWO_PI, 100 );
26+
var opts = {
27+
'dtype': 'float64'
28+
};
29+
var x = uniform( 100, 0.0, TWO_PI, opts );
2630

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

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ v = cosd( NaN );
6363
<!-- eslint no-undef: "error" -->
6464

6565
```javascript
66-
var linspace = require( '@stdlib/array/base/linspace' );
66+
var uniform = require( '@stdlib/random/array/uniform' );
67+
var logEachMap = require( '@stdlib/console/log-each-map' );
6768
var cosd = require( '@stdlib/math/base/special/cosd' );
6869

69-
var x = linspace( -180, 180, 100 );
70+
var opts = {
71+
'dtype': 'float64'
72+
};
73+
var x = uniform( 100, -180, 180, opts );
7074

71-
var i;
72-
for ( i = 0; i < x.length; i++ ) {
73-
console.log( cosd( x[ i ] ) );
74-
}
75+
logEachMap( 'cosd(%0.4f) = %0.4f', x, cosd );
7576
```
7677

7778
</section>

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

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

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

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ v = cosh( NaN );
6262
<!-- eslint no-undef: "error" -->
6363

6464
```javascript
65-
var linspace = require( '@stdlib/array/base/linspace' );
65+
var uniform = require( '@stdlib/random/array/uniform' );
66+
var logEachMap = require( '@stdlib/console/log-each-map' );
6667
var cosh = require( '@stdlib/math/base/special/cosh' );
6768

68-
var x = linspace( -5.0, 5.0, 100 );
69+
var opts = {
70+
'dtype': 'float64'
71+
};
72+
var x = uniform( 100, -5.0, 5.0, opts );
6973

70-
var i;
71-
for ( i = 0; i < x.length; i++ ) {
72-
console.log( cosh( x[ i ] ) );
73-
}
74+
logEachMap( 'cosh(%0.4f) = %0.4f', x, cosh );
7475
```
7576

7677
</section>

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

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

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

0 commit comments

Comments
 (0)