Roman Numerals in Racket Sources

posted by Shriram Krishnamurthi

The other day, while discussing Church numerals in class, I pointed out that Racket could support Roman numeral in source programs. The essence of the idea is that, whenever an unbound identifier matches the syntax of a Roman numeral, it is automatically converted into the corresponding number.

The implementation of this is here. The test client best illustrates this in action. For instance, here is a valid test case:

( define ( square x ) ( * x x )) ( check-equal? ( square X ) C )

The essence of the implementation is just this macro:

I(define MMMMM “that is especially delicious!”)

— steck, 23 November 2012

It’s a great setup for counters, too: (do ((i i …)) …)

— YeshuaAaron, 23 November 2012