Cartesian product of two or more lists: Difference between revisions

Content added Content deleted
(added langur language example)
Line 1,561: Line 1,561:


=={{header|Julia}}==
=={{header|Julia}}==
Run in REPL.
<lang julia>
<lang julia>
# Product {1, 2} × {3, 4}
# Product {1, 2} × {3, 4}
collect(product([1, 2], [3, 4]))
collect(Iterators.product([1, 2], [3, 4]))
# Product {3, 4} × {1, 2}
# Product {3, 4} × {1, 2}
collect(product([3, 4], [1, 2]))
collect(Iterators.product([3, 4], [1, 2]))

# Product {1, 2} × {}
# Product {1, 2} × {}
collect(product([1, 2], []))
collect(Iterators.product([1, 2], []))
# Product {} × {1, 2}
# Product {} × {1, 2}
collect(product([], [1, 2]))
collect(Iterators.product([], [1, 2]))

# Product {1776, 1789} × {7, 12} × {4, 14, 23} × {0, 1}
# Product {1776, 1789} × {7, 12} × {4, 14, 23} × {0, 1}
collect(product([1776, 1789], [7, 12], [4, 14, 23], [0, 1]))
collect(Iterators.product([1776, 1789], [7, 12], [4, 14, 23], [0, 1]))
# Product {1, 2, 3} × {30} × {500, 100}
# Product {1, 2, 3} × {30} × {500, 100}
collect(product([1, 2, 3], [30], [500, 100]))
collect(Iterators.product([1, 2, 3], [30], [500, 100]))
# Product {1, 2, 3} × {} × {500, 100}
# Product {1, 2, 3} × {} × {500, 100}
collect(product([1, 2, 3], [], [500, 100]))
collect(Iterators.product([1, 2, 3], [], [500, 100]))
</lang>
</lang>