redplanetlabs / specter

Clojure(Script)'s missing piece
Apache License 2.0
2.52k stars 105 forks source link

(setval spectre-path None map-with-vec) not working #259

Closed matt3ho closed 6 years ago

matt3ho commented 6 years ago

with clojure 1.9 and spectre 1.1.0

(let [map-with-vec {:abc [1 2 3]}
        path [:abc 1]
        spectre-path [(first path) (rs/srange (last path) (inc (last path)))]]
    ;this doesn't work
    (rs/setval spectre-path rs/None map-with-vec)
    ;this does
    (->> map-with-vec
         (rs/setval spectre-path [nil])
         (rs/setval [:abc rs/ALL nil?] rs/NONE))
    )

exception stacktrace:

java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword clojure.lang.RT.seqFrom(RT.java:550) clojure.lang.RT.seq(RT.java:530) clojure.lang.LazySeq.seq(LazySeq.java:58) clojure.lang.RT.seq(RT.java:528) clojure.core$seq5124.invokeStatic(core.clj:137) clojure.core$concat$cat5217$fn5218.invoke(core.clj:726) clojure.lang.LazySeq.sval(LazySeq.java:40) clojure.lang.LazySeq.seq(LazySeq.java:49) clojure.lang.Cons.next(Cons.java:39) clojure.lang.RT.next(RT.java:706) clojure.core$next5108.invokeStatic(core.clj:64)

nathanmarz commented 6 years ago

The correct way to remove a subsequence with srange is to set it to an empty sequence:

(setval [:abc (srange 1 2)] nil {:abc [1 2 3]})