public static function partition($n, $coll)
    {
        $coll = self::iterator($coll);
        for ($coll->rewind(); $coll->valid();) {
            $partition = [];
            for ($i = 0; $i < $n && $coll->valid(); ++$i, $coll->next()) {
                $partition[] = $coll->current();
            }
            yield $partition;
        }
    }