title: Taking 3 or more combinations using `combinations`
body: <p>The following is a bit of code I wrote in Sage to compute the dimensions of certain Lie algebras that are equal to $p^2$ for some $p$. </p>
  
  <pre><code>def A_comb2rep(p):
      bound = p*p
      name_fund = []
      name_comb = []
      A = lambda i: WeylCharacterRing("A{0}".format(i))
      for i in range(bound):
          for k in range(1,bound+1):
              fw = A(i+1).fundamental_weights()
              if A(i+1)(k * fw[1]).degree() &gt; bound:
                  break
              else:
                  for v in fw:
                      if A(i+1)(k * v).degree() == bound:
                          name_fund.append([])
                          name_fund[len(name_fund)-1].append('A'+str(i+1)+'('+str(k)+'*'+str(v)+')')
      for i in range(1,bound): # now onto combinations of two of the fws   #####
          fw = A(i+1).fundamental_weights()
          for k in fw:
              if A(i+1)(fw[1] + fw[2]).degree() &gt; bound:
                  break
              else:
                  for j in fw:
                      rep = A(i+1)(j+k)
                      deg = rep.degree()
                      if deg == bound:
                          name_comb.append([])
                          name_comb[len(name_comb)-1].append('A'+str(i+1)+'['+str(j)+'+'+str(k)+']')
      return name_comb, name_fund
  </code></pre>
  
  <p>The second half of the code is where I consider combinations of two fundamental weights. I am now wondering how to extend this for combinations of 3 or more fundamental weights using the <code>combination</code> function in the iterables module. </p>
  
  <p>More specifically, how would I code in a sum of 3 of the elements of <code>fw</code>? I know that <code>v = combinations(fw, 3)</code> would then put into <code>v</code> all ${n \choose 3}$ triple combinations, but the elements of <code>fw</code> are tuples, like <code>(1,1,1,0,0,0)</code>. How would I then sum each of the triples I get in <code>v</code>? I apologize if this question is inappropriate for this site. </p>