Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Combinations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49697] Re: [mg49672] Combinations
  • From: János <janos.lobb at yale.edu>
  • Date: Thu, 29 Jul 2004 07:43:06 -0400 (EDT)
  • References: <200407271100.HAA11164@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

With Outer you need a function as the first parameter.  Being a newbie 
I would go with:

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

János

P.S.  Look back on the list for any postings to "All combinations" from 
April this year.  Here is what I got back from Andrzej Kozlowski

AllCombinations[S_List,k_]:=Distribute[Table[S,{k}],List]

pretty comprehensive and deep.



On Jul 27, 2004, at 7:00 AM, Gregory Lypny wrote:

> Hello everyone,
>
> 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.
>
> 	Regards,
>
> 		Greg
>
>
------
"..because Annushka has already bought sunflower oil, and not only 
bought it, but spilled it too."
Bulgakov:  Master and Margarita


  • References:
    • Combinations
      • From: Gregory Lypny <gregory.lypny@videotron.ca>
  • Prev by Date: Re: Using "Sum" (i = 1 ... N) in a function definition
  • Next by Date: Re: Re: DeleteCases : several at once, conditions
  • Previous by thread: Re: Combinations
  • Next by thread: Re: Combinations