Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

creating a group of similar functions with similar names

namelist = ['f'+str(i) for i in range(10)]; namelist
for i in range(len(namelist)):
    namelist[i] = lambda x: 1/x^i

1 - create a list of function names (f0, f1, f2, ...)

2 - for each item in namelist

3 - take that that item and make it a function that raises x to a negative power equal to the position of that item (f0(x) = 1/x^0, f1(x) = 1/x^1, ...)

Is this possible?

creating a group of similar functions with similar names

namelist = ['f'+str(i) for i in range(10)]; namelist
for i in range(len(namelist)):
    namelist[i] = lambda x: 1/x^i

1 - create a list of function names (f0, f1, f2, ...)

2 - for each item in namelist

3 - take that that item and make it a function that raises x to a negative power equal to the position of that item (f0(x) = 1/x^0, f1(x) = 1/x^1, ...)

Is this possible?

EDIT:

Made some progress by changing the type of namelist[i] to Expression by var(i)...