# Revision history [back]

You could define a function or use a list comprehension to do this. Both rely on using string formatting to convert integers into strings for the WeylCharacterRing constructor.

Here's an example using list comprehension: I add an empty string '' at the beginning of the list to fix indexing, because lists in Sage are always indexed starting with 0, so you would want B[1] to be the second element in the list, etc.

sage: B = ['']+[WeylCharacterRing("B{0}".format(i)) for i in range(1,5)]
sage: B[1]
The Weyl Character Ring of Type ['B', 1] with Integer Ring coefficients
sage: B[1](1)
B1(0)
sage: B[1](1).degree()
1
sage: B[4](1,1,1,1).degree()
126


And here's a different way you could do this, using a lambda function:

sage: B = lambda i: WeylCharacterRing("B{0}".format(i))
sage: B(2)
The Weyl Character Ring of Type ['B', 2] with Integer Ring coefficients


You can automate lots more things by defining more functions and, if you eventually need to, a new object class!