[plt-scheme] match single symbol

From: Jon Rafkind (rafkind at cs.utah.edu)
Date: Thu Sep 3 11:58:07 EDT 2009

Sam TH wrote:
> On Thu, Sep 3, 2009 at 12:28 AM, Jon Rafkind<rafkind at cs.utah.edu> wrote:
>>> What have literals (which compare against a single value) got to do
>>> with predicates (which often match a whole class of values)?
>>> --Carl
>> Er yea, sorry I was totally confused for a second. I'll just write my own
>> matchers with define-match-expander.
> For literals, 'foo, 7, "hello", and such all work fine.  What doesn't
> exist at the moment that you need?

I need to match any single symbol and got momentarily confused about the 
literal patterns. I thought there was a pattern for matching any string, 
but its just a literal string.

This is essentially what I need:

(define-match-expander symbol (lambda (stx) #'(? symbol?)))

(match 'x
       [symbol 'ok]
       [else 'bad])

Posted on the users mailing list.