mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 20:22:26 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/xprod.js
|
|
|
|
|
|
import _curry2 from './internal/_curry2.js';
|
|
|
|
|
|
/**
|
|
* Creates a new list out of the two supplied by creating each possible pair
|
|
* from the lists.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.1.0
|
|
* @category List
|
|
* @sig [a] -> [b] -> [[a,b]]
|
|
* @param {Array} as The first list.
|
|
* @param {Array} bs The second list.
|
|
* @return {Array} The list made by combining each possible pair from
|
|
* `as` and `bs` into pairs (`[a, b]`).
|
|
* @example
|
|
*
|
|
* R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
|
|
* @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]]
|
|
*/
|
|
var xprod = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...)
|
|
var idx = 0;
|
|
var ilen = a.length;
|
|
var j;
|
|
var jlen = b.length;
|
|
var result = [];
|
|
while (idx < ilen) {
|
|
j = 0;
|
|
while (j < jlen) {
|
|
result[result.length] = [a[idx], b[j]];
|
|
j += 1;
|
|
}
|
|
idx += 1;
|
|
}
|
|
return result;
|
|
});
|
|
export default xprod;
|