fork(1) download
  1. <?php
  2.  
  3. function add1($a) {
  4. return $a + 1;
  5. }
  6.  
  7. function mul0_5($a) {
  8. return $a * 0.5;
  9. }
  10.  
  11. function COMPOSE($f, $g) {
  12. return function() use ($f,$g) {
  13. $args = func_get_args();
  14. return $g(call_user_func_array($f, $args));
  15. };
  16. }
  17.  
  18. $compose1 = COMPOSE("add1", "mul0_5");
  19. $compose2 = COMPOSE("intval", $compose1);
  20.  
  21. printf("%f", $compose2("1"));
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
1.000000