This morning I pushed out an update to Dendrite to improve the numbering on the contents pages. The website follows a book metaphor so I thought it would be nice to use lowercase Roman numerals for the contents and Arabic numerals for the story pages. I did some quick research to make sure I wasn’t mixing up my Ls, Cs, and Ds and then scribbled down a recursive function for building the string.

It works, but I hated how long and repetitive it was. To improve it, I decided to pull out the numbers and Roman numerals into a map and then just iterate over that until the Arabic number was 0.

Iterating over an array is simpler than a map, but it is slightly more difficult to match which Arabic number matches which Roman number.

Some interesting notes:

The Arabic number falls through the function like a series of sieves. 4s and 9s are special cases with a subtractive representation. Numbers larger than a few thousand don’t look very good. Ms all the way down…

As a side note, the arrows for navigating through the contents page still need to have larger tap targets and maybe some way to be in the same place on the page regardless of the page content. Maybe stuck to the bottom?