title: php advanced functional programming - creating a curry method similar to ramdaJS
body: <p>Requirements: </p>
  
  <ol>
  <li>place holder support</li>
  <li>partial applied functions can be applied to partially applied functions</li>
  <li>currying</li>
  <li>5.6 PHP support</li>
  </ol>
  
  <p>here is my attempt however it only supports hhvm 3.7 as you can see in the example on <a href="http://3v4l.org/0i5FV" rel="nofollow">http://3v4l.org/0i5FV</a></p>
  
  <pre><code>&lt;?php 
  class Placeholder{}
  function curry(callable $func, ... $curriedArgs) {
      return function(...$fulfillment) use ($func, $curriedArgs) {
          $removedPlaceheldArgs = array_map(function($arg) use ($fulfillment) {
              if ($arg instanceof Placeholder)
                  return array_shift($fulfillment);
              return $arg;
          }, $curriedArgs);
          return $func(...array_merge($removedPlaceheldArgs, $fulfillment));
      };
  };
  </code></pre>
  
  <p>here is an example of my usage: </p>
  
  <pre><code>$resultset = json_decode('[{
    "id": 1,
    "gender": "Male",
    "name": "Matthew"
  }, {
    "id": 2,
    "gender": "Male",
    "name": "Willie"
  }, {
    "id": 3,
    "gender": "Female",
    "name": "Ann"
  }, {
    "id": 4,
    "gender": "Female",
    "name": "Margaret"
  }, {
    "id": 5,
    "gender": "Female",
    "name": "Marie"
  }]',TRUE);
  
  $filterGender = function($row,$gender){
      return $row['gender']==$gender;
  };
  
  $detectMen = curry($filterGender,(new Placeholder),'Male');
  $detectWomen = curry($filterGender,(new Placeholder),'Female');
  
  var_dump($detectMen(['gender'=&gt;'Male'])); //works -- expected result TRUE
  
  $getLadies = curry('array_filter',(new Placeholder),$detectWomen);
  
  var_dump($getLadies($resultset)); //does not work -- expected result Ladies from result set
  </code></pre>
  
  <p>can the $getLadies result be achieved in PHP 5.6 instead of just hhvm? </p>