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
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
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
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
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
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?
>
> ;;
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