nushell cross product for tables
cross.nu
1def cross-product [...tables] { 05/12/2026 08:21:49 PM
2 let indexed = (
3 $tables
4 | enumerate
5 | each { |t|
6 let prefix = $"t($t.index)_"
7 $t.item
8 | rename --block { |col| $"($prefix)($col)" }
9 }
10 )
11
12 $indexed
13 | reduce --fold [ ] { |table, acc|
14 if ($acc | is-empty) {
15 $table
16 } else {
17 $acc
18 | each { |row|
19 $table | each { |other| $row | merge $other }
20 }
21 | flatten
22 }
23 }
24}