Fix a number of arguments to a function producing another one with an smaller arity.
If not arguments are present, it returns the same $fn
- fn
- Function to be biased.
- args
- Arguments to fix to the function.
Add 5 to another number:
<?php
use function Lambdish\Phunctional\partial;
$sum = function($a, $b) {
return $a + $b;
};
$add5 = partial($sum, 5);
$add5(10);
// => 15
$add5(3);
// => 8