Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Pipeline
- {
- public static function make_pipeline($funcs)
- {
- $func_list = func_get_args();
- $result = function($arg) use ($func_list)
- {
- foreach($func_list as $funcs)
- {
- if(!isset($value))
- {
- print "set nilai!\n";
- $value = $funcs($arg);
- }else{
- print "update nilai!\n";
- $value = $funcs($value);
- }
- print "Argumen $value is: " . $value . "\n";
- }
- return $value;
- };
- return $result;
- }
- }
- $fun = Pipeline::make_pipeline(function($x) { return $x * 3; },
- function($x) { return $x + 1; },
- function($x) { return $x / 2; });
- echo $fun(3); # should print 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement