ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 16 Jan 2014 17:03:38 +0100Function generatorhttps://ask.sagemath.org/question/10933/function-generator/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)
ThanksThu, 16 Jan 2014 16:15:30 +0100https://ask.sagemath.org/question/10933/function-generator/Answer by czsan for <p>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</p>
https://ask.sagemath.org/question/10933/function-generator/?answer=15929#post-id-15929it seems, in my problem the following works:
[F[i].function(x) for i in range(len(F))]Thu, 16 Jan 2014 16:50:32 +0100https://ask.sagemath.org/question/10933/function-generator/?answer=15929#post-id-15929Comment by DSM for <p>it seems, in my problem the following works:</p>
<p>[F[i].function(x) for i in range(len(F))]</p>
https://ask.sagemath.org/question/10933/function-generator/?comment=16425#post-id-16425No need to use indices; `[f.function(x) for f in F]` should work too.Thu, 16 Jan 2014 17:03:38 +0100https://ask.sagemath.org/question/10933/function-generator/?comment=16425#post-id-16425