diff --git a/NEWS.md b/NEWS.md index c13a9d0b65823..f4c642774d0d2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -36,6 +36,8 @@ Build system changes New library functions --------------------- +* `Iterators.flatmap` was added ([#44792]). + Library changes --------------- diff --git a/base/iterators.jl b/base/iterators.jl index ccb910afa5758..2702375d0f630 100644 --- a/base/iterators.jl +++ b/base/iterators.jl @@ -1167,6 +1167,11 @@ last(f::Flatten) = last(last(f.it)) Equivalent to `flatten(map(f, iterators...))`. +See also [`Iterators.flatten`](@ref), [`Iterators.map`](@ref). + +!!! compat "Julia 1.9" + This function was added in Julia 1.9. + # Examples ```jldoctest julia> Iterators.flatmap(n->-n:2:n, 1:3) |> collect @@ -1182,7 +1187,6 @@ julia> Iterators.flatmap(n->-n:2:n, 1:3) |> collect 3 ``` """ -# flatmap = flatten ∘ map flatmap(f, c...) = flatten(map(f, c...)) """ diff --git a/doc/src/base/iterators.md b/doc/src/base/iterators.md index 8afc54b3bd11b..1c4831e52bc14 100644 --- a/doc/src/base/iterators.md +++ b/doc/src/base/iterators.md @@ -14,6 +14,7 @@ Base.Iterators.cycle Base.Iterators.repeated Base.Iterators.product Base.Iterators.flatten +Base.Iterators.flatmap Base.Iterators.partition Base.Iterators.map Base.Iterators.filter