This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-20
Channels
- # ai (1)
- # beginners (17)
- # boot (27)
- # cider (2)
- # cljs-dev (64)
- # clojure (131)
- # clojure-austin (13)
- # clojure-dev (15)
- # clojure-dusseldorf (11)
- # clojure-france (45)
- # clojure-russia (19)
- # clojure-spec (66)
- # clojure-uk (22)
- # clojurescript (97)
- # core-logic (7)
- # cursive (5)
- # data-science (1)
- # datomic (92)
- # dirac (49)
- # emacs (1)
- # events (5)
- # funcool (10)
- # hoplon (79)
- # jobs (1)
- # jobs-rus (1)
- # lein-figwheel (1)
- # leiningen (3)
- # om (14)
- # onyx (35)
- # planck (2)
- # proton (1)
- # re-frame (21)
- # reagent (2)
- # ring-swagger (10)
- # spacemacs (10)
- # specter (18)
- # untangled (7)
- # vim (23)
howdy! just curious about a behaviour in the following example:
(s/select [:a s/ALL (juxt :start :end)]
{:a [{:start 1 :middle 9 :end 2} {:start 3 :middle 9 :end 4}]})
yields [{:start 1, :middle 9, :end 2} {:start 3, :middle 9, :end 4}]
when i would have expected just :start and :end keys in the resulting maps.i thought multipath might allow me to collect the two values but this throws an exception in cljs:
(s/select [:a s/ALL (s/multi-path :start :end)]
{:a [{:start 1 :middle 9 :end 2} {:start 3 :middle 9 :end 4}]})
i could just throw an anonymous function in there, something like (vals (select-keys...
In the juxt
example, I’m guessing the function is treated as a predicate, so it returns anything for which that predicate returns a truthy result, not the truthy result itself.
@joshkh what exception are you getting? that works fine for me in a cljs repl
specter.cljc?rel=1476963781628:1049 Uncaught TypeError: G__36053.select_STAR_ is not a function
yea that bug is fixed in master
try 0.13.1-SNAPSHOT
also if you want to get [[1 2] [3 4]]
as the result do this:
(select [:a s/ALL (s/collect-one :start) :end]
{:a [{:start 1 :middle 9 :end 2} {:start 3 :middle 9 :end 4}]})
oh right. i had tried calling collect-one
for each respective key but couldn't figure out how to "drop" the rest from the selection resulting in [1 3 {entire-node}]
no problem, glad I was helpful