MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: All Possible Combinations from N Sublists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97704] Re: [mg97651] Re: [mg97639] All Possible Combinations from N Sublists
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Thu, 19 Mar 2009 02:11:03 -0500 (EST)
  • References: <31581884.1237284930765.JavaMail.root@m02>
  • Reply-to: drmajorbob at bigfoot.com

myList = {{1, 2, 3}, {e, f}, {g, h}};
Tuples@myList

{{1, e, g}, {1, e, h}, {1, f, g}, {1, f, h}, {2, e, g}, {2, e, h}, {2,
    f, g}, {2, f, h}, {3, e, g}, {3, e, h}, {3, f, g}, {3, f, h}}

Bobby

On Wed, 18 Mar 2009 04:51:33 -0500, David Park <djmpark at comcast.net> wrote:

> myList = {{1, 2, 3}, {e, f}, {g, h}};
>
> Flatten[Outer[List, Sequence @@ myList], 2]
> {{1, e, g}, {1, e, h}, {1, f, g}, {1, f, h}, {2, e, g}, {2, e, h}, {2,
>    f, g}, {2, f, h}, {3, e, g}, {3, e, h}, {3, f, g}, {3, f, h}}
>
>
> David Park
> djmpark at comcast.net
> http://home.comcast.net/~djmpark/
>
>
> From: Donald DuBois [mailto:donabc at comcast.net]
>
> Given a list of N sublists, how can I produce all possible combinations
> where the first
> element comes from the first sublst, the second element from the second
> sublist etc.
>
> For instance,
>
> myList = {{1, 2, 3}, {e, f}, {g, h}}
>
> the result should be,
>
>
> {{1, e, g}, {1, e, h}, {1, f, g}, {1, f, h}, {2, e, g}, {2, e, h}, {2, f,
>   g}, {2, f, h}, {3, e, g}, {3, e, h}, {3, f, g}, {3, f, h}}
>
> Thank you.
>
>
>



-- 
DrMajorBob at bigfoot.com


  • Prev by Date: Notebook State Saver: A new tool for saving the state of your open
  • Next by Date: Re: Wolfram WorkBench and iDisk
  • Previous by thread: Re: All Possible Combinations from N Sublists
  • Next by thread: econometrics with mathematica?