-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
prod()
over zero-length tuple generator should just return 1
?
#40160
Comments
The difficulty with this is that without any elements, we don't know what the domain is, so we don't know if (We have |
Is prod(i for i in Int[]) === 1
prod(i for i in Float64[]) === 1.0 but tuples start to make a difference between collect(i for (i,j) in NTuple{2, Int}[]) == Int[]
collect(j for (i,j) in Tuple{Int, Float64}[]) == Float64[]
prod(i for (i,j) in NTuple{2, Int}[]) ## Error Thanks, anyways, I can definitely live with the current behavior, I just wondered if this is intended or just hard to solve case. |
For products and sums, I feel like using |
Not exactly, we just have some special cases for the |
similar to #36262 we have |
Hello,
This might be related to #28028, #36262 and similar issues.
Observing the following statements:
I can't really say where this goes wrong, whether it is in the zip generator or in the reduction in
prod()
.The following "identity" function
id(n)
evaluates for all integers except 1:Of course such functions could check for cases where
n==1
but that is somewhat clumsy, I think. My actual use is in a function computing the sum of the divisors of a positive natural number:The text was updated successfully, but these errors were encountered: