Download the PHP package phpfn/curry without Composer
On this page you can find all versions of the php package phpfn/curry. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package curry
Short Description Convenient implementation of function currying and partial application
License MIT
Homepage https://github.com/phpfn
Informations about the package curry
Curry
Convenient implementation of function currying and partial application.
- Installation
- Usage
- Left currying
- Right currying
- Partial application
- Api
- Functions
- Methods of the curried function
Installation
Library can be installed into any PHP application:
In order to access library make sure to include vendor/autoload.php
in your file.
Usage
Left currying
The left currying can be perceived as adding arguments to an array. And then applying this array of arguments to the function.
The left currying returns the partially applied function from the first argument.
Right currying
At the same time, right-hand currying can be perceived as adding arguments to the right.
Partial application
Partial application is when you can specify completely
random arguments, skipping unnecessary using placeholder _
.
Api
Functions
-
lcurry(callable $fn, ...$args): Curried
orcurry
Left currying (like array_push arguments)
-
rcurry(callable $fn, ...$args): Curried
Right currying
uncurry(callable $fn): mixed
Returns result or partially applied function
Curried
-
$fn->__invoke(...$args)
or$fn(...$args)
The magic method that allows an object to a callable type
-
$fn->lcurry(...$args)
A method that returns a new function with left currying
-
$fn->rcurry(...$args)
A method that returns a new function with right currying
-
$fn->reduce()
Reduction of the composition of functions. Those. bringing the function to a single value - the result of this function.
-
$fn->uncurry()
An attempt is made to reduce, or bring the function to another, which will return the result
$fn->__toString()
Just a function dump