Re: Combinations
- To: mathgroup at smc.vnet.net
- Subject: [mg49708] Re: [mg49672] Combinations
- From: Ken Levasseur <klevasseur at mac.com>
- Date: Thu, 29 Jul 2004 07:43:25 -0400 (EDT)
- References: <200407271100.HAA11164@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Greg:
If data is the output from the Outer expression,
Flatten[Map[StringJoin, Map[ToString, data, {4}], {3}]]
produces
{"aaa", "aab", "aac", "aba", "abb", "abc", "aca", "acb",
"acc", "baa", "bab", "bac", "bba", "bbb", "bbc", "bca",
"bcb", "bcc", "caa", "cab", "cac", "cba", "cbb", "cbc",
"cca", "ccb", "ccc"}
Ken Levasseur
Math. Sci.
UMass Lowell
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
>
- References:
- Combinations
- From: Gregory Lypny <gregory.lypny@videotron.ca>
- Combinations