Let's say I have two lists, and I'd like to generate a "cartesian product" from these two. Specifically
Inputs:
A = {{{1}}, {{2}}, {{1}, {2}}};
B = {8, 9};
Desired output:
X = {{{{1}} -> 8, {{1}} -> 9}, {{{2}} -> 8, {{2}} -> 9}, {{{1}, {2}} ->
8, {{1}, {2}} -> 9}}
I tried
f[#1, #2]& /@ {A, B}
but it didn't work. I also tried to use Thread, but that didn't work either.
Edit
Outer doesn't really work either, since it goes to all the leaves and extracts them first.
Outer[#1 -> #2, A, B]
{{{{1 -> 8, 1 -> 9}}}, {{{2 -> 8, 2 -> 9}}}, {{{1 -> 8, 1 -> 9}}, {{2 -> 8, 2 -> 9}}}}
Outer?Outer[Rule, A, B, 1]– rm -rf Jul 03 '13 at 17:46Ruleis the function instead ofJoin. There are several answers there, most/all of which should be applicable here (cc @Mr.Wizard) – rm -rf Jul 03 '13 at 19:50