I have a YeSQL query:
(get-signs {:em emails}) ;; emails is a vector of email address strings
... which produces this list of maps:
(
{:email "a...@gmail.com", :sign "Scorpio", :planet "Mercury", :surname
"Blogs", :first_name "Joe"}
{:email "a...@gmail.com", :sign "Leo", :planet "Moon", :surname "Blogs",
:first_name "Joe"}
{:email "a...@gmail.com", :sign "Scorpio", :planet "Venus", :surname
"Blogs", :first_name "Joe"}
{:email "a...@gmail.com", :sign "Cancer", :planet "Mars", :surname
"Blogs", :first_name "Joe"}
{:email "a...@gmail.com", :sign "Libra", :planet "Sun", :surname "Blogs",
:first_name "Joe"}
{:email "d...@gmail.com", :sign "Scorpio", :planet "Mars", :surname
"Doe", :first_name "Jane"}
{:email "d...@gmail.com", :sign "Taurus", :planet "Moon", :surname "Doe",
:first_name "Jane"}
{:email "d...@gmail.com", :sign "Cancer", :planet "Mercury", :surname
"Doe", :first_name "Jane"}
{:email "d...@gmail.com", :sign "Virgo", :planet "Venus", :surname "Doe",
:first_name "Jane"}
{:email "d...@gmail.com", :sign "Leo", :planet "Sun", :surname "Doe",
:first_name "Jane"}
)
I want to transform this data structure into a list of maps in this format:
{:email "a...@gmail.com" :planet-signs {:Sun "Libra" :Moon "Leo" :Mercury
"Scorpio" :Venus "Scorpio" :Mars "Cancer"]}
I started with:
(defn extract-planet-signs [emails]
(let [results (group-by :email (get-signs {:em emails}))]
(for [email-key (keys results)
{:keys [email sign planet surname first_name]} (results
email-key)
... but beyond that I'm a bit stuck. Any ideas?
gvim
--
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.