Skip to content

Commit 67d19bc

Browse files
committed
Auto-generated commit
1 parent 67ab428 commit 67d19bc

File tree

3 files changed

+26
-35
lines changed

3 files changed

+26
-35
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ A total of 15 issues were closed in this release:
389389

390390
<details>
391391

392+
- [`d30fed0`](https://github.com/stdlib-js/stdlib/commit/d30fed0b3516e362f957aa15d1521b3b3fe6cefd) - **docs:** update examples _(by Athan Reines)_
392393
- [`916b907`](https://github.com/stdlib-js/stdlib/commit/916b9073d6cf82262233e835f9bbbaca26d685f0) - **feat:** add `ndarray/vector/ctor` _(by Athan Reines)_
393394
- [`9b8f3a8`](https://github.com/stdlib-js/stdlib/commit/9b8f3a8e51b449803b683c7bf394d498de479a5f) - **docs:** update namespace table of contents [(#6996)](https://github.com/stdlib-js/stdlib/pull/6996) _(by stdlib-bot)_
394395
- [`603ba97`](https://github.com/stdlib-js/stdlib/commit/603ba974c88f33cb73ba53c69435183ca535ded9) - **docs:** fix parameter names _(by Athan Reines)_

promotion-rules/README.md

+13-18
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,23 @@ var out = promotionRules( 'foo', 'generic' );
9797
<!-- eslint no-undef: "error" -->
9898

9999
```javascript
100+
var cartesianProduct = require( '@stdlib/array/cartesian-product' );
100101
var dtypes = require( '@stdlib/ndarray/dtypes' );
102+
var unzip = require( '@stdlib/utils/unzip' );
103+
var logEachMap = require( '@stdlib/console/log-each-map' );
101104
var promotionRules = require( '@stdlib/ndarray/promotion-rules' );
102105

103-
var DTYPES;
104-
var dt1;
105-
var dt2;
106-
var dt;
107-
var i;
108-
var j;
109-
110106
// Get the list of supported ndarray data types:
111-
DTYPES = dtypes();
112-
113-
// Print the promotion rule for each pair of ndarray data types...
114-
for ( i = 0; i < DTYPES.length; i++ ) {
115-
dt1 = DTYPES[ i ];
116-
for ( j = 0; j < DTYPES.length; j++ ) {
117-
dt2 = DTYPES[ j ];
118-
dt = promotionRules( dt1, dt2 );
119-
console.log( '(%s, %s) => %s', dt1, dt2, dt );
120-
}
121-
}
107+
var dt = dtypes();
108+
109+
// Generate a list of data type pairs:
110+
var pairs = cartesianProduct( dt, dt );
111+
112+
// Split the pairs into separate arrays:
113+
var args = unzip( pairs );
114+
115+
// Print the promotion rule for each pair of ndarray data types:
116+
logEachMap( '(%s, %s) => %s', args[ 0 ], args[ 1 ], promotionRules );
122117
```
123118

124119
</section>

promotion-rules/examples/index.js

+12-17
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,20 @@
1818

1919
'use strict';
2020

21+
var cartesianProduct = require( '@stdlib/array/cartesian-product' );
2122
var dtypes = require( './../../dtypes' );
23+
var unzip = require( '@stdlib/utils/unzip' );
24+
var logEachMap = require( '@stdlib/console/log-each-map' );
2225
var promotionRules = require( './../lib' );
2326

24-
var DTYPES;
25-
var dt1;
26-
var dt2;
27-
var dt;
28-
var i;
29-
var j;
30-
3127
// Get the list of supported ndarray data types:
32-
DTYPES = dtypes();
28+
var dt = dtypes();
29+
30+
// Generate a list of data type pairs:
31+
var pairs = cartesianProduct( dt, dt );
32+
33+
// Split the pairs into separate arrays:
34+
var args = unzip( pairs );
3335

34-
// Print the promotion rule for each pair of ndarray data types...
35-
for ( i = 0; i < DTYPES.length; i++ ) {
36-
dt1 = DTYPES[ i ];
37-
for ( j = 0; j < DTYPES.length; j++ ) {
38-
dt2 = DTYPES[ j ];
39-
dt = promotionRules( dt1, dt2 );
40-
console.log( '(%s, %s) => %s', dt1, dt2, dt );
41-
}
42-
}
36+
// Print the promotion rule for each pair of ndarray data types:
37+
logEachMap( '(%s, %s) => %s', args[ 0 ], args[ 1 ], promotionRules );

0 commit comments

Comments
 (0)