Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reverse(zip(its...)) now checks lengths of constituent iterators for equality #50435

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add comments
  • Loading branch information
adienes committed Oct 5, 2023
commit 06b3af43a94d8cfd14face781dcabaa9752a9f02
8 changes: 7 additions & 1 deletion base/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,18 @@ function _zip_min_length(is)
end
end
_zip_min_length(is::Tuple{}) = nothing

# For a collection of iterators `is`, returns a tuple (b, n), where
# `b` is true when every component of `is` has a statically-known finite
# length and all such lengths are equal. Otherwise, `b` is false.
# `n` is an implementation detail, and will be the `length` of the first
# iterator if it is statically-known and finite. Otherwise, `n` is `nothing`.
function _zip_lengths_finite_equal(is)
i = is[1]
b, n = _zip_lengths_finite_equal(tail(is))
if IteratorSize(i) isa Union{IsInfinite, SizeUnknown}
return (false, nothing)
else
b, n = _zip_lengths_finite_equal(tail(is))
return (b && (n === nothing || n == length(i)), length(i))
end
end
Expand Down