Haha, the one line was more an artifact of me entering it that way than a recommendation, if I was committing to master it would probably look like
(map-indexed (fn [person-num _person_name] (->> optij (map (fn [[attribute-name attribute-vals]] {attribute-name (nth attribute-vals person-num)})) (into {}))) (:name optij)) On Tuesday, January 10, 2017 at 6:13:28 PM UTC-8, hiskennyness wrote: > > > > On Tuesday, January 10, 2017 at 2:37:22 PM UTC-5, Beau Fabry wrote: >> >> With specter: >> >> (map-indexed (fn [i name] (sp/transform sp/MAP-VALS #(nth % i) optij)) >> (:name optij)) >> => ({:name :tom, :age 1, :tone :do} {:name :dick, :age 2, :tone :re} >> {:name :harry, :age 3, :tone :mi}) >> > > One line! With specter, but still nice. > > But to me this is the downside of specter and even Clojure: the code > starts to get opaque. I am reminded of the C Puzzle Book which offered > simple data and a few lines of code and defied us to guess what the code > produced. > > My big take-away here is map-indexed. Forgot about that and it would have > greatly simplified my original efforts. > > >> >> Without: >> >> (map-indexed (fn [i name] (into {} (map (fn [[k v]] [k (nth v i)]) >> optij))) (:name optij)) >> => ({:name :tom, :age 1, :tone :do} {:name :dick, :age 2, :tone :re} >> {:name :harry, :age 3, :tone :mi}) >> >> > Gonna have to study that one. :) Still one line, tho! Cool. > > -kt > >> >>> -- 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.