Fork me on GitHub
#beginners
<
2019-07-11
>
jakuzure06:07:11

Hi, I'm trying to do something like (merge (into {} (for [ch "abc"] [ch 1])) (into {} (for [ch "def"] [ch 2]))) but want it to be more scalable and work with any number of lists

jakuzure06:07:12

tried something like this, but not quite there yet

seancorfield06:07:51

@shin Maybe look at map-indexed?

seancorfield06:07:25

(with multiple collection mapped to vectors perhaps?)

seancorfield06:07:26

(apply merge (map-indexed (fn [i x] (into {} (for [ch x] [ch i]))) (map vector coll1 coll2 coll3 ...)))

seancorfield06:07:22

user=> (apply merge (map-indexed (fn [i x] (into {} (for [ch x] [ch i]))) (map vector [1 2 3] [:a :b :c] ["f" "o" "o"])))
{1 0, :a 0, "f" 0, 2 1, :b 1, "o" 2, 3 2, :c 2}
user=> 

seancorfield06:07:37

Is that what you're after @shin?

jakuzure07:07:48

thanks @seancorfield! I'm actually looking for a solution that maps [1 2 3] to 1 [:a πŸ˜› :c] to 2 etc.

jaihindhreddy07:07:05

Is this it @shin

(->> [[1 2 3] [:a :b :c] ["f" "o" "o"]]
     (map-indexed #(vector %2 (inc %)))
     (into {}))

jakuzure07:07:16

@jaihindhreddy I'd like to have it for each character individually, like {\a 1, \b 1, \c 1, \d 2, \e 2} [...]

jaihindhreddy08:07:10

Can you explain the meaning behind it, so that we can understand it better.

jaihindhreddy08:07:30

What happens when things repeat? What if the args are "abcd" "xdcd"?

jakuzure08:07:48

this is what I asked yesterday: jakuzure [12:17] I'm trying to take a list of random kanji and sort them into the different grades as seen here: https://de.wikipedia.org/wiki/J%C5%8Dy%C5%8D-Kanji

jaihindhreddy10:07:26

Still am not sure what you're looking for but I have a hunch group-by can help. Checkout (doc group-by)

jakuzure08:07:54

each character should only show up once

dmaiocchi09:07:22

is there a way to see which class methods has the imported jar?

dmaiocchi09:07:53

so I have imported a jar via leinigen with reource-paths ["resources/my-custom-secret.jar"] in project.clj

dmaiocchi09:07:42

now, since I dunno which class there are inside and there is not much documentation in the open, I was thinking if there was maybe a way to print the classes/inspect that Jar via REPL

dmaiocchi09:07:06

or maybe it can even do it with Java, for moment I don't have experience with it 😁

dmaiocchi09:07:52

I wonder if one can do it via only REPL/clojure

jumar10:07:15

if you use cider you can just cider-open-classpath-entry and then select and hit enter. Not sure about pure-clojure way to do it

dmaiocchi11:07:00

@U06BE1L6T many thx. I'm trying it now

jumar11:07:58

You can then even "open" the .class file by pressing Enter (not sure if it requires some setup or not - it uses javap)

jumar11:07:10

(but that's admittedly not that useful :)

dmaiocchi11:07:42

currently, beeing a Java nob, I have my foo.jar jars, is there a way if you know, to import the full jar in clojure?

dmaiocchi11:07:42

e.g I have managed currently to build a local jar. but I dunno currently the full namespaces of my jar

dmaiocchi11:07:13

for doing like the example above.. 😁 I'm seraching maybe if i can know it via java..

jumar11:07:07

I'm not sure I'm following what you mean by "import the full jar"? If you built a local version of jukebox2 then you should do lein install and reference it in the project.clj with appropriate version as found in https://github.com/thehammer/jukebox2/blob/369c8b3050eb3c5209452532206a743a1986c695/project.clj#L1

dmaiocchi11:07:22

I fixed for moment. I'm learning how to import java classes and namespace if they have

dmaiocchi11:07:49

actually I was trying to find out if there is kind of namespace in Java or is everything a class..

dmaiocchi11:07:31

but it worked for moment, it was kind adventourous to setup a local jar 😁 but it worked ! kind cool

stacktracer13:07:48

is it possible to get emacs+cider autocomplete working in a codebase with a Maven POM rather than a lein project.clj?

dmaiocchi17:07:58

you can ask in #cider

stacktracer13:07:29

I got cider connected to an nrepl instance that I started from the CLI, and I get autocomplete in the cider repl. But don't get autocomplete when I'm editing a file

telekid17:07:19

Any idea why swap! doesn’t throw when the form passed to f includes the io! macro? I would have assumed that swap! would behave similarly to alter in this respect.

andy.fingerhut17:07:18

I can surmise that perhaps the expectation is that dosync transactions would often be 'much bigger' things than changes to single atoms via swap!, but that is only a guess on my part.

Alex Miller (Clojure team)17:07:35

Also, because atom swaps are spin waits, the function is expected to be as fast as possible. Adding checks for io! would have some cost

πŸ‘Œ 4
PB18:07:53

Can deps.edn fetch from a private maven repository?

theeternalpulse18:07:54

I believe this is an example of doing such a thing https://github.com/seancorfield/dot-clojure/blob/master/deps.edn#L2

πŸ‘ 4
PB18:07:37

Superb! thank you!

πŸ‘ 4
seancorfield18:07:03

If you need authentication for a private repo, you can put the credentials in ~/.m2/settings.xml

Ludwig21:07:21

hi all, do jdbc.next has support for ucanaccess driver? for .mdb files (microsoft access)

seancorfield21:07:07

@vachichng If you have a JDBC driver, you should be able to use it with next.jdbc (or clojure.java.jdbc).

πŸ‘ 4