Ask Your Question

Function dependence flexibility

asked 2017-01-07 09:15:17 +0200

implicitnone gravatar image

I'd like to declare an unknown function f. If I had one variable x, I would write


Instead, I would like to declare this function with a variable list (or tuple) that has unknown length at the beginning of the program. For example,


has two variables or


has three.

I can get a list (or tuple) containing my variables just before the function declaration:


Then how can I declare my function like



edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-01-07 14:22:55 +0200

tmonteil gravatar image

You have to "remove the brackets" of your list, so that the input of function is not a single list of four symbols, but four symbols (note the star before vars):

sage: f=function('f')(*vars)
sage: f
f(x, y, z, t)
edit flag offensive delete link more


Thank you, that works!

implicitnone gravatar imageimplicitnone ( 2017-01-07 15:04:11 +0200 )edit

^_^ .

tmonteil gravatar imagetmonteil ( 2017-01-07 16:10:59 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-01-07 09:15:17 +0200

Seen: 499 times

Last updated: Jan 07 '17