src/main/php/Collectors.php
public function inPartitions(callable $predicate, Collector $base = null): array
    {
        $collector = (null === $base) ? Collector::forList() : $base;
        return $this->with(
                function() use($collector)
                {
                    return [true  => $collector->fork(),
                            false => $collector->fork()
                    ];
                },
                function(&$partitions, $element, $key) use($predicate)
                {
                    $partitions[$predicate($element)]->accumulate($element, $key);
                },
                function($partitions)
                {
                    return [true  => $partitions[true]->finish(),
                            false => $partitions[false]->finish()
                    ];
                }
        );
    }
public function inPartitions(callable $predicate, Collector $base = null): array
    {
        $collector = (null === $base) ? Collector::forList() : $base;
        return $this->with(
                function() use($collector)
                {
                    return [true  => $collector->fork(),
                            false => $collector->fork()
                    ];
                },
                function(&$partitions, $element, $key) use($predicate)
                {
                    $partitions[$predicate($element)]->accumulate($element, $key);
                },
                function($partitions)
                {
                    return [true  => $partitions[true]->finish(),
                            false => $partitions[false]->finish()
                    ];
                }
        );
    }
public function inPartitions ( callable $ predicate , Collector $ base = null ) : array { $ collector = ( null === $ base ) ? Collector :: forList ( ) : $ base ; return $ this -> with ( function ( ) use ( $ collector ) { return [ true => $ collector -> fork ( ) , false => $ collector -> fork ( ) ] ; } , function ( & $ partitions , $ element , $ key ) use ( $ predicate ) { $ partitions [ $ predicate ( $ element ) ] -> accumulate ( $ element , $ key ) ; } , function ( $ partitions ) { return [ true => $ partitions [ true ] -> finish ( ) , false => $ partitions [ false ] -> finish ( ) ] ; } ) ; }
creates collector which groups the elements in two partitions according to given predicate

@api
@param   callable                      $predicate  function to evaluate in which partition an element belongs
@param   \stubbles\sequence\Collector  $base       optional  defaults to Collector::forList()
@return  array
creates collector which groups the elements in two partitions according to given predicate