MapIndex returns the index in a list instead of as shown in my revised example. I can work with it (or work around it), but what's the design concept? It seems like an unnecessary complication, but I'm sure there is a reason I don't see.
I tagged this with a design-pattern tag. I'm not sure if that's appropriate. Editors please remove the tag if it's not.