Neil's News

Sequence Converter

29 December 2007

Sequences can be listed as numbers (1,2,3...) or letters (a,b,c...) or roman numerals (i,ii,iii...). Converting between them is fun. A quick search of the web revealed a lot of converters, but the code quality was generally questionable. As is often the case, Moo Canada contained a really solid implementation: $math_utils:from_roman and $math_utils:to_roman by the ever great Mathieu Fenniak. With his permission I ported it to JavaScript and embedded it into an application I'm writing at Google. There is a lot of Moo code in use here. Not surprising given the number of Mooers who are working here.

Number Alpha Roman

Above is a live demo of the three-way conversion. The library file is sequenceConverter.js and the test harness is sequenceConverterTest.html.

And for the non-coders out there whom I've just bored to tears, go read Shel Silverstein's "The Bagpipe Who Didn't Say No".

< Previous | Next >

Legal yada yada: My views do not necessarily represent those of my employer or my goldfish.