Cartesian product of two or more lists: Difference between revisions

Content added Content deleted
(Added Uiua solution)
 
Line 5,085: Line 5,085:
result: {1 30 500} {1 30 100} {2 30 500} {2 30 100} {3 30 500} {3 30 100}
result: {1 30 500} {1 30 100} {2 30 500} {2 30 100} {3 30 500} {3 30 100}
result:
result:
</pre>
=={{header|Uiua}}==
<syntaxhighlight lang="uiua">
# Cartesian products

☇1⊞⊂[1 2] [3 4]
☇1⊞⊂[3 4] [1 2]
☇1⊞⊂[3 4] []
C ← /(☇1⊞⊂∩°□)
≡⍚C{{[1776 1789] [7 12] [4 14 23] [0 1]}
{[1 2 3] [30] [500 100]}
{[1 2 3] [] [500 100]}}
</syntaxhighlight>
{{out}}
<pre>
╭─
╷ 1 3
1 4
2 3
2 4
╭─
╷ 3 1
3 2
4 1
4 2
╭─
╷ 0×2 ℝ # i.e. empty
╭─
╓─
╟ 1776 7 4 0
1776 7 4 1
1776 7 14 0
1776 7 14 1
1776 7 23 0
1776 7 23 1
1776 12 4 0
1776 12 4 1
1776 12 14 0 ╓─
1776 12 14 1 ╟ 1 30 500
1776 12 23 0 1 30 100
1776 12 23 1 2 30 500 ╓─
1789 7 4 0 2 30 100 ╟ 0×2 ℝ
1789 7 4 1 3 30 500 ╜
1789 7 14 0 3 30 100
1789 7 14 1 ╜
1789 7 23 0
1789 7 23 1
1789 12 4 0
1789 12 4 1
1789 12 14 0
1789 12 14 1
1789 12 23 0
1789 12 23 1
</pre>
</pre>
=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==
Line 5,127: Line 5,185:
(3,30,500)
(3,30,500)
(3,30,100)
(3,30,100)

=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
{{trans|C#}}
{{trans|C#}}