Re: Combinations
- To: mathgroup at smc.vnet.net
- Subject: [mg49827] Re: Combinations
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Tue, 3 Aug 2004 01:10:59 -0400 (EDT)
- Organization: The University of Western Australia
- References: <ced7i3$q4k$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <ced7i3$q4k$1 at smc.vnet.net>, "E. Martin-Serrano" <eMartinSerrano at houston.rr.com> wrote: > The following seems to be a generalization of David's solution for input of > any length. > > MyCombinations[list_List]:= > Module[{step1}, > > step1=Flatten[Outer[List,Sequence@@Array[list&,Length[list]]],Length[list]-1 > ]; > StringJoin[#1]&/@( Map[SymbolName,#]&/@step1) > ] A slight improvement (using StringJoin in Outer instead of using List): MyCombinations[list_List] := With[{n=Length[list]}, Flatten[Outer[StringJoin, Sequence @@ Map[ToString, Table[list, {n}], {2}]], n - 1]] Cheers, Paul -- Paul Abbott Phone: +61 8 9380 2734 School of Physics, M013 Fax: +61 8 9380 1014 The University of Western Australia (CRICOS Provider No 00126G) 35 Stirling Highway Crawley WA 6009 mailto:paul at physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul