Ask Your Question
0

Function generator

asked 11 years ago

czsan gravatar image

updated 10 years ago

FrédéricC gravatar image

How can I generate a list (or array) of functions? I have a list which contains the expressions for the functions. For example: F = [x, x^2, (x-1)/x, -1/x] and I want f1(x) = F[1] f2(x) = F[2],... (In Maple there is an indexed function construction) Thanks

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 11 years ago

czsan gravatar image

it seems, in my problem the following works:

[F[i].function(x) for i in range(len(F))]

Preview: (hide)
link

Comments

No need to use indices; `[f.function(x) for f in F]` should work too.

DSM gravatar imageDSM ( 11 years ago )

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 11 years ago

Seen: 799 times

Last updated: Jan 16 '14