Note that reduce(vcat, fun.(array))
may well hit a special method for vectors of vectors or matrices, which allocates one array to write into. There is no such method for mapreduce(fun, vcat, array)
, and thus it will call vcat
many times, allocating length(array)-1
arrays in the process. This will probably be much more expensive than the one temporary array from fun.(array)
.
If fun(a)
returns a vector, then you can try vec(stack(fun, array))
, with using Compat
first.