Skip to content

Instantly share code, notes, and snippets.

@ship561
Last active December 16, 2015 01:41
Show Gist options
  • Save ship561/2e3f3664c2f0bf3676f9 to your computer and use it in GitHub Desktop.
Save ship561/2e3f3664c2f0bf3676f9 to your computer and use it in GitHub Desktop.
(defn bar [input]
(let [xf1 (partial re-seq #"[-\w]+")
xf2 (fn [[x & ys]]
[x
(->> ys
(map-indexed #(if (odd? %1)
(read-string %2)
%2))
(apply assoc {}))])]
(transduce (comp (map xf1)
(map xf2))
(completing (fn [m kvs]
(apply assoc m kvs)))
{}
(str/split-lines input))))
(def foo "one property1 1, property2 1\ntwo property1 2, property2 2\nthree property1 3, property2 3\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment