On Dec 22, 2011, at 10:54 PM, Herwig Hochleitner wrote:
> I want to match vectors of the form [(some expr) :as :label], but #(match
> [%] [[expr :as (label :when keyword)]] {:expr expr :label label}) throws a
> compiler exception: Unable to resolve symbol expr
>
If you want to match a literal keyword that has a special meaning to match, you
need to quote it. (It's always safe to quote the keyword literals when in
doubt.) Also, I think your :when test should be keyword? (to make sure
something is a keyword, rather than creating one). The following works for me:
(match [['(some expr) :as :label]]
[[expr ':as (label :when keyword?)]] {:expr expr :label label})
;=> {:expr (some expr), :label :label}
--
Steve Miner
[email protected]
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en