On Tuesday, August 18, 2015 at 1:13:16 AM UTC-4, Alex Knauth wrote:
> Is == what you're looking for?
> Or do you want a version of == that uses string=? ?

I'm not sure what you're suggesting. I basically want a way to inject the value 
of x into the pattern vs. using a literal such as "abc" since I need to do this 
programmatically. The #:when clause and/or the ? function are reasonable work 
arounds - I'm just hoping there's a more concise way to get the value of x into 
the pattern.

> On Aug 18, 2015, at 12:55 AM, Brian Adkins <lojicdot...@gmail.com> wrote:
> 
> > 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.

-- 
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