MathGroup Archive 2000

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

Search the Archive

generating all combinations.


Dear all,

I would like to generate all the combinations n-digit lists, which can 
vary between a certain range and duplications are allowed. The three 
digits with range between -2 to 2 is the following:

allcomb = 
    Table[{i, j, k}, {i, -2, 2}, {j, -2, 2}, {k, -2, 2}];
fltcomb = Partition[Flatten[allcomb], 3];

Is there a more succinct way to do that? If I would like to expand the 
code to 10 digits, the code would looks clumsy.

Thanks for your help.

Wen-Feng



  • Prev by Date: How to change the default setting of BarChart?
  • Next by Date: Creation of file.m
  • Previous by thread: How to change the default setting of BarChart?
  • Next by thread: Creation of file.m