MathGroup Archive 2000

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

Search the Archive

Re:Generating all combinations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22517] Re:Generating all combinations
  • From: "Alan W.Hopper" <awhopper at hermes.net.au>
  • Date: Sun, 5 Mar 2000 00:24:57 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Here is a convenient solution for Wen-Feng Hsiao's problem ,

In[1]:= <<DiscreteMath`Combinatorica`

In[2]:= ?Strings

             Strings [l,n] constructs all possible strings of length n
               from the elements of list l.

In[4]:= ls=Strings[Range[-2, 2], 3] //Shallow

Out[4]//Shallow=

                {{-2,-2,-2}, {-2,-2,-1}, {-2,-2,0}, {-2,-2,1},
                  {-2,-2,2}, {-2,-1,-2}, {-2,-1,-1}, {-2,-1,0},
                  {-2,-1,1}, {-2,-1,2} <<115>> }

In[5]:= Length[ls[[1]]]

Out[5]= 125



Alan Hopper

awhopper at hermes.net.au


  • Prev by Date: Re: newbie, problems with loading packages
  • Next by Date: Re: Importing LaTex files
  • Previous by thread: Re:Generating all combinations
  • Next by thread: <<NumberTheory`FactorIntegerECM`