composer require michaelpetri/php-generic-list
ImmutableList::of(1, 2, 3, 4, 5)
->filter(
static fn(int $i): bool => 0 === $i % 2
)
->map(
static fn(int $i): int => 2 ** $i
)
->with(
32
)
->with(
32
)
->unique()
->each(
static function (int $i): void { sprintf("\d\n", $i) }
)
// Output:
// 4
// 16
// 32
map
filter
each
toArray