I was meaning map would be inelegant if you tried to cram all that logic into the the map block (foreach would be a much better way to lay that out). But obviously your way to do it is also elegant.
It's fairly easy to give examples of what is/isn't elegant, but I find it harder to come up with an actual definition.