1 | initial version |
There is not much to adapt to get what you want.
Regarding the underscores, just use a different string to format.
Also, no need to use str(...)
with .format
string formatting, it comes for free.
If you know you always expect 10 entries from 0 to 9 in some order:
def p(t):
return SR.var('p_{}{}{}{}{}_{}{}{}{}{}'.format(*t))
Usage:
sage: p((2, 4, 1, 3, 9, 8, 0, 9, 6, 1))
p_24139_80961
The double parentheses can be avoided using *args
.
def p(*t):
return SR.var('p_{}{}{}{}{}_{}{}{}{}{}'.format(*t))
Usage:
sage: p(2, 4, 1, 3, 9, 8, 0, 9, 6, 1)
p_24139_80961
Summing:
sage: sum(p(2, 4, 1, 3, 9, 8, 0, 9, j, 1) for j in (0 .. 9))
p_24139_80901 + p_24139_80911 + p_24139_80921 + p_24139_80931
+ p_24139_80941 + p_24139_80951 + p_24139_80961
+ p_24139_80971 + p_24139_80981 + p_24139_80991