This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-26
Channels
- # admin-announcements (1)
- # beginners (12)
- # cider (2)
- # cljs-dev (6)
- # cljsrn (4)
- # clojure (123)
- # clojure-austin (10)
- # clojure-brasil (1)
- # clojure-canada (21)
- # clojure-conj (5)
- # clojure-dev (8)
- # clojure-gamedev (42)
- # clojure-russia (121)
- # clojure-sanfrancisco (2)
- # clojure-spec (25)
- # clojure-uk (36)
- # clojurescript (195)
- # clojutre (3)
- # cursive (43)
- # datomic (6)
- # defnpodcast (2)
- # dirac (14)
- # emacs (2)
- # ethereum (2)
- # events (2)
- # funcool (6)
- # hoplon (76)
- # jobs (1)
- # kekkonen (9)
- # lein-figwheel (1)
- # leiningen (4)
- # mount (6)
- # off-topic (5)
- # om (2)
- # onyx (91)
- # pedestal (2)
- # protorepl (14)
- # re-frame (22)
- # reagent (20)
- # rethinkdb (1)
- # ring (2)
- # schema (3)
- # sfcljs (3)
- # spacemacs (15)
- # specter (12)
- # testing (1)
- # yada (63)
I’m trying to write a navigator that drops n
items. Here’s what I’ve got:
(spm/defnav nav-drop [n]
(select* [this structure next-fn]
(let [ret (next-fn (drop n structure))
empt (empty structure)]
(if (= ret sp/NONE)
ret
(into empt ret))))
(transform* [this structure next-fn]
(let [ret (next-fn (drop n structure))]
(->> (concat (take n structure) ret)
(into (empty structure))))))
I found I had to check the return value of next-fn
to check for NONE
. Is that the right approach? My original attempt was done assuming I’d just get back an empty list, but that didn’t work.@sashton the select* implementation should just be (next-fn (drop n structure))
you're on 0.12.0, right?
the requirement of select* is to call next-fn on whatever subvalue should be passed to the next navigator
so you should put the logic to maintain type before you call next-fn
probably (next-fn (into (empty structure) (drop n structure)))
you only need to deal with NONE
when a navigator navigates to an indeterminate number of subvalues