ailixter / gears-pipeline
为管道齿轮的项目。
dev-master
2019-09-07 18:55 UTC
Requires
- php: ^7.1
This package is auto-updated.
Last update: 2024-09-08 06:00:32 UTC
README
为管道齿轮的项目。
它在一个迭代器(迭代器、生成器、数组)上运行处理链。处理过程内存效率高,不使用中间数组。
echo PipelinedIteration::over( [1, 2], [3, 4], [5, 6], [7, 8] ) ->map(function ($a, $b, $c, $d) { return [$a + $b, $c + $d]; }) ->reduce(function ($r, $x, $y) { return $r += $x * $y; }) ->getResult(); // 132
实现的处理程序
map(callable)
filter(callable)
reduce(callable, mixed = 0)
find(callable)
some(callable)
every(callable)