Consider the following:

(define x "abc")
(match '(1 "abc")
  [ (list 1 y) #:when (string=? y x) #t ]
  [ _ #f ])

Is there a way to accomplish the same thing more concisely by interpolating the 
value of x into the pattern? For example (non-working syntax):

(define x "abc")
(match '(1 "abc")
  [ (list 1 ~x) #t ]
  [ _ #f ])

This also works, but seems overly verbose:

(define x "abc")
(match '(1 "abc")
  [ (list 1 (? (λ (v) (string=? v x)))) #t ]
  [ _ #f ])

I tried a few quasipatterns, but got nowhere.

Thanks,
Brian

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to