This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-21
Channels
- # aleph (2)
- # beginners (22)
- # boot (7)
- # chestnut (8)
- # cider (4)
- # clara (3)
- # cljs-dev (3)
- # cljs-experience (19)
- # clojure (69)
- # clojure-italy (8)
- # clojure-nl (1)
- # clojure-spec (11)
- # clojure-uk (17)
- # clojurescript (77)
- # cursive (22)
- # datomic (14)
- # events (1)
- # fulcro (78)
- # hoplon (51)
- # jobs (3)
- # keechma (1)
- # lambdaisland (1)
- # lumo (30)
- # off-topic (42)
- # om (22)
- # onyx (5)
- # parinfer (4)
- # portkey (1)
- # re-frame (15)
- # reagent (2)
- # ring (4)
- # spacemacs (1)
- # specter (23)
- # testing (1)
- # unrepl (60)
- # yada (8)
pred= and friends are great!
@nathanmarz Is it possible to contribute to the Specter wiki?
When you first mentioned recursive-path, I noticed it wasn't documented (in the Macros section?). I dug up the mention in Changes.MD that had an example. I cloned the wiki and made a change locally but would like to contribute it
@michaelwfogleman yea, I wish github had a way to make pull requests for project wikis
maybe I can make the specter wiki its own project and keep it in sync myself
@michaelwfogleman ok, make a pull request to https://github.com/nathanmarz/specter-wiki
Awesome! Done!
Happy to tweak the documentation if it's not quite right. 🙂
awesome, merged
should probably add example of transform and an example of a parameterized recursive-path
can open issues on specter-wiki repository for anything you find that's lacking
(which is probably a lot of things)
hello, just discovered specter yesterday and I thought it might help me transforming honeysql queries. for example given...
{:select (:*), :from (:table), :where [:or [:and [:= :a 1] [:b 1]] [:and [:= :c 1] [:= :d 1]]]}
example: if i need to add [:= :active true]
to each clause.
having trouble specifying the path past [:where ALL]
, i guess it's a problem with the sequences having a keyword as the first element.@twillis do you want to add that clause to the top-level of :where
(e.g. [:and [:= :active true] [:or ...]]
) or within each :and
clause?
if the latter you'll probably need a recursive path since :and
and :or
can nest arbitrarily
well in the above example I was thinking of adding to each clause but it was just an arbitrary example. but I think the issue i'm having is that I dont know how to get to things in a vector where the first item is a keyword.
you can use this to navigate to each node in tree:
(def TreeNodes
(recursive-path [] p
(if-path sequential?
(continue-then-stay ALL p)
STAY
)))
then something like this for your transform:
(setval [:where TreeNodes vector? (selected? FIRST (pred= :and)) AFTER-ELEM] [:= :active true] data)
ok thanks for your help @nathanmarz
Oh, it's a specter function. Didn't notice that none of the functions were namespaced in the samples
it's just a convenience, same as #(= % some-val)