This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-11
Channels
- # admin-announcements (3)
- # beginners (51)
- # boot (14)
- # cider (55)
- # cljsrn (5)
- # clojure (105)
- # clojure-austin (2)
- # clojure-brasil (3)
- # clojure-dusseldorf (2)
- # clojure-greece (5)
- # clojure-italy (1)
- # clojure-mexico (1)
- # clojure-russia (74)
- # clojure-spec (66)
- # clojure-uk (22)
- # clojurescript (124)
- # cursive (10)
- # datomic (79)
- # events (2)
- # immutant (3)
- # jobs (4)
- # klipse (38)
- # leiningen (2)
- # luminus (1)
- # off-topic (25)
- # om (48)
- # om-next (36)
- # on (1)
- # onyx (19)
- # overtone (3)
- # pedestal (2)
- # proton (3)
- # re-frame (178)
- # reagent (49)
- # ring-swagger (1)
- # spacemacs (10)
- # specter (29)
- # testing (5)
- # untangled (6)
- # yada (65)
what's a good letter to bind com.rpl.specter to , given that I already have s -> clojure.spec ?
I guess yeah, though spec is in core so I think it's fair to just assume it will always get the bare 's'
I second sp
:)
@nathanmarz : between cascalog, elephantdb, and specter; you have the tools for "manipulating large scale datasets" -- any plans on a database of some sort down the line?
https://github.com/nathanmarz/specter/search?utf8=%E2%9C%93&q=setval <-- where is setval defined?
(m/pp (com.rpl.specter/setval [:a com.rpl.specter/ALL nil?] com.rpl.specter/NONE {:a [1 2 nil 3 nil]}))
is outputting:
{:a [1 2 :com.rpl.specter.impl/NONE 3 :com.rpl.specter.impl/NONE]}
what am I doing wrong?@qqq no comment ;)
@nathanmarz : what, if any, is the theoretical under pinning of specter? in numpy, we can do something like: a :: mxn float b :: mxn bool a [b] = ... // assigns to the portion of a where b is true specter seems to be doing this on a "multi level" way, but I'm wondering if there is some deeper theoretical underpinning
Keeps the element only if it matches the supplied predicate. This is the late-bound parameterized version of using a function directly in a path. ^^ -- I don' get it. Why do I need pred instead of just using the function?
;; not-selected?: stops navigation if something is found
(sp/select [sp/all (sp/not-selected? even?)] (range 10))
(sp/select [sp/all (sp/not-selected? [(sp/must :a) even?])] [{:a 0} {:a 1} {:a 2} {:a 3}])
(sp/select-one (sp/not-selected? [sp/all (sp/must :a) even?]) [{:a 0} {:a 1} {:a 2} {:a 3}])
;; not-selected?: stops navigation if fails to find path
(sp/select [sp/all (sp/selected? even?)] (range 10))
(sp/select [sp/all (sp/selected? [(sp/must :a) even?])] [{:a 0} {:a 1} {:a 2} {:a 3}])
(sp/select (sp/selected? [sp/all (sp/must :a) even?]) [{:a 0} {:a 1} {:a 2} {:a 3}])
selected? / not-selected? -- these examples I am not understanding@qqq pred
is the navigator that functions implicitly use
You would use it in a situation like this:
(defn foo [afn data]
(select [ALL (pred afn)] data))
if you were just to do (select [ALL afn] data)
there's no way to know what the type of that local will be (or whether it will change on every invocation, so specter would have to figure that out on every single invocation
which would hurt performance
by explicitly saying it's pred
, the inline compiler can bake it into the path and avoid that coercion at runtime
a common use case of selected?
is finding all values in a map where the key matches some criteria
e.g. (select [ALL (selected? FIRST some-predicate?) LAST] amap)
lot of other use cases of course
as for theoretical underpinnings... no
the specter API is the result of me unifying a ton of data manipulation use cases into the simplest possible abstractions
there's similarities to haskell lenses but also some key differences
I'm starting over and playing with examples to see if I can stub my toe and document beginner gotchas. here's an interesting example : (setval [:peeps END] [:name "Moe"] {:peeps [{:name "Larry" } {:name "Curly"}]})
(setval [:peeps END] {:name "Moe"} {:peeps [{:name "Larry" } {:name "Curly"}]})
(setval [:peeps END] [{:name "Moe"}] {:peeps [{:name "Larry" } {:name "Curly"}]})