Skip to content

Commit

Permalink
Fix bug with Partition operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jul 16, 2021
1 parent 94476e2 commit e44d50b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public function partition(callable ...$callbacks): CollectionInterface
return new self(
Pipe::of()(
Partition::of()(...$callbacks),
Map::of()(static fn (Iterator $iterator): CollectionInterface => self::fromIterable($iterator))
Map::of()(static fn (array $callUserFuncParameters): CollectionInterface => self::fromCallable(...$callUserFuncParameters)),
),
$this->getIterator()
);
Expand Down
12 changes: 4 additions & 8 deletions src/Operation/Partition.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@ public function __invoke(): Closure
*
* @return Generator<int, Iterator<TKey, T>>
*/
static function (Iterator $iterator) use ($callbacks): Iterator {
/** @var Iterator<TKey, T> $filter */
$filter = Filter::of()(...$callbacks)($iterator);
/** @var Iterator<TKey, T> $reject */
$reject = Reject::of()(...$callbacks)($iterator);

return yield from [$filter, $reject];
};
static fn (Iterator $iterator): Generator => yield from [
[Filter::of()(...$callbacks), $iterator],
[Reject::of()(...$callbacks), $iterator],
];
}
}

0 comments on commit e44d50b

Please sign in to comment.