add reverseind(s, i) function to convert indices in reverse(s) to indices in s
Merge pull request #9249 from stevengj/reverseind

add reverseind(s, i): convert indices in reverse(s) to indices in s