1
$\begingroup$

I have a list of sets of ordered pairs:

{{{1, 1}, {1, 2}, {2, 4}, {4, 8}}, {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}}

There are 4 ordered pairs in the first set, 2 ordered pairs in the second set and 2 ordered pairs in the third set. I want the 4X2X2=16 triplets of ordered pairs:

{{{1,1},{1,1},{1,1}}, {{1,1},{1,1},{1,2}}, {{1,1},{1,2},{1,1}},..., {{4,8},{1,2},{1,2}}}.

I tried using the functions "Outer" and "List" but my code didn't work.

$\endgroup$
3
  • $\begingroup$ Please include the code you tried, so that we can see where you are! $\endgroup$
    – march
    Commented Aug 3 at 21:41
  • 2
    $\begingroup$ Like this Outer[List, Sequence @@ lst, 1]~Flatten~2? Where lst is your list of lists of ordered pairs. $\endgroup$
    – march
    Commented Aug 3 at 21:46
  • $\begingroup$ @ march. Yes Thank you. $\endgroup$ Commented Aug 3 at 22:01

1 Answer 1

5
$\begingroup$
input = {{{1, 1}, {1, 2}, {2, 4}, {4, 8}}, {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}};
Tuples[input]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.