Ask Your Question
1

Function dependence flexibility

asked 2017-01-07 02:15:17 -0500

implicitnone gravatar image

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

f=function('f')(x)

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,

f=function('f')(x,y)

has two variables or

f=function('f')(x,y,t)

has three.

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

vars=[x,y,z,t]

Then how can I declare my function like

f=function('f')(vars)

?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-01-07 07:22:55 -0500

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

Comments

Thank you, that works!

implicitnone gravatar imageimplicitnone ( 2017-01-07 08:04:11 -0500 )edit

^_^ .

tmonteil gravatar imagetmonteil ( 2017-01-07 09:10:59 -0500 )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

Stats

Asked: 2017-01-07 02:15:17 -0500

Seen: 35 times

Last updated: Jan 07