[racket] Any way to get "true" quasiquote behavior in match form?
Thanks for the tips - I am new to using match, the answers are
illuminating, and so close...
I perhaps oversimplified my example. What I actually need to do is to match
on an arbitrary expression bound earlier., e.g.
(match foo
(bar #t)
(_ #f))
Where bar is bound to some valid *match* expression. It appears the ==
fits the bill for something that resolves to some literal value in the end.
I need to match what might be a literal, but could be something like bar
being (list (and (? number?) (? odd?)))).
In other words, I'd like to be able to generate or have the user supply any
arbitrary match expression, and use it for the bar in the match shown
above. Ideas?
Thx again,
Rob
On Fri, Mar 9, 2012 at 4:37 PM, rob cook <heycarnut at gmail.com> wrote:
> That is, without using a macro or eval. Id like to do:
>
> (define a 4)
> (define l1 '(1 2 3))
> (match l1
> (`(1 2 ,a) #t)
> (_ #f))
>
> So that this example would result in #f, and #t if a bound to 3.
>
> Since of course match has its own quasiquote behavior, this does not seem
> possible w/o making a macro for "dynamic" match, or building the s-exp and
> using eval (yuck!).
>
> Is this correct, or have I missed something obvious?
>
> Thnx
> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120309/79d14c50/attachment.html>