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:

    {"a...@gmail.com <javascript:>"
          [{:email "a...@gmail.com <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 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
<mailto:clojure+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
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/d/optout.

Reply via email to