-2

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.

Ethan
  • 152

1 Answers1

2

You might try this.

Iter:= combinat:-cartprod([[$0..p-1]$n]):
[seq(Iter:-nextvalue(),i=1..p^n)];
Robert Israel
  • 448,999