PHP code example of srph / compose
1. Go to this page and download the library: Download srph/compose 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/ */
srph / compose example snippets
$square = function($n) {
return $n * $n;
}
$pow = function($exponent) {
return function($n) use ($exponent) {
for (;$exponent--;) {
$n .= $n;
}
return $n;
}
}
$input = 2;
$f = compose($square, $pow(3), $square);
$f($input); // 4096
diff
- $h($g($f($x)))
+ compose($h, $g, $f)(x);