Re: Help ! complex permutations
- To: mathgroup at smc.vnet.net
- Subject: [mg7032] Re: Help ! complex permutations
- From: uyurtsever at dynatec.com (Ulvi Yurtsever)
- Date: Fri, 2 May 1997 21:30:56 -0400 (EDT)
- Organization: AT&T WorldNet Services
- Sender: owner-wri-mathgroup at wolfram.com
On 29 Apr 1997 21:40:11 -0400, Robert_P at pro-bel.co.uk (Robert Perkins)
wrote:
>
>Robert_p
>
>
E.g., for the case (your case, I think) when the ordering of elements
IS significant, you might do:
In[70]:= Flatten[Outer[f, {a,b}, {a,b}]]/.f->List
Out[70]= {{a,a},{a,b},{b,a},{b,b}}
In[71]:= Flatten[Outer[f, {a,b}, {a,b}, {a,b}]]/.f->List
Out[71]={{a,a,a},{a,a,b},{a,b,a},{a,b,b},{b,a,a},
{b,a,b},{b,b,a},{b,b,b}}
For the case where the ordering is NOT significant (in which case the
total number of permutations is Binomial[n+|m|-1, |m|-1]), you might
do:
In[72]:= Union[Map[Sort,Flatten[Outer[f,{a,b},{a,b}]]/.f->List]]
Out[72]={{a,a},{a,b},{b,b}}
In[73]:= Union[Map[Sort,Flatten[
Outer[f,{a,b},{a,b}, {a,b}]]/.f->List]]
Out[73]={{a,a,a},{a,a,b},{a,b,b},{b,b,b}}
(Caution: these are quick & dirty implementations; ie with no
attention paid to time or space efficiency.)
best wishes
Ulvi Yurtsever
Senior Research Scientist
Dynamics Technology, Inc.
21311 Hawthorne Blvd., Suite 300
Torrance, CA 90503-5610
(310) 543-5433, FAX: (310) 543-2117
email: uyurtsever at dynatec.com