/** * @param Iterator $iterator * @param callable $fn($key, $value) * @return Sequence */ public static function filterKeys(Iterator $iterator, $fn) { return Sequence::make(new FilteredSequence($iterator, FnGen::fnSwapParamsPassThrough($fn))); }
/** * Returns the key of the first element where $fnTest returns true. * * @param callable|null $fnTest($value, $key) * @return mixed */ public function firstKey($fnTest = null) { $fnTest = $fnTest ?: fn\fnTrue(); return $this->filter($fnTest)->limit(1)->keys()->reduce(null, FnGen::fnSwapParamsPassThrough(FnGen::fnIdentity())); }