1
$\begingroup$

I want do something for all subsets J of a certain cardinality of {1,2,...,n}, for a (previously declared) number n. It seems magma is not happy with:

for J in PowerSet([1..n]) do

To which MAGMA responds:

for J in PowerSet([1..n]) do; ^ Runtime error in for: Iteration is not possible over this object

Is it really impossible to iterate over power sets? Or do I just need a small change? Any suggestions on how to solve this would be appreciated.

  • 1
    You want to use `Subsets({1..n})` ...2012-10-05

1 Answers 1

3

To construct a set of all subsets of $\{1,\ldots,n\}$ of size $k$, use the command Subsets({1..n},k). You can iterate over this.

Example: go to http://magma.maths.usyd.edu.au/calc/ and run for x in Subsets({1..4},2) do Random(x); end for;