What are some suggestions on how I could most efficiently generate a list of all tuples in $\mathbb{Z}_p^n$? (For example, for $p=n=2$, $\{[0,0],[0,1],[1,0],[1,1]\}$). I can get this to work for a fixed $n$ value by using the $seq$ function, but I cannot think of a good way to do so when the value of $n$ is defined as a variable.
Asked
Active
Viewed 65 times
-2
-
A quick Google search returned a Maple procedure. – Somos Feb 01 '22 at 20:21
1 Answers
2
You might try this.
Iter:= combinat:-cartprod([[$0..p-1]$n]):
[seq(Iter:-nextvalue(),i=1..p^n)];
Robert Israel
- 448,999