Fork me on GitHub
#clojure
<
2015-11-07
>
Alex Miller (Clojure team)00:11:26

@triss look up how to do it in Java and use interop to do that

triss00:11:50

thanks alexmiller

triss00:11:13

interop it is. couldn't find a library I was sure of anywhere

manderson02:11:46

I'm experimenting with the specter library and am trying to select a list of values for a given key anywhere it may occur in a map (including nested maps and vectors of maps, etc) with the intention of applying a transform function to it (say keyword). So, for example, given the map: {:a "one" :b {:a "two" :c "foo"} :d [{:a "three"} {:e "bar"}]} I want all values of :a ["one" "two" "three"], and then transform these with keyword so that the final map has :one :two :three in their place. Thoughts?

jfntn02:11:52

@manderson: that should like a postwalk traversal, can specter do that?

manderson02:11:54

@jfntn: not sure. I may have the wrong library for the use case as I wasn't able to find a nice way to do it, but thought I'd check here in case I was missing something.

jfntn02:11:39

@manderson: well in this case you should check clojure.walk/postwalk does just what you’re trying to do

manderson02:11:02

@jfntn: great, thanks! I'll check it out.

jfntn02:11:18

I think there’s even a replace variant of that function

manderson02:11:44

yeah, that would be perfect. finding the right tool helps simple_smile

manderson02:11:58

for reference, here's a quick solution to my above question using postwalk:

(clojure.walk/postwalk 
  (fn [form] 
    (if (and (map? form) (contains? form :a)) 
      (assoc form :a (keyword (:a form))) 
      form)) 
  {:a "one" :b {:a "two" :c "foo"} :d [{:a "three"} {:e "bar"}]})

sveri09:11:11

Hi, is there an easy way to add a local jar to a leiningen project? Easy as just putting the lib path to leiningen configuration and being done? (No, I don't want to setup a local maven repo or something similar)

nowprovision09:11:44

@sveri, yes lein-localrepo

sveri09:11:24

@nowprovision: Hm, you mean this one: https://github.com/kumarshantanu/lein-localrepo ? This also requires me to do some local setup. I'd like to omit that, if possible

nowprovision09:11:48

though, i used lein-localrepo to throw the ms-sql driver in the right place, setup was one line to ~/.lein/profiles.clj

sveri09:11:34

Hm, I have been trying to add it to resoure-paths, but the test runner cannof find it. it fails on compilation -.-

sveri09:11:42

@nowprovision: Thanks for helping. I found the lib is available on clojars, been looking on maven repo only

ghadi15:11:03

About to do a 1hr talk on intro to Clojure. Anyone recommend a favorite slideset? It's for BarCamp. Mixed crowd

ghadi15:11:34

spread the doctrine

cigitia20:11:22

What’s the idiomatic way to get only the first resulting item from applying a transducer to a collection? My current understanding is that: With (first (into [] xform input)), the entire result is needlessly processed. But with (first (sequence xform input)), a lot of intermediate lazy sequences are needlessly instantiated.

bronsa22:11:11

@cigitia: no intermediate lazy sequences are instantiated with sequence

bronsa22:11:18

it's chunked though

bronsa22:11:44

@cigitia: one way to avoid the chunkedness is (-> (eduction xform input) .iterator .next)