This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-19
Channels
- # admin-announcements (2)
- # aws-lambda (3)
- # beginners (66)
- # boot (61)
- # cider (1)
- # cljs-dev (17)
- # clojure (100)
- # clojure-austin (4)
- # clojure-brasil (1)
- # clojure-canada (8)
- # clojure-quebec (6)
- # clojure-russia (48)
- # clojure-sg (6)
- # clojure-spec (37)
- # clojure-uk (61)
- # clojure-ukraine (2)
- # clojurescript (80)
- # core-async (13)
- # cursive (20)
- # datascript (37)
- # datomic (2)
- # defnpodcast (4)
- # emacs (5)
- # funcool (3)
- # hoplon (11)
- # jobs (7)
- # juxt (26)
- # lein-figwheel (48)
- # leiningen (3)
- # luminus (3)
- # om (34)
- # om-next (5)
- # onyx (5)
- # protorepl (6)
- # re-frame (10)
- # reagent (9)
- # rethinkdb (16)
- # ring-swagger (5)
- # spacemacs (14)
- # specter (54)
- # untangled (36)
- # vim (75)
- # yada (1)
@arvind: those are all build/test dependencies
except for riddley, which is actually used by specter's implementation
and riddley has no dependencies of its own
so basically specter is very lean with respect to dependencies
@nathanmarz thanks
When I run "lein repl" inside the specter directory and type (require 'com.repl.specter)
@arvind: try (require '[com.rpl.specter])
. Also, the select and transform macros are in com.rpl.specter.macros
.
actually, it should work not in a list
oh, you added an extra e
com.rpl.specter
, not com.repl.specter
@codonnell: Please refer below:
user=> (require 'com.rpl.specter) FileNotFoundException Could not locate com/rpl/specter__init.class or com/rpl/specter.clj on classpath. clojure.lang.RT.load (RT.java:449)
Also when I run (all-ns)
in the repl I don't see com.rpl.specter in the list of namespaces
@arvind: if you've cloned specter off github, you need to run lein cljx
to compile the classes.
@codonnell: I just ran lein cljx
and I tried (transform)
that gave the following error:
CompilerException java.lang.RuntimeException: Unable to resolve symbol: transform in this context, compiling:(/tmp/form-init2526821032412369112.clj:1:1)
If you just do (require 'com.rpl.specter.macros)
, then transform
is named com.rpl.specter.macros.transform
If you want to just type transform
, you need to do (require '[com.rpl.specter.macros :refer [transform]])
there's a nice piece about namespaces at http://www.braveclojure.com/organization/
If you're new to clojure, that's a great book to work through.
@codonnell: I bought that book recently. Have to read through it.
this might be a question of me not understanding spectre … but say I’ve got a nested map that I want to transform multiple times … is it possible to save the lookup? e.g. write a generic path, but for this exact instance of the map, its a very narrow this key, the next key, run the transform, etc?
@hueyp: could you give an example of what you mean?
sure … {:foo {:a 1 :b 2 :c 3} :bar {:x 1 :y 2 :z 3}
… something like … ALL LAST ALL LAST even?
(I might have that syntax wrong …) … it would transform [:foo :b]
and [:bar :y]
… like if I want to double those, or subtract 1, etc … that paths are the same, so I’d like to kind of save that knowledge
Sure. If you know the whole path in advance (no parameters), you could save it with (def my-map-path (comp-paths MAP-VALS MAP-VALS even?))
(`MAP-VALS` is the same as [ALL LAST]
, but more efficient
it would do a traversal each time, that's right
this is more of a curiosity … the cost of traversing the maps I have is small … just curious if I could say turn (comp-paths MAP-VALS MAP-VALS even?)
+ an exact instance of a map into a more specific path
@hueyp: you could use traverse
from 0.12.0, which returns an instance of IReduceable
(or something like that; basically it's only useful when being called with reduce
or into
)
that will only do the traversal once, and you could call reduce
on it multiple times over the same initial structure
@codonnell: interesting, I’ll take a look, thanks~
@hueyp: I think you might be looking for a locate
feature https://github.com/nathanmarz/specter/issues/49