Re: Selecting subsets of maps

2013-08-31 Thread Baishampayan Ghose
Alex, Very cool! Thanks. ~BG On Fri, Aug 30, 2013 at 4:58 PM, Alex P wrote: > @ Baishampayan > @ Christophe > > Accidentally crossed over this post, turned out I've had exactly same need > (about a year after you though), and decided to write a little library, > Balagan: https://github.com/cloj

Re: Selecting subsets of maps

2013-08-30 Thread Alex P
@ Baishampayan @ Christophe Accidentally crossed over this post, turned out I've had exactly same need (about a year after you though), and decided to write a little library, Balagan: https://github.com/clojurewerkz/balagan Basically, you can run predicate-based queries on your data and apply

Re: Selecting subsets of maps

2012-05-29 Thread Baishampayan Ghose
Great feedback, Christophe. I will get back to you with a better implementation. Regards, BG On Tue, May 29, 2012 at 5:44 PM, Christophe Grand wrote: > The expansion idea is interesting: expand your selectors to a seq of paths, > redcue with get-in/assoc-in over thme to get the "extract" sense,

Re: Selecting subsets of maps

2012-05-29 Thread Christophe Grand
The expansion idea is interesting: expand your selectors to a seq of paths, redcue with get-in/assoc-in over thme to get the "extract" sense, reduce with update-in+dissoc to get the exclude. Could yield a nice implementation. And now for some nitpicking: * nowadays I'm reluctant to extend a protoc

Re: Selecting subsets of maps

2012-05-29 Thread Baishampayan Ghose
Christophe, > Laurent dragged me in the conversation so here is my take > https://gist.github.com/2823916 which strictly follows your proposed > "syntax". I am glad that Laurent dragged you in, I got to see your beautiful solution :-) Here is my (less beautiful) solution, `extract` along with it

Re: Selecting subsets of maps

2012-05-29 Thread Christophe Grand
Hi BG, Laurent dragged me in the conversation so here is my take https://gist.github.com/2823916 which strictly follows your proposed "syntax". hth, Christophe On Sat, May 26, 2012 at 6:58 AM, Baishampayan Ghose wrote: > Hi, > > I have a problem wherein I need to select subsets of a given map;

Re: Selecting subsets of maps

2012-05-28 Thread Jay Fields
(without actual context) Here's what I'd probably do. There's a bit of repetition, but it's clear what's going on, so I don't mind. assuming the my-map def from the original email. user=> (defn select-nested-keys [m top-level-keys & {:as pairs}] (reduce #

Re: Selecting subsets of maps

2012-05-28 Thread Laurent PETIT
Le 29 mai 2012 à 00:14, Jay Fields a écrit : use destructuring? I dont know, destructuring would, well, destructure the input map, giving you all the bits on the table, but unable to restructure it with the original shape. As I understand it, BG would like some kind of shape-preserving filter/

Re: Selecting subsets of maps

2012-05-28 Thread Jay Fields
use destructuring? On May 28, 2012, at 6:12 PM, Laurent PETIT wrote: > Le 29 mai 2012 à 00:03, Laurent PETIT a écrit : > >> Hello bg, >> For describing the subsets you want, why not use as a bottom representation >> something more connected with clojure datastructures? >> >> Like >> set lite

Re: Selecting subsets of maps

2012-05-28 Thread Laurent PETIT
Le 29 mai 2012 à 00:03, Laurent PETIT a écrit : Hello bg, For describing the subsets you want, why not use as a bottom representation something more connected with clojure datastructures? Like set literal => set of sibling keys Vector => path to an inner key Map => I see no usage for maps right

Re: Selecting subsets of maps

2012-05-28 Thread Laurent PETIT
Hello bg, For describing the subsets you want, why not use as a bottom representation something more connected with clojure datastructures? Like set literal => set of sibling keys Vector => path to an inner key Map => I see no usage for maps right now Your example could then become: #{[:name]