Skip to content

Instantly share code, notes, and snippets.

@jeremyheiler
Created April 5, 2013 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyheiler/5321505 to your computer and use it in GitHub Desktop.
Save jeremyheiler/5321505 to your computer and use it in GitHub Desktop.
Pointfree!
(let [d [["a" " 1 "] ["b " "2"] ["c" " 3"]]]
(reduce (partial apply assoc) {} (map (partial map clojure.string/trim) d)))
;=> {"c" "3", "b" "2", "a" "1"}
@saolsen
Copy link

saolsen commented Apr 5, 2013

(let [d [["a" " 1 "] ["b " "2"] ["c" " 3"]]]
  (apply assoc {} (flatten (map (partial map clojure.string/trim) d))))

@saolsen
Copy link

saolsen commented Apr 5, 2013

well hell, why not do this?

(let [d [["a" " 1 "] ["b " "2"] ["c" " 3"]]]
  (apply assoc {} (map clojure.string/trim (flatten d))))

or this

(let [d [["a" " 1 "] ["b " "2"] ["c" " 3"]]]
  (->> d
       flatten
       (map clojure.string/trim)
       (apply assoc {})))

@jeremyheiler
Copy link
Author

Slightly better:

(let [d [["a" " 1 "] ["b " "2"] ["c" " 3"]]]
  (apply hash-map (map clojure.string/trim (flatten d))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment