Le 29 mai 2012 à 00:03, Laurent PETIT <laurent.pe...@gmail.com> 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 now

Your example could then become:

#{[:name]
     [:email]
     [:adress #{:city :state}]
     [:spouse #{:name [:address #{:city :state}]}


I don't have an implementation to offer, but as I see it, it could be some
kind of superset of get-in, extending its syntax, if you will.


What about that ?



Le 26 mai 2012 à 06:59, Baishampayan Ghose <b.gh...@gmail.com> a écrit :

Hi,

I have a problem wherein I need to select subsets of a given map;
think about select-keys, but with arbitrary nesting.

For example, consider this map -

(def my-map {:name "John Doe"
              :email "j...@doe.com"
              :address {:house "42"
                         :street "Moon St."
                        :city "San Francisco"
                        :state "CA"
                        :zip 76509
                         :mobile "+188888888"}
              :ssn "123456"
              :spouse {:name "Jane Doe"
                       :ssn "654321"
                        :relation :wife
                       :address {:house "42"
                                 :street "Moon St."
                                 :city "Atlanta"
                                  :state "GA"
                                 :zip 76509
                                 :mobile "+188888888"}}})

>From the above map, I want to extract this sub-map -

{:spouse {:name "Jane Doe", :address {:state "GA", :city "Atlanta"}},
:name "John Doe",
 :email "j...@doe.com",
:address {:state "CA", :city "San Francisco"}}

What would be a good way to express this sub-map so that I can pass it
on to a function?

I am thinking about something like this -

[:name :email {:address [:city :state]} {:spouse [:name {:address
[:city :state]}]}]

Example implementations are also welcome.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
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 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

Reply via email to