No that won’t do, as a transducer is not a function. I finally figured something out though that is type-stable, doesn’t allocate, and is extremely fast (thanks to @jakobnissen for the starting point):
function Base.map!(f::F, dest, kernel::Kernel) where {F}
foldl(kernel |> Map(f) |> Enumerate(); init=dest) do v, (i, e)
i > length(dest) && resize!(dest, i)
v[i] = e
v
end
end
If anyone sees any room for improvement, I’d like to know, being relatively new to Julia, and extremely new to Transducers.jl myself. Thank you!