-
-
Save jhn/bc797e8a107609425919 to your computer and use it in GitHub Desktop.
LazySeq into #{}
This file contains 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
(def tat (atom #{})) | |
(class (products)) ; => clojure.lang.LazySeq | |
; works | |
(defn go [] | |
(let [ps (products)] | |
(when-not (empty? ps) | |
(reset! tat (into #{} ps)))) | |
(go) ; resets tat correctly on every invocation | |
; crashes | |
(defn go [] | |
(let [ps (products) | |
diff (set/difference ps @tat)] | |
(when-not (empty? ps) | |
(reset! tat (into #{} ps)))) | |
(go) ; ClassCastException clojure.lang.LazySeq cannot be cast to clojure.lang.IPersistentSet clojure.core/disj (core.clj:1454) |
This file contains 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
(def tat (atom #{})) | |
(class (products)) ; => clojure.lang.LazySeq | |
(defn go [] | |
(let [ps (products) | |
diff (set/difference ps @tat)] | |
(when-not (empty? ps) | |
(reset! tat (into #{} ps)))) | |
(go) ; works fine! | |
(go) ; ClassCastException clojure.lang.LazySeq cannot be cast to clojure.lang.IPersistentSet clojure.core/disj (core.clj:1454) | |
(go) ; ClassCastException clojure.lang.LazySeq cannot be cast to clojure.lang.IPersistentSet clojure.core/disj (core.clj:1454) | |
(def tat (atom #{})) | |
(go) ; works fine! | |
(go) ; ClassCastException clojure.lang.LazySeq cannot be cast to clojure.lang.IPersistentSet clojure.core/disj (core.clj:1454) | |
; etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment