Cartesian product of two or more lists: Difference between revisions

→‎{{header|langur}}: updated to use mapX() instead of X()
m (→‎{{header|Wren}}: Minor tidy)
(→‎{{header|langur}}: updated to use mapX() instead of X())
Line 2,974:
</pre>
=={{header|langur}}==
{{works with|langur|0.8.311}}
We could use mapX() to map each set of values to a function, but this assignment only requires an array of arrays, so we use the X() function.
<syntaxhighlight lang="langur">writeln mapX(f(... .x) .x, [1, 2], [3, 4]) == [[1, 3], [1, 4], [2, 3], [2, 4]]
 
writeln mapX(f(... .x) .x, [3, 4], [1, 2]) == [[3, 1], [3, 2], [4, 1], [4, 2]]
{{works with|langur|0.8.3}}
<syntaxhighlight lang="langur">writeln XmapX(f(... .x) .x, [1, 2], [3, 4]) == [[1, 3], [1, 4], [2, 3], [2, 4]]
writeln XmapX([3f(... .x) .x, 4[], [1, 2]) == [[3, 1], [3, 2], [4, 1], [4, 2]]
writeln X([1, 2], []) == []
writeln X([], [1, 2]) == []
writeln()
 
writeln XmapX f(... .x) .x, [1776, 1789], [7, 12], [4, 14, 23], [0, 1]
writeln()
 
writeln XmapX f(... .x) .x, [1, 2, 3], [30], [500, 100]
writeln()
 
writeln XmapX f(... .x) .x, [1, 2, 3], [], [500, 100]
writeln()</syntaxhighlight>
 
Line 3,004 ⟶ 3,002:
[]
</pre>
 
=={{header|Lua}}==
=== Functional ===
889

edits