Closed Smoren closed 6 months ago
Seems equivalent to https://github.com/nikic/iter !
@llaville, thanks for feedback!
PHP iterTools is similar to iter but not equivalent because it provides a lot more functionality. Please look at the documentation in the README of the project.
Moreover, it provides fluent interface to make chain operations on iterables (Stream class):
$result = Stream::of([1, 1, 2, 2, 3, 4, 5])
->distinct() // [1, 2, 3, 4, 5]
->map(fn ($x) => $x**2) // [1, 4, 9, 16, 25]
->filter(fn ($x) => $x < 10) // [1, 4, 9]
->toSum(); // 14
Here is a comparison:
@Smoren thanks for compare report
BTW, IterTools PHP is mentioned in PHP Annotated February 2023 by JetBrains.
@ziadoz thank you for merging this PR!
Added IterTools PHP - A library that provides functionality for working with iterable entities (similar to itertools library in Python).