On Wed, Jul 24, 2013 at 5:16 AM, Phillip Lord
<phillip.l...@newcastle.ac.uk>wrote:

>
>
> So, with this case, say I want the Italian label, in the set which is the
> value of the annotation key, find any list with the first element 'label,
> and
> third element "it", and return the second element. Of course, this can be
> done
> in Clojure, but the code gets complex very quickly.
>
> What I'd really want to be able to do is to use some sort of query; so I'd
> write a data structure like so:
>
> {:annotation
>  #{(label ? "it")}}
>
> and have this match and return
>
> {:annotation
>  #{(label "Ingredienti di Pizza" "it")}}
>
> which is the bit that matches.
>

This is considerably more complicated than the query given, but I have lib
which (when I push an update for better set, string, and map handling) will
allow you to do something not entirely unlike that:

macroparser.parsers> (run (map (both (keyword
:annotation)

                                     (set (seq (parseq (symbol 'label)
(expression) (string
"it"))))))

                          '({:annotation #{(label "pizza" "it")}}))
{:annotation #{(label "pizza" "it")}}
macroparser.parsers>

i.e., match a map with one value whose key is :annotation and whose value
is a set containing a seq of 'label, anything, and "it".

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to