You can’t convert list of lists to a map in Clojure

less than 1 minute read

Code

;; list_of_list_to_map.clj

(def list-of-vectors
  (list [:a 1] [:b 2])) ; ([:a 1] [:b 2])

(into {} list-of-vectors) ; {:a 1, :b 2}

(def list-of-lists
  (list (list :a 1) (list :b 2))) ; ((:a 1) (:b 2))

(into {} list-of-lists) ; error, why?

(into {} (map vec list-of-lists)) ; {:a 1, :b 2}

Notes

Updated: