I want to create a list that contains the monomials up to degree n
basis = [lambda x:x**i for i in range(0,n+1)]
This however creates a list of n functions, but all the same one (of degree n) and not of degree 0,1,2,...n
I tried without list comprehension as well:
basis = []
for i in range(0,n+1):
basis.append(lambda x:x**i)
but with the same result. Substituting the lambda function by a classic function definition also did not fix it.
I checked Python lambdas and scoping, but that did not help, since I don't want to store function values, but the function itself. For example, I want to be able to call
basis[0](34)
and this should return
1