This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-18
Channels
- # bangalore-clj (1)
- # beginners (36)
- # boot (119)
- # braid-chat (16)
- # cider (14)
- # cljs-dev (34)
- # cljsrn (7)
- # clojars (9)
- # clojure (91)
- # clojure-austin (1)
- # clojure-bangladesh (1)
- # clojure-dusseldorf (5)
- # clojure-israel (1)
- # clojure-russia (3)
- # clojure-spec (6)
- # clojure-uk (7)
- # clojurescript (11)
- # community-development (1)
- # core-async (5)
- # cursive (6)
- # datomic (11)
- # dirac (12)
- # funcool (24)
- # leiningen (5)
- # luminus (5)
- # off-topic (2)
- # om (69)
- # om-next (16)
- # overtone (4)
- # perun (19)
- # re-frame (23)
- # reagent (38)
- # specter (7)
- # uncomplicate (9)
- # yada (4)
I'm super-hesitant to ask this—I feel I ought to go thru the wikis listing the navigators and macros and other examples a couple more times (and as I just did). Can I navigate to "the space between the first and second element of a vec" and setval
it, so that [:a :b :c]
becomes [:a :NEW-VAL :b :c]
?
try this:
(def my-nav (n/PosNavigator (fn [v] (nth v 1)) (fn [v afn]
(let [val (nth v 1)]
(assoc v 1 (afn val))))))
that will need to polymorphic on the second function (the transformer), but it’s the idea
(defnav POSONE []
(select* [this structure next-fn]
(next-fn []))
(transform* [this structure next-fn]
(let [new-val (next-fn [])]
(vec (cons (first structure)
(cons new-val (rest structure)))))))
@fasiha take two. similar caveats, but I think that’s the right direction.@fasiha (setval (srange 1 1) [:NEW-VAL] [:a :b :c])