16
16
* limitations under the License.
17
17
*/
18
18
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
21
21
/// <reference types="@stdlib/types"/>
22
22
23
23
import { Collection } from '@stdlib/types/object' ;
24
24
25
+ /**
26
+ * Returns the n-fold Cartesian product.
27
+ *
28
+ * ## Notes
29
+ *
30
+ * - If provided one or more empty arrays, the function returns an empty array.
31
+ *
32
+ * @param x1 - first input array
33
+ * @param x2 - second input array
34
+ * @returns Cartesian product
35
+ *
36
+ * @example
37
+ * var x1 = [ 1, 2, 3 ];
38
+ * var x2 = [ 4, 5 ];
39
+ *
40
+ * var out = nCartesianProduct( x1, x2 );
41
+ * // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]
42
+ */
43
+ declare function nCartesianProduct < T = any , U = any > ( x1 : Collection < T > , x2 : Collection < U > ) : Array < [ T , U ] > ; // tslint:disable-line:max-line-length
44
+
45
+ /**
46
+ * Returns the n-fold Cartesian product.
47
+ *
48
+ * ## Notes
49
+ *
50
+ * - If provided one or more empty arrays, the function returns an empty array.
51
+ *
52
+ * @param x1 - first input array
53
+ * @param x2 - second input array
54
+ * @param x3 - third input array
55
+ * @returns Cartesian product
56
+ *
57
+ * @example
58
+ * var x1 = [ 1, 2, 3 ];
59
+ * var x2 = [ 4, 5 ];
60
+ * var x3 = [ 6 ];
61
+ *
62
+ * var out = nCartesianProduct( x1, x2, x3 );
63
+ * // returns [ [ 1, 4, 6 ], [ 1, 5, 6 ], [ 2, 4, 6 ], [ 2, 5, 6 ], [ 3, 4, 6 ], [ 3, 5, 6 ] ]
64
+ */
65
+ declare function nCartesianProduct < T = any , U = any , V = any > ( x1 : Collection < T > , x2 : Collection < U > , x3 : Collection < V > ) : Array < [ T , U , V ] > ; // tslint:disable-line:max-line-length
66
+
25
67
/**
26
68
* Returns the n-fold Cartesian product.
27
69
*
@@ -41,7 +83,7 @@ import { Collection } from '@stdlib/types/object';
41
83
* var out = nCartesianProduct( x1, x2 );
42
84
* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]
43
85
*/
44
- declare function nCartesianProduct ( x1 : Collection , x2 : Collection , ...xN : Array < Collection > ) : Array < Array < any > > ; // tslint:disable-line:max-line-length
86
+ declare function nCartesianProduct < T = any , U = any , V = any > ( x1 : Collection < T > , x2 : Collection < U > , ...xN : Array < Collection < V > > ) : Array < Array < T | U | V > > ; // tslint:disable-line:max-line-length
45
87
46
88
47
89
// EXPORTS //
0 commit comments