I want to define a function over a dynamic number of variables, but find no way to coerce list, tuple or string to symbolic ring. Is there some Python / pre-parse / magic which can make this work?
A failed example follows:
sage: var( 'x1 x2 x3' )
sage: function('xxx')(x1,x2) # A function of a fixed, pre-programmed number of variables
xxx(x1, x2)
sage: n = 3
sage: ' '.join('x'+str(i+1) for i in range(n)) # A string
'x1 x2 x3'
sage: eval( ' '.join('x'+str(i+1)+',' for i in range(n)) ) # A tuple
(x1, x2, x3)
sage: function('yyy')( eval( ' '.join('x'+str(i+1)+',' for i in range(n)) ) )
Traceback (most recent call last):
...
TypeError: cannot coerce arguments: no canonical coercion from <type 'tuple'> to Symbolic Ring