Re: Simple clojure example improvements sought

2017-01-10 Thread Beau Fabry
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 p

Re: Simple clojure example improvements sought

2017-01-10 Thread hiskennyness
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 li

Re: Simple clojure example improvements sought

2017-01-10 Thread hiskennyness
On Tuesday, January 10, 2017 at 1:59:05 PM UTC-5, Francis Avila wrote: > > > > On Tuesday, January 10, 2017 at 9:27:24 AM UTC-6, hiskennyness wrote: >> >> Whenever I code something like this I get the feeling a clojure guru >> could do it more simply, and I love learning new tricks. >> >> Here i

Re: Simple clojure example improvements sought

2017-01-10 Thread Beau Fabry
sorry that last nth should've been (nth % i nil) On Tuesday, January 10, 2017 at 11:37:22 AM UTC-8, 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

Re: Simple clojure example improvements sought

2017-01-10 Thread Beau Fabry
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}) Without: (map-indexed (fn [i name] (into {} (map (fn [[k v]] [k (nth v i)]) optij))) (:na

Re: Simple clojure example improvements sought

2017-01-10 Thread Francis Avila
On Tuesday, January 10, 2017 at 9:27:24 AM UTC-6, hiskennyness wrote: > > Whenever I code something like this I get the feeling a clojure guru could > do it more simply, and I love learning new tricks. > > Here is my simple (real-world, btw) problem and solution. Is there a > better way? > > ;;

Simple clojure example improvements sought

2017-01-10 Thread hiskennyness
Whenever I code something like this I get the feeling a clojure guru could do it more simply, and I love learning new tricks. Here is my simple (real-world, btw) problem and solution. Is there a better way? ;; Problem: given optimized* json maps (* to avoid duplicating keys): (def optij {:name