[racket] Generating comparable symbols

From: Pierpaolo Bernardi (olopierpa at gmail.com)
Date: Wed Jan 15 02:59:44 EST 2014

On Wed, Jan 15, 2014 at 8:43 AM, Eric Dobson <eric.n.dobson at gmail.com> wrote:
> I'm not sure what you mean by random, but does gensym do what you want?

I think Marco means interned. Gensym produces uninterned symbols.

AFAIK, and checking briefly the manual, there doesn't seem to exists a
single function to do this.
But it is easy to cobble up something.

(define gensym-intern
  (let ((k 0))
    (λ ((base "gensym-"))
      (set! k (add1 k))
      (string->symbol (format "~a~a" base k)))))


Posted on the users mailing list.