Cartesian product of two or more lists: Difference between revisions
Cartesian product of two or more lists (view source)
Revision as of 03:18, 6 January 2019
, 5 years agoAdded 11l
(Added SQL implementation) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 21:
<br>
=={{header|11l}}==
{{trans|Go}}
<lang 11l>F cart_prod(a, b)
V p = [(0, 0)] * (a.len * b.len)
V i = 0
L(aa) a
L(bb) b
p[i++] = (aa, bb)
R p
print(cart_prod([1, 2], [3, 4]))
print(cart_prod([3, 4], [1, 2]))
print(cart_prod([1, 2], []))
print(cart_prod([], [1, 2]))</lang>
{{out}}
<pre>
[(1, 3), (1, 4), (2, 3), (2, 4)]
[(3, 1), (3, 2), (4, 1), (4, 2)]
[]
[]
</pre>
=={{header|AppleScript}}==
<lang AppleScript>-- CARTESIAN PRODUCTS ---------------------------------------------------------
|