-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
map! only works on AbstractArray #38344
Comments
True: seems like only the output array needs to be restricted to |
Stumbled upon the same issue and wondered why function Base.map!(f, b::AbstractArray, a...)
for (i,v) in enumerate(zip(a...))
b[i] = f(v...)
end
end |
I wouldn't use |
The current N-source implementation for Extending the type of the sources to be Doing a very simple version that captures remaining cases, and only requires the sources to be iterable is a lot slower. function map!(f::F, dest::AbstractArray, As...) where {F}
isempty(As) && throw(ArgumentError(
"""map! requires at least one "source" argument"""))
for (i,v) in zip(eachindex(dest), zip(As...))
dest[i] = f(v...)
end
end I don't know if it is preferable to just to have something simple to catch remaining cases, and then add more specialized methods for specific types when needed, or if is it preferable to skip it to avoid a slow path. |
Any reason for restricting the signature of
map!
toAbstractArray
? I don't see why this shouldn't work:The text was updated successfully, but these errors were encountered: