MathGroup Archive 2004

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

Search the Archive

Re: Combinations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49719] Re: Combinations
  • From: BobHanlon at aol.com
  • Date: Thu, 29 Jul 2004 07:43:45 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Needs["DiscreteMath`Combinatorica`"];


Strings[{a,b,c}, 3]


{{a, a, a}, {a, a, b}, {a, a, c}, {a, b, a}, {a, b, b}, 
   {a, b, c}, {a, c, a}, {a, c, b}, {a, c, c}, {b, a, a}, 
   {b, a, b}, {b, a, c}, {b, b, a}, {b, b, b}, {b, b, c}, 
   {b, c, a}, {b, c, b}, {b, c, c}, {c, a, a}, {c, a, b}, 
   {c, a, c}, {c, b, a}, {c, b, b}, {c, b, c}, {c, c, a}, 
   {c, c, b}, {c, c, c}}


%==Flatten[Outer[List,{a,b,c},{a,b,c},{a,b,c}],2]


True


Length[%%]


27


Bob Hanlon

> In a message dated Tue, 27 Jul 2004 11:17:25 +0000 (UTC), <
> gregory.lypny at videotron.ca> writes:  Does Mathematica have a built-in function that 
> will generate a simple 
> list all possible combinations of a list of strings?   For example, 
> {a,b,c}, where the elements are strings, should give 3x3=27 triplets of 
> "aaa", "aba", etc.
> 
> I tried
> 
> In[4]:=Outer[{a,b,c},{a,b,c},{a,b,c}]
> 
> but I get
> 
> {{{a, b, c}[a, a], {a, b, c}[a, b], {
>       a, b, c}[a, c]}, {{a, b, c}[b, a], {a, b, c}[b, b], {a, b,
>         c}[b, c]}, {{a, b, c}[c, a], {a, b, c}[c, b], {a, b, c}[c, c]}}
> 
> which is going to be difficult to match with my data using BinCounts 
> and the like.
> 


  • Prev by Date: RE: Using "Sum" (i = 1 ... N) in a function definition
  • Next by Date: Re: Using "Sum" (i = 1 ... N) in a function definition
  • Previous by thread: Re: Combinations
  • Next by thread: Re: Combinations