This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-09
Channels
- # adventofcode (1)
- # aleph (2)
- # beginners (28)
- # boot (26)
- # boot-dev (8)
- # cider (10)
- # clara (10)
- # cljs-dev (130)
- # cljs-experience (1)
- # cljsrn (12)
- # clojure (118)
- # clojure-austin (40)
- # clojure-boston (1)
- # clojure-chicago (1)
- # clojure-dusseldorf (1)
- # clojure-estonia (11)
- # clojure-france (1)
- # clojure-greece (3)
- # clojure-italy (19)
- # clojure-nl (1)
- # clojure-russia (1)
- # clojure-spec (19)
- # clojure-uk (34)
- # clojurescript (62)
- # core-logic (7)
- # cursive (11)
- # datomic (35)
- # emacs (15)
- # fulcro (264)
- # jobs (4)
- # leiningen (5)
- # midje (4)
- # off-topic (74)
- # onyx (27)
- # planck (14)
- # protorepl (4)
- # re-frame (37)
- # reagent (62)
- # rum (2)
- # shadow-cljs (171)
- # slack-help (5)
- # spacemacs (6)
- # specter (9)
@aaelony with specter it would be something like:
(defn first-matching-tag [tag]
(path (filterer #(= (:tag %) tag)) FIRST))
(select
[(first-matching-tag :html)
:content
(first-matching-tag :div)
:content
(first-matching-tag :h2)
ALL
:content
FIRST
(view #(str/split #" "))
(fn [[verb _]] (#{"GET" "POST" "DELETE" "HEAD"} verb))
]
data)
plus a little extra code to do that processing of "inputs" in your code
Thank-you, @nathanmarz. Looks more elegant and concise. I was unaware of the path macro. I’ll need to look into it. Eager to understand Specter better.
@aaelony select
, transform
etc. implicitly use that macro
path
is the heart of what makes specter work
first-matching-tag
returns a navigator to be composed with rest of path
select
invokes a navigator on a piece of data