Fork me on GitHub
#specter
<
2017-05-29
>
oskarkv19:05:44

outer-map looks like this:

{[1.0 1.0] {:vertices [[0 0] [1.5 0.0] [1.5 1.5] [0.0 1.5]]}
 ...}
Can I do this conveniently with specter? I.e. take the vertices, make a polygon out of them, and put it next to the vertices.
(into {} (map (fn [[site m]] (assoc m :polygon
                                    (pair-cycle (:vertices m)))
                outer-map)))

oskarkv21:05:25

(s/transform [s/MAP-VALS (s/collect-one :vertices) :polygon]
                   (fn [vs _] (pair-cycle vs))
                   m)

oskarkv21:05:53

That's what I came up with.

nathanmarz22:05:54

@oskarkv that code looks good to me