Cartesian product of two or more lists: Difference between revisions

Content added Content deleted
m (→‎{{header|Tailspin}}: update syntax)
Line 3,390: Line 3,390:
templates cartesianProduct
templates cartesianProduct
{ product: [$(1)... -> [$]], rest: $(2..last) } -> #
{ product: [$(1)... -> [$]], rest: $(2..last) } -> #
<{ rest: <[](0)> }> $.product !
when <{ rest: <[](0)> }> do $.product !
<> def m: $.rest(1);
otherwise def m: $.rest(1);
{ product: [$.product... -> \(def n: $; $m... -> [$n..., $] !\)], rest: $.rest(2..last) } -> #
{ product: [$.product... -> \(def n: $; $m... -> [$n..., $] !\)], rest: $.rest(2..last) } -> #
end cartesianProduct
end cartesianProduct