Skip to content

Conversation

@datokrat
Copy link
Contributor

This PR provides the iterator combinator filterMap in a pure and monadic version and specializations map and filter. This new combinator allows to apply a function to the emitted values of a stream while filtering out certain elements.

map should have an optimized IteratorCollect implementation but it turns out that this is not possible without a major refactor of IteratorCollect: toArrayMapped requires a proof that the iterator is finite. If it.mapM f is Finite but it is not, then such a proof does not exist. IteratorCollect needs to take a proof that the loop will terminate for the given monadic function f instead. This will not be done in this PR.

@datokrat datokrat added the changelog-library Library label May 23, 2025
@datokrat datokrat force-pushed the paul/iterators/6 branch from 1a11672 to 4d2728c Compare May 23, 2025 14:30
@datokrat datokrat force-pushed the paul/iterators/5-for-6 branch from f7ec109 to 19556b4 Compare May 23, 2025 14:30
@datokrat datokrat force-pushed the paul/iterators/6 branch 2 times, most recently from 1ee7dfb to 42a4907 Compare May 26, 2025 07:24
@datokrat datokrat force-pushed the paul/iterators/5-for-6 branch from 920f8c1 to a12f89a Compare May 30, 2025 12:54
@datokrat datokrat force-pushed the paul/iterators/6 branch from 5aaa1a5 to ce3ed9e Compare May 30, 2025 12:54
@datokrat datokrat changed the base branch from paul/iterators/5-for-6 to master May 30, 2025 13:01
@datokrat datokrat marked this pull request as ready for review May 30, 2025 13:03
@datokrat datokrat requested a review from TwoFX as a code owner May 30, 2025 13:03
@datokrat datokrat added this pull request to the merge queue May 30, 2025
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label May 30, 2025
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase a12f89aefa10812fda01275d87bfc18d97914899 --onto 72141b05fd9a3328c1e5d99211dc4da4495cbd42. You can force Mathlib CI using the force-mathlib-ci label. (2025-05-30 13:48:00)

Merged via the queue into master with commit 90462e2 May 30, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants