map! seems to work:
a = [collect(1:3)..., -Inf, Inf, NaN]
map!(x -> 0 <= x <= 10 ? x : 0.0, a, a)
Is it allowed?
Assuming that it is, I made a pull request: https://github.com/JuliaLang/julia/pull/37792.
I would have been surprised if it didn’t work.
map!(f, dest, src) is just:
for i in eachindex(src)
dest[i] = f(src[i])
AFAIK. An example is always nice, but IMHO there’s a missing method
map!(f, iter) = map!(f, iter, iter) which would make it obvious that it does work.
Agree. I was specifically looking for it in the documentation. In fact, I wrote a piece of code with it and I was surprised that it didn’t work.
That’s a great idea, but given that the semantics is different from the current
map!, perhaps a different name would be preferable. Also, there is no reason it can’t take multiple arguments, and just write into the first one.
mapinto!(f, dst_and_first_arg, args...)?