This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-17
Channels
- # admin-announcements (4)
- # boot (93)
- # cider (4)
- # cljsrn (61)
- # clojure (137)
- # clojure-austin (2)
- # clojure-brasil (2)
- # clojure-dev (11)
- # clojure-dusseldorf (10)
- # clojure-greece (245)
- # clojure-russia (37)
- # clojure-spec (60)
- # clojure-taiwan (1)
- # clojure-uk (24)
- # clojurescript (36)
- # cursive (18)
- # datomic (20)
- # emacs (20)
- # funcool (1)
- # hoplon (29)
- # jobs (1)
- # keechma (1)
- # lein-figwheel (1)
- # leiningen (1)
- # off-topic (3)
- # om (10)
- # om-next (1)
- # onyx (60)
- # other-languages (14)
- # planck (26)
- # random (3)
- # re-frame (21)
- # ring (2)
- # spacemacs (8)
- # specter (56)
- # spirituality-ethics (2)
- # uncomplicate (1)
- # untangled (68)
- # yada (3)
Note that if you're doing a transform, you'll lose the first element
(transform [(view rest) ALL] inc (range 5))
(2 3 4 5)
you don't need to call nextfn
twice in your select
you do need it in your transform*, though
transform* also needs to perform nextfn
on the passed in structure, and then reconstruct the original structure, replacing what you navigate to with the results of nextfn
for example, the wiki example stores the result of (nextfn (nth structure n))
and then replaces the nth element of structure
with it
yep, you're right
no, that's not right
I mean, you could do that if you want, but that's like doing [REST ALL]
I updated the gist so that it now works on sets and maps as well, although obviously you probably wouldn't want to use it on thsoe
I think it'd be nice to have more selectors that mimic the bahavior of clojure.core
functions (`TAKE`, DROP
etc.)
I did not know about empty
some of those functions are in the works, I think (https://github.com/nathanmarz/specter/issues/121)
this returns what I want, but I wonder if there's a way to write it using just one transform
(transform [ALL (collect-one :foo) :bar REST ALL ALL] + data)
@codonnell: yeah that works except for it doesn't lift :bar
up
but maybe (mapv :bar (transform [ALL (collect-one :foo) :bar REST ALL ALL] + data))
is the most readable
alright, I'll take a closer look in a bit
I think that using collect-one
with transform
for the purpose of lifting an inner structure upwards is a bit verbose and doesn't feel so easily composable
(transform [ALL (collect-one :foo) (view :bar) REST ALL ALL] + data)
that does it, I think
as for which is more readable, I'd say that's a matter of opinion
probably has a lot to do with how familiar the reader is with specter
the fact that it's even possible to accomplish that transformation in one line of code is pretty absurd IMO
and adding one more level of complexity takes only a small tweak: https://gist.github.com/luxbock/c499f34ffe07c00404da7b2615295057
yep, very nice
@severed-infinity: Def. a Cursive problem, not specter
Simply go into the specter (and macros) source file, hover over a (eg. devnav
) usage and choose Resolve as ... def
@rauh Ah I am using the latest EAP but did not know about this