Replace some occurrences of iteration over 1:length with more idiomatic structures (mostly eachindex) (#55137)
Base should be a model for the ecosystem, and `eachindex(x)` is better
than `1:length(x)` in almost all cases. I've updated many, but certainly
not all examples. This is mostly a NFC, but also fixes #55136.