Re:PHP Pipes in 156 Bytes
by mkdirp on Thursday March 03, 2022 @10:59AM
(#30542651)
That's what I was wondering too, especially considering there is a helper function that just wraps it. Seems rather unnecessary.
Works just as well.
[ Parent
| on HN ]
Passing the first argument as part of the variadic array isn't necessary.
Here's my version in only 66 bytes, what do I win? ;)
<?php function pipe($v,...$p){foreach($p as$f)$v=$f($v);return$v;}64! (if you don't mind calling a variable).
<?php $pipe=fn($v,...$p)=>array_reduce($p,fn($a,$f)=>$f($a),$v);