Skip to content

Commit d31fbf2

Browse files
hrshyaanandkaranubc
authored andcommitted
docs: replace manual for loop in examples
PR-URL: stdlib-js#6612 Reviewed-by: Athan Reines <[email protected]>
1 parent f33351a commit d31fbf2

File tree

10 files changed

+70
-60
lines changed

10 files changed

+70
-60
lines changed

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

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

6363
```javascript
64-
var linspace = require( '@stdlib/array/base/linspace' );
64+
var uniform = require( '@stdlib/random/array/uniform' );
65+
var logEachMap = require( '@stdlib/console/log-each-map' );
6566
var PI = require( '@stdlib/constants/float64/pi' );
6667
var cosm1 = require( '@stdlib/math/base/special/cosm1' );
6768

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

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

7677
</section>

lib/node_modules/@stdlib/math/base/special/cosm1/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 PI = require( '@stdlib/constants/float64/pi' );
2324
var cosm1 = require( './../lib' );
2425

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

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

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

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

65-
var x = linspace( -100.0, 100.0, 100 );
66+
var opts = {
67+
'dtype': 'float64'
68+
};
69+
var x = uniform( 100, -100.0, 100.0, opts );
6670

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

7374
</section>

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

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

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

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

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

6868
```javascript
69-
var linspace = require( '@stdlib/array/base/linspace' );
69+
var uniform = require( '@stdlib/random/array/uniform' );
70+
var logEachMap = require( '@stdlib/console/log-each-map' );
7071
var PI = require( '@stdlib/constants/float64/pi' );
7172
var cot = require( '@stdlib/math/base/special/cot' );
7273

73-
var x = linspace( -PI/2.0, PI/2.0, 100 );
74+
var opts = {
75+
'dtype': 'float64'
76+
};
77+
var x = uniform( 100, -PI/2.0, PI/2.0, opts );
7478

75-
var i;
76-
for ( i = 0; i < x.length; i++ ) {
77-
console.log( cot( x[ i ] ) );
78-
}
79+
logEachMap( 'cot(%0.4f) = %0.4f', x, cot );
7980
```
8081

8182
</section>

lib/node_modules/@stdlib/math/base/special/cot/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 PI = require( '@stdlib/constants/float64/pi' );
2324
var cot = require( './../lib' );
2425

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

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

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

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

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

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

7778
</section>

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

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

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

65-
var x = linspace( -10.0, 10.0, 100 );
66+
var opts = {
67+
'dtype': 'float64'
68+
};
69+
var x = uniform( 100, -10.0, 10.0, opts );
6670

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

7374
</section>

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

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

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

0 commit comments

Comments
 (0)