matteosister / php-curry

Curried functions for PHP
61 stars 1 forks source link

Implementation of a fixed number of argument for curry #10

Closed jasny closed 1 year ago

jasny commented 6 years ago

The curry_fixed and curry_right_fixed methods are never implemented.

Rather than adding more functions, passing an integer as first arg specifies the number arguments.

$divider = function ($a, $b, $c = 1) {
    return $a / ($b * $c);
};

$divide10ByProduct = C\curry(2, $divider, 10);
$divideByTripple = C\curry(2, $divider, 3);
$divideBy200 = C\curry_right(1, $divider, 10, 20);

This PR includes #9