Page 84 is where it shows that maps are a sequence of pairs. The destructuring in James's code is on vectors -- the pairs in the sequence.
Hope that helps? Sean On Fri, Jun 5, 2015 at 8:11 PM, gvim <[email protected]> wrote: > Yes, I'm fine with the concept. Just can't remember coming across it in > the textbooks but maybe I wasn't paying attention :) > > gvim > > > > On 06/06/2015 04:08, Sean Corfield wrote: > >> Itβs because if you treat a hash map as a sequence β as `for` does β you >> get a sequence of pairs (key/value β map entries): >> >> (seq {:a 1 :b 2}) >> ;;=> ([:a 1] [:b 2]) >> >> Does that help? >> >> Sean >> >> On Jun 5, 2015, at 7:41 PM, gvim <[email protected]> wrote: >>> >>> I must re-read "Clojure Programming" (O'Reilly) in that case as I don't >>> recall the authors mentioning this kind of destructuring. >>> >>> gvim >>> >>> >>> On 06/06/2015 03:33, Fluid Dynamics wrote: >>> >>>> On Friday, June 5, 2015 at 10:07:05 PM UTC-4, g vim wrote: >>>> >>>> That works but I missed this possibility because I'm still not clear >>>> how: >>>> >>>> (group-by :email signs) >>>> >>>> .... which produces a map of the form: >>>> >>>> {"[email protected] <javascript:>" >>>> [{:email "[email protected] <javascript:>", :sign "Cancer", >>>> :planet "Mars", :surname >>>> "Blogs", :first_name "Joe"} >>>> ..... ]} >>>> >>>> .... can be destructured with the vector [email signs]. I assumed a >>>> map >>>> must be destructured with a map but couldn't find a solution as the >>>> map >>>> keys are unique values, ie. email addresses. >>>> >>>> >>>> The code was (for [[email signs] (group-by...)]...). The for iterates >>>> over the map produced by group-by, producing individual map entries, and >>>> map entries can be treated as two-element seqs/vectors of [key value], >>>> which is what the destructuring does here, putting the key in local >>>> binding email and the value, a vector with maps in it, in signs. >>>> >>> >> > -- > 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 > --- 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 [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 --- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
