Re: combinations of n objects 2 at a time
- To: mathgroup at smc.vnet.net
- Subject: [mg15219] Re: combinations of n objects 2 at a time
- From: Bill Knox <bknox at snet.net>
- Date: Tue, 22 Dec 1998 04:01:48 -0500
- References: <75cvud$3u8@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Albert Maydeu-Olivares wrote: > > Hello, > > In order to generate all combinations of n objects 2 at a time I load > the `DiscreteMath` add-on. > > <<DiscreteMath`Combinatorica` > > l[n_]:=rt[Ksubsets[Reverse[Table[i,{i,n}]],2]] > > So that with n=objects I get > > l[6] > > {{2,1},{3,1},...,{6,4},{6,5}} > > Any suggestions on how to do this without loading the add-on? > Here is direct code: l[n_]:= Flatten[Table[{i,j},{i,2,n}, {j,i-1}],1] Bill Knox e-mail to: bknox at snet.net