title: Maple - How to make a loop of 4 variables suitable for an array
body: <p>Say I have two lists:
      M=(0,1,2,3) and N=(0,2,4,6)</p>
  
  <pre><code>And I wish to put into a list all the combinations of Mi,Mj,Ns,Nt (where i,j,s,t are       subscripts so for i=1 M=0, i=2 M=1 etc.) such that:
  
  C = a^(Mi+Mj) + b^(Ns+Nj)
  
  First in the list would be
  C = a^(0+0) + b^(0+0)
  C = a^(1+0) + b^(0+0)
  C = a^(1+0) + b^(2+0)
  </code></pre>
  
  <p>Is there a neater way of writing this out than using the 'for' clause 4 times?</p>
  
  <pre><code>for i from 1 to 4 do
  for j from 1 to 4 do
  for s from 1 to 4 do
  for t from 1 to 4 do
  
  C = a^(Mi+Mj) + b^(Ns+Nj)
  
  end do;
  end do;
  end do;
  end do;
  </code></pre>
  
  <p>I will be putting it into an array, but I want to limit the recursion because maple doesn't like it! Is it possible to put this into a 2x2 array with 4 variables?</p>
  
  <p>I considered making 2 lists of all the combinations of Mi+Mj and all the combinations of Ns+Nt then putting those together in an array, but it comes out similar to what I want, yet not quite right.</p>