Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
13
Task/First-class-functions/PHP/first-class-functions.php
Normal file
13
Task/First-class-functions/PHP/first-class-functions.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
$compose = function ($f, $g) {
|
||||
return function ($x) use ($f, $g) {
|
||||
return $f($g($x));
|
||||
};
|
||||
};
|
||||
|
||||
$fn = array('sin', 'cos', function ($x) { return pow($x, 3); });
|
||||
$inv = array('asin', 'acos', function ($x) { return pow($x, 1/3); });
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$f = $compose($inv[$i], $fn[$i]);
|
||||
echo $f(0.5), PHP_EOL;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue