I want to create a list of sine functions using a for loop where the parameters depend on a list. As a minimum working example, let us say that my list is
lst = [0, 50, 75, 83, 98, 84, 32]
I want my loop to output the following list of functions:
[0, sin(50x), sin(75x), sin(83x), sin(98x), sin(84x), sin(32x)]
Here's what I tried:
function = [];
lst = [0, 50, 75, 83, 98, 84, 32]
for m in lst:
function.append(lambda x : np.sin(m*x))
This does give me a list of 7 functions:
[<function __main__.<lambda>(x)>,
<function __main__.<lambda>(x)>,
<function __main__.<lambda>(x)>,
<function __main__.<lambda>(x)>,
<function __main__.<lambda>(x)>,
<function __main__.<lambda>(x)>,
<function __main__.<lambda>(x)>]
But when I evaluate function[0](1)
it outputs 0.5514266812416906
whereas it should be 0 (m=0 implies sin(0*x) = sin(0) = 0 for all values of x), so I am doing something wrong.