daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Pipeline
  3. {
  4.     public static function make_pipeline(...$funcs)
  5.     {
  6.         return function($arg) use ($funcs)
  7.         {
  8.             $value = $arg;
  9.             foreach($funcs as $f) {
  10.                 $value = $f($value);
  11.             }
  12.             return $value;
  13.         };
  14.     }
  15. }
  16. $fun = Pipeline::make_pipeline(function($x) { return $x * 3; }, function($x) { return $x + 1; },
  17.                           function($x) { return $x / 2; });
  18. echo $fun(3);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top