Partial Function Application
modernescpp.com
modernescpp.com
double divMe(double a, double b){
return double(a/b);
}
The "return double(a/b)" is excessive, right? Returning a/b has the same effect, and I'd expect they compile to the exact same thing in this particular case.Is there a reason to prefer the extra verbose version?
The excessive redundancy irks the perfectionist in me.
I don't think I have actually used them in years. Even though they can be succinct, they have some sharp corners and a non-trivial compilation time cost. In practice lambdas are good enough in almost all cases.
f x
has a single argument, even if x is (a, b)
f a b would then be equivalent to (f a) b such that (f a) evaluates to a new function which takes a single argument.
'curry' and 'uncurry' allow to go to and from this way of handling arguments instead of using tuples. But tuples are also a single value, and this is actually very important - you won't be able to change a single 'argument' without creating a new pair, for example. There is no way to have a real multi argument function.