# How to lazily filter an iterator while also applying a function to it

**URL:** <https://discourse.julialang.org/t/how-to-lazily-filter-an-iterator-while-also-applying-a-function-to-it/35902>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 12, 2020, 9:45pm UTC](https://discourse.julialang.org/t/how-to-lazily-filter-an-iterator-while-also-applying-a-function-to-it/35902 "2020-03-12T21:45:24Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![jeffreyesun](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreyesun/32/13379_2.png) [@jeffreyesun](https://discourse.julialang.org/u/jeffreyesun)\
**Post date:** [March 18, 2020, 4:56pm UTC](https://discourse.julialang.org/t/how-to-lazily-filter-an-iterator-while-also-applying-a-function-to-it/35902/21 "2020-03-18T16:56:07Z")

</div>

Nonetheless, it can apparently made a difference: [See this post](https://discourse.julialang.org/t/an-assert-statement-makes-my-code-run-faster/25334). It seems that, at one point at least, the presence of an assert triggers a compiler optimization that wouldn’t be triggered otherwise.

---

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [March 18, 2020, 5:45pm UTC](https://discourse.julialang.org/t/how-to-lazily-filter-an-iterator-while-also-applying-a-function-to-it/35902/22 "2020-03-18T17:45:04Z")

</div>

Fair point. But Julia (to my knowledge) does nothing special with `@assert`, unlike assertions `myvec::Vector` etc. Afterwards, LLVM et. al. are indeed very clever sometimes… especially when you are trying to test out a trivial example!

[Previous page](https://discourse.julialang.org/t/how-to-lazily-filter-an-iterator-while-also-applying-a-function-to-it/35902.md?page=1)
