Anonymous user
Cartesian product of two or more lists: Difference between revisions
Cartesian product of two or more lists (view source)
Revision as of 07:15, 28 February 2021
, 3 years ago→{{header|Tailspin}}: Use new cartesian product feature
(Added Wren) |
(→{{header|Tailspin}}: Use new cartesian product feature) |
||
Line 3,840:
=={{header|Tailspin}}==
<lang tailspin>
' -> !OUT::write
'{
' -> !OUT::write
'{
' -> !OUT::write
'{}x{1,2
' -> !OUT::write
'{1776, 1789} × {7, 12} × {4, 14, 23} × {0, 1} = $:[by [1776, 1789]..., by [7, 12]..., by [4, 14, 23]..., by [0, 1]...];
▲'{}x{1,2} = $:[[],[1,2]] -> cartesianProduct;
' -> !OUT::write
'{
' -> !OUT::write
'{1, 2, 3} × {
' -> !OUT::write
// You can also generate structures with named fields
'year {1776, 1789} × month {7, 12} × day {4, 14, 23} = $:{by [1776, 1789]... -> (year:$), by [7, 12]... -> (month:$), by [4, 14, 23]... -> (day:$)};
' -> !OUT::write
</lang>
{{out}}
<pre>
{1,2}x{3,4} =
{3,4}x{1,2} =
{1,2}x{} =
{}x{1,2} =
{1776, 1789} × {7, 12} × {4, 14, 23} × {0, 1} =
{1, 2, 3} × {30} × {500, 100} =
{1, 2, 3} × {} × {500, 100} =
year {1776, 1789} × month {7, 12} × day {4, 14, 23} = {day=4, month=7, year=1776}{day=4, month=7, year=1789}{day=4, month=12, year=1776}{day=4, month=12, year=1789}{day=14, month=7, year=1776}{day=14, month=7, year=1789}{day=14, month=12, year=1776}{day=14, month=12, year=1789}{day=23, month=7, year=1776}{day=23, month=7, year=1789}{day=23, month=12, year=1776}{day=23, month=12, year=1789}
</pre>
|