Cartesian product of two or more lists: Difference between revisions
Content added Content deleted
m (→{{header|OCaml}}: remove excess whitespace) |
|||
Line 243: | Line 243: | ||
[]</pre> |
[]</pre> |
||
=={{header|Bracmat}}== |
|||
<lang Bracmat>( ( mul |
|||
= R a b A B |
|||
. :?R |
|||
& !arg:(.?A) (.?B) |
|||
& ( !A |
|||
: ? |
|||
( %@?a |
|||
& !B |
|||
: ? |
|||
( (%@?b|(.?b)) |
|||
& !R (.!a !b):?R |
|||
& ~ |
|||
) |
|||
? |
|||
) |
|||
? |
|||
| (.!R) |
|||
) |
|||
) |
|||
& ( cartprod |
|||
= a |
|||
. !arg:%?a %?arg&mul$(!a cartprod$!arg) |
|||
| !arg |
|||
) |
|||
& out |
|||
$ ( cartprod |
|||
$ ( (.1776 1789) |
|||
(.7 12) |
|||
(.4 14 23) |
|||
(.0 1) |
|||
) |
|||
) |
|||
& out$(cartprod$((.1 2 3) (.30) (.500 100))) |
|||
& out$(cartprod$((.1 2 3) (.) (.500 100))) |
|||
)</lang> |
|||
<pre>. (.1776 7 4 0) |
|||
(.1776 7 4 1) |
|||
(.1776 7 14 0) |
|||
(.1776 7 14 1) |
|||
(.1776 7 23 0) |
|||
(.1776 7 23 1) |
|||
(.1776 12 4 0) |
|||
(.1776 12 4 1) |
|||
(.1776 12 14 0) |
|||
(.1776 12 14 1) |
|||
(.1776 12 23 0) |
|||
(.1776 12 23 1) |
|||
(.1789 7 4 0) |
|||
(.1789 7 4 1) |
|||
(.1789 7 14 0) |
|||
(.1789 7 14 1) |
|||
(.1789 7 23 0) |
|||
(.1789 7 23 1) |
|||
(.1789 12 4 0) |
|||
(.1789 12 4 1) |
|||
(.1789 12 14 0) |
|||
(.1789 12 14 1) |
|||
(.1789 12 23 0) |
|||
(.1789 12 23 1) |
|||
. (.1 30 500) |
|||
(.1 30 100) |
|||
(.2 30 500) |
|||
(.2 30 100) |
|||
(.3 30 500) |
|||
(.3 30 100) |
|||
.</pre> |
|||
=={{header|C}}== |
=={{header|C}}== |