# Standard way to get first element of iterator satisfying predicate

**URL:** https://discourse.julialang.org/t/standard-way-to-get-first-element-of-iterator-satisfying-predicate/25038
**Category:** New to Julia
**Created:** [June 7, 2019, 10:05am UTC](https://discourse.julialang.org/t/standard-way-to-get-first-element-of-iterator-satisfying-predicate/25038 "2019-06-07T10:05:01Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)
#### Post date: [June 13, 2020, 11:20pm UTC](https://discourse.julialang.org/t/standard-way-to-get-first-element-of-iterator-satisfying-predicate/25038/12 "2020-06-13T23:20:54Z")

</div>

You could use `filter` instead of `Iterators.filter`, but the first one allocates a new array, which will be very inefficient. The `Iterators` submodule provides different lazy iterators, which can be more efficient in some situations than working with arrays.

---

_[View the full topic](https://discourse.julialang.org/t/standard-way-to-get-first-element-of-iterator-satisfying-predicate/25038)._
