Last active
January 3, 2019 03:40
-
-
Save irsyadrdp/25642674fcf556189fb1f188655004f0 to your computer and use it in GitHub Desktop.
Revisions
-
irsyadrdp revised this gist
Jan 3, 2019 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,8 +12,7 @@ public static function make_pipeline(...$funcs) } } $fun = Pipeline::make_pipeline(function($x) { return $x * 3; }, function($x) { return $x + 1; }, function($x) { return $x / 2; }); // Sample test case echo $fun(3); # should print 5 -
irsyadrdp revised this gist
Jan 3, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ public static function make_pipeline(...$funcs) { return function($arg) use ($funcs) { // Call each function in loop foreach($funcs as $func) (!isset($param)) ? $param = $func($arg) : $param = $func($param); return $param; }; -
irsyadrdp created this gist
Jan 3, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <?php class Pipeline { public static function make_pipeline(...$funcs) { return function($arg) use ($funcs) { // Call each function in loop foreach($funcs as $func) (!isset($param)) ? $param = $func($arg) : $param = $func($param); return $param; }; } } $fun = Pipeline::make_pipeline(function($x) { return $x * 3; }, function($x) { return $x + 1; }, function($x) { return $x / 2; }); // Sample test case echo $fun(3); # should print 5