Skip to content

Instantly share code, notes, and snippets.

@frankhale
Last active December 29, 2015 23:49
Show Gist options
  • Save frankhale/7745450 to your computer and use it in GitHub Desktop.
Save frankhale/7745450 to your computer and use it in GitHub Desktop.
Playing with maps in Clojure
; Playing here, trying to figure out how to work with vectors of maps, my brain synapses are connecting but
; this code doesn't totally reflect the connections made. This will be rectified within 24 hours! HAHA!
;(def buffers (atom []))
;(swap! buffers conj {:file-name "one.txt" :file-text "first file"}
; {:file-name "two.txt" :file-text "second file"}
; {:file-name "three.txt" :file-text "third file"}
; {:file-name "four.txt" :file-text "fourth file"})
;@buffers
;(swap! buffers conj {:file-name "text.txt" :file-text "this is a test"})
;(map #(if-not (= (:file-name %) "three.txt") %) @buffers)
(def editor-state (atom {:buffers []}))
(swap! editor-state assoc :buffers (conj (:buffers @editor-state) {:file-name "foo.txt" :file-text "hello, world!"}))
@editor-state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment