PHP code example of bermudaphp / curry
1. Go to this page and download the library: Download bermudaphp/curry library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bermudaphp / curry example snippets
$add = new Curry(static fn(int $a, $int $b) => $a+$b, 10);
// alternative
$add = curry(static fn(int $a, $int $b) => $a+$b, 10);
$add(5); // 15
// alternative
$add->call(5);
// add new arguments
$decrement = $add->add(-5);
$decrement(); // 5
// Allow default argument values
$add = curry(static fn(int $a, $int $b = 5) => $a + $b, 10)->useDefaultValues(true);
// alternative
$add = Curry::use(static fn(int $a, $int $b = 5) => $a + $b, 10)
$add() // 15