J*****n 发帖数: 4859 | 1 Not quite familar with C#, so I would like to express it in C++ term.
I have a list of function ptrs, which all take one parameter.
I have a function f, which have 2 parameters, assume f(x, y).
Is there any way I can insert f(x, 1) as a single variable function in above
list?
Thank you. | m*******l 发帖数: 12782 | 2 i think closure/lambda should work
above
【在 J*****n 的大作中提到】 : Not quite familar with C#, so I would like to express it in C++ term. : I have a list of function ptrs, which all take one parameter. : I have a function f, which have 2 parameters, assume f(x, y). : Is there any way I can insert f(x, 1) as a single variable function in above : list? : Thank you.
| g****r 发帖数: 1589 | 3 I think curring is not supported out of box, but you can write a lamada to
convert it to a single parameter function as (x)=>f(x,1);
above
【在 J*****n 的大作中提到】 : Not quite familar with C#, so I would like to express it in C++ term. : I have a list of function ptrs, which all take one parameter. : I have a function f, which have 2 parameters, assume f(x, y). : Is there any way I can insert f(x, 1) as a single variable function in above : list? : Thank you.
| s***o 发帖数: 2191 | 4 yes currying or partial function. Jon Skeet has a wonderful post on this
topic:
http://msmvps.com/blogs/jon_skeet/archive/2012/01/30/currying-v
【在 g****r 的大作中提到】 : I think curring is not supported out of box, but you can write a lamada to : convert it to a single parameter function as (x)=>f(x,1); : : above
|
|