Hacker News new | past | comments | ask | show | jobs | submit login

Here is curry in php 5.3

  function curry(){
    $args = func_get_args();
    $fn = array_shift($args);
    return function() use(&$fn, &$args) {
        $nargs = func_get_args();
        foreach($nargs as $narg) $args[] = $narg;
        return call_user_func_array($fn, $args);
    };
  }

  $add20 = curry(function($a, $b){return $a + $b;}, 20);

  echo $add20(5); #25



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: