Reputation: 69
constraint_condition = [lambda x: [x[0], x[1]]]
mid.gen_answer(constraint_ueq)
In codes above, mid
is a class, and the method gen_answer
is calling a function from another python package which requires n-dimension input written in this format:
lambda x:[x[0],x[1],...x[n]]
How do I create lambda function and fill these paramters automatically? For example I want a 4-dimension input, I shall be writing this by my hand like this:
lambda x:[x[0],x[1],x[2],x[3]]
, but what if there are more dimensions(like 12)? There is a way to let python write these (x[1],x[2]...
) for me?
Upvotes: 0
Views: 63
Reputation: 69
Guy, I solved this by using lambda x:[sub_x for sub_x in x[:n]]
. Thx for your help
Upvotes: 1