Re: querying a clojure data structure

2013-07-25 Thread Phillip Lord
Okay, this is worth poking into. Ben Wolfson writes: > On Wed, Jul 24, 2013 at 5:16 AM, Phillip Lord > 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 eleme

Re: querying a clojure data structure

2013-07-25 Thread Phillip Lord
Timothy Washington writes: > Like Tim, I was thinking about the Datomic query language. Before you do > that though, remember that there's some basic relational algebra functions > in clojure.set . I did think about clojure.set, but as far

Re: querying a clojure data structure

2013-07-25 Thread Phillip Lord
Timothy Baldridge writes: > I think the first hint to an answer is found in your question. You are > dealing with complex data, simplify the data, and querying the data is much > simpler. Part of the problem is that the data structure that I have is intrinsically fairly complex; I have already

Re: querying a clojure data structure

2013-07-25 Thread Alexander Solovyov
On Wed, Jul 24, 2013 at 3:16 PM, Phillip Lord wrote: > 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")}} > Some time ago I wrote a little library to act as a model layer for browser apps: https://gi

Re: querying a clojure data structure

2013-07-24 Thread Timothy Washington
Like Tim, I was thinking about the Datomic query language. Before you do that though, remember that there's some basic relational algebra functions in clojure.set . Stuart Halloway demonstrates this in an interesting gist

Re: querying a clojure data structure

2013-07-24 Thread Ben Wolfson
On Wed, Jul 24, 2013 at 5:16 AM, Phillip Lord 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

Re: querying a clojure data structure

2013-07-24 Thread Timothy Baldridge
Eh...use the right tool for the job... On Wed, Jul 24, 2013 at 2:00 PM, Cedric Greevey wrote: > On Wed, Jul 24, 2013 at 3:27 PM, Timothy Baldridge > wrote: > >> However, to be honest, this is where I reach for Datomic. It has a wicked >> fast query engine (datalog), you can run it in-memory (n

Re: querying a clojure data structure

2013-07-24 Thread Cedric Greevey
On Wed, Jul 24, 2013 at 3:27 PM, Timothy Baldridge wrote: > However, to be honest, this is where I reach for Datomic. It has a wicked > fast query engine (datalog), you can run it in-memory (no disk access > required), it has an excellent Clojure interface, the free version should > do everything

Re: querying a clojure data structure

2013-07-24 Thread Timothy Baldridge
I think the first hint to an answer is found in your question. You are dealing with complex data, simplify the data, and querying the data is much simpler. For instance, if you have a tree, you could flatten the tree into a hash map like this: {parent-id {:children [child-id1 child-id2]} child-i

Re: querying a clojure data structure

2013-07-24 Thread Cedric Greevey
Don't quote me on this, but it might be the sort of problem for which core.logic is well suited. Though really it seems like what's wanted is a variation on the theme of core.match but which does destructuring assignments rather than flow control. On Wed, Jul 24, 2013 at 8:16 AM, Phillip Lord wro