[plt-scheme] match single symbol
Ryan Culpepper wrote:
> Jon Rafkind wrote:
>> I was trying to match a single symbol but I didn't see a match
>> pattern for it. This code seems to do what I want
>>
>> (define (match-symbol sym)
>> (match sym
>> [x (=> f) (if (not (symbol? x)) (f) 'ok)]
>> [else 'bad]))
>
> (define (match-symbol sym)
> (match sym
> [(? symbol?) 'ok]
> [_ 'bad]))
>
Ah right, good call. It seems like predicates could be used for other
literals too, like char?, string?, etc. So is there a good reason for
the current set of literals that can be used in a pattern?