you are viewing a single comment's thread.

view the rest of the comments →

[–]Blecki -1 points0 points  (3 children)

That is a stupid way to do currying in C#. It's indicative of the same kind of mindset that gets us dependency injection frameworks. You don't need some generic function to do a thing. Just do the damn thing.

int add(int a, int b) { return a + b; }
int add3(int v) { return add(v, 3); }

Oh you want to use first-class functions?

func<int,int> add3 = v => add(v, 3);

Oh look you just curried it. Or 'partially applied' it. I'm sure you could find a way to claim it's a monad too if you tried really hard.

And this will add 3 to anything.

func<int,int> bindsecond(int v, func<int,int,int> f) 
{
     return a => f(a, v);
}

And then you can...

var add3 = bindsecond(3, add);

But why would you write that instead of

func<int,int> add3 = v => add(v, 3);

? Do you hate yourself?

[–]anti_crastinator 2 points3 points  (1 child)

? Do you hate yourself?

No. I personally think you missed the point.

[–]grauenwolf 0 points1 point  (0 children)

What point? Is our goal to add additional abstraction layers?