我正在寻找一种方法来计算笛卡尔乘积中的EcmaScript 6如何计算乘积的迭代对象
例子:
product([["I", "They"], ["watch", "drink"], ["the sea", "the juice"]])
预期结果:
[["I", "watch", "the sea"], ["I", "watch", "the juice"], ["I", "drink", "the sea"], ["I", "drink", "the juice"], ["They", "watch", "the sea"], ["They", "watch", "the juice"], ["They", "drink", "the sea"], ["They", "drink", "the juice"]]
例如:
product([[-1, -2], [10, 20]])
预期结果:
[[-1, 10], [-1, 20], [-2, 10], [-2, 20]]
什么是嵌套'for..of'循环,如果'arr2'不和的元素目的'arr1'? – guest271314
笛卡尔产品! –
认为,这比真正有用的东西更具挑战性! –