Generating all tuples in $Zp^n$ using Maple

66 Views Asked by At

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.

1

There are 1 best solutions below

0
On

You might try this.

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