Created
April 3, 2010 16:43
-
-
Save fehrenbach/354668 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (deftype Element [data start end] :as this | |
| clojure.lang.Associative | |
| (assoc [key value] | |
| (apply (fn [data start end] | |
| (Element. data start end)) | |
| (vals (assoc {:data (:data this) | |
| :start (:start this) | |
| :end (:end this)} | |
| key value))))) | |
| ;; much better: | |
| (deftype Element [data start end] | |
| clojure.lang.IPersistentMap) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(assoc (Element "bla" 23 42) :data "blubb") => #:Element{:data "blubb", :start 23, :end 42}