Improving performance elegantly - type stability

I agree. I’m curious though, why map was able to vectorize correctly while loops weren’t?