我正在尋找一種方法來計算笛卡爾乘積中的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
笛卡爾產品! –
認爲,這比真正有用的東西更具挑戰性! –