-
-
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
Document function argument for prod #19146
Comments
Now that we have generators, maybe we could just deprecate those methods. |
+1000 to removing these kinds of pre-composed generator + function patterns |
function-first does allow do-block notation, is that doable with generators? |
I find the generator syntax more readable than a do-block with function-first. |
+1 for generators. In the rare occasions where your function definition is so big that a |
julia> methods(prod)
# 6 methods for generic function "prod":
prod(x::Tuple{}) at tuple.jl:222
prod(x::Tuple{Any,Vararg{Any,N<:Any}}) at tuple.jl:223
prod(f::Function, A::AbstractArray, region) at reducedim.jl:291
prod(f::Union{DataType,Function}, a) at reduce.jl:400
prod(A::AbstractArray, region) at reducedim.jl:293
prod(a) at reduce.jl:407 The third and fourth methods listed are the ones you want. |
@ararslan The issue is that it's not documented. |
I changed the title to reflect that concern. Care to make a PR to fix this? |
Deprecation in favor of generators seems like the better approach here. |
Why can't both methods exist? |
They can. I have to say that writing things like |
Ok, to flip sides again: the definition of |
@StefanKarpinski What about |
Yes, I considered that but it's inefficient since it materializes the array of lengths. The |
Sorry, |
Ref. discussion around #16285 (comment) (generalizing compact broadcast syntax to compact higher-order function syntax, relevant given the behavior mentioned above is |
sum
andmean
both can take a function argument to apply to elements before summing or averaging, and this is documented:But
?prod
doesn't show the method that takes a function argument.The text was updated successfully, but these errors were encountered: