Ask Your Question
1

Function dependence flexibility

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

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 14:22:55 +0100

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 15:04:11 +0100 )edit

^_^ .

tmonteil gravatar imagetmonteil ( 2017-01-07 16:10:59 +0100 )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 09:15:17 +0100

Seen: 686 times

Last updated: Jan 07 '17