Cartesian product of two or more lists: Difference between revisions
Content added Content deleted
(Erlang version) |
mNo edit summary |
||
Line 1,637: | Line 1,637: | ||
end program cartesian_product |
end program cartesian_product |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{out}} |
|||
'''Output:''' |
|||
<pre> {1,2} x {3,4} = {{1,3},{1,4},{2,3},{2,4}} |
|||
{3,4} x {1,2} = {{3,1},{3,2},{4,1},{4,2}} |
{3,4} x {1,2} = {{3,1},{3,2},{4,1},{4,2}} |
||
{1,2} x {} = {} |
{1,2} x {} = {} |
||
{} x {1,2} = {} |
{} x {1,2} = {}</pre> |
||
<!-- |
|||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
I'll leave the extra credit part for someone else. It's just going to amount to repeatedly finding Cartesian products and [[Flatten a list|flattening]] the result, so considerably less interesting than Cartesian products where the list items themselves can be lists. |
I'll leave the extra credit part for someone else. It's just going to amount to repeatedly finding Cartesian products and [[Flatten a list|flattening]] the result, so considerably less interesting than Cartesian products where the list items themselves can be lists. |
||
Line 1,714: | Line 1,713: | ||
{} |
{} |
||
</pre> |
</pre> |
||
=={{header|Fōrmulæ}}== |
=={{header|Fōrmulæ}}== |
||