Re: generating all combinations.
- To: mathgroup at smc.vnet.net
- Subject: [mg22420] Re: [mg22395] generating all combinations.
- From: Rob Pratt <rpratt at email.unc.edu>
- Date: Wed, 1 Mar 2000 00:40:17 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Distribute[Table[Range[-2,2],{n}],List]
I would not suggest using n = 10, as there would be 5^10 lists, each with
10 elements.
Rob Pratt
Department of Operations Research
The University of North Carolina at Chapel Hill
rpratt at email.unc.edu
http://www.unc.edu/~rpratt/
On Sun, 27 Feb 2000, Wen-Feng Hsiao wrote:
> 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