tried doing it in racket.  Works, but not pretty or robust