How to match , in match in Racket?

racket, scheme

Solution

First note that the comma `,` is a special reader abbreviation. The `(hi,there)` is a read as `(hi (unquote there))`. This is difficult to spot - since the default printer prints lists whose first element is an `unquote` in a special way.

Welcome to DrRacket, version 5.3.0.14--2012-07-24(f8f24ff2/d) [3m].
Language: racket.
> (list 'hi (list 'unquote 'there))
'(hi ,there)

Therefore the pattern you need is '(list h (list 'unquote t))'.

> (define s '(hi,there))
> (match s [(list h (list 'unquote t)) (list h t)])
(list 'hi 'there)

Problem

if I have something like this `(define s (hi,there))` then how can I write in match like `(match s [(,h , ,t)] ...)` But it is not working, because `match` needs the `,` so how can I do this?

Original source