Slide 48
Slide 48 text
Abstract away the loop!
$collection = new Collection([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
print $collection
->filter(function ($x) { return $x % 2 == 0; })
->map(function ($x) { return $x * $x; })
->reduce(function($x, $y) { return $x + $y; });
use bbujisic\functional\Collection;
composer require bbujisic/functional
reduce
filter
map