# Introduce lazy version of compactMap

**URL:** <https://forums.swift.org/t/introduce-lazy-version-of-compactmap/9835>\
**Category:** Pitches\
**Created:** [February 12, 2018, 6:12pm UTC](https://forums.swift.org/t/introduce-lazy-version-of-compactmap/9835 "2018-02-12T18:12:22Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![TellowKrinkle](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tellowkrinkle/32/3370_2.png) [@TellowKrinkle](https://forums.swift.org/u/TellowKrinkle)\
**Post date:** [March 20, 2018, 12:59am UTC](https://forums.swift.org/t/introduce-lazy-version-of-compactmap/9835/12 "2018-03-20T00:59:41Z")

</div>

Dropping `LazyMap` would lose its O(1) count (and its nonzero `underestimatedCount`) which might not be preferable, but dropping `LazyFilter` would probably make sense. The only thing that `LazyFilter` does that `LazyCompactMap` doesn't is the check in `_customContainsEquatableElement` that checks whether or not the element matches the predicate before actually searching the collection. I don't know much that helps things but as long as you think losing that is fine that I'm happy to try the removal.

---

_[View the full topic](https://forums.swift.org/t/introduce-lazy-version-of-compactmap/9835)._
