Fork me on GitHub
#beginners
<
2016-11-09
>
progzilla08:11:35

@pawel.kapala @curlyfry wow! Thanks. I really appreciate it.

rcanepa14:11:46

Hi everyone!... I am confused about how to include java code in an application. Right now, my sources are separated in two folders: src/java and src/clojure. I want to import a class that I wrote from a clojure namespace, however, when I run lein javac or lein repl I receive an exception with a message telling me that the class was not found.

rcanepa14:11:59

This is the import statement

rcanepa14:11:56

And the stacktrace error message is this:

rcanepa14:11:56

Exception in thread "main" java.lang.ExceptionInInitializerError at clojure.main.<clinit>(main.java:20) Caused by: java.lang.ClassNotFoundException: org.tempuri.Core, compiling:(scv2backend/component/signature_soap_client.clj:1:1)

rcanepa14:11:06

From what I have read, first I should run lein javac to compile my java sources and the run lein repl, but for some reason isn't working.

dominicm15:11:40

@rcanepa might be an issue with your project.clj too, would be useful to see the relevant parts / all of it.

rcanepa15:11:48

@dominicm right! ... I believe this is the important part:

rcanepa15:11:44

Does running lein javac compile the clojure sources too?

dominicm15:11:08

Nope. Shouldn't need to. Might be worth looking around target for .class files

rcanepa15:11:19

Ok, I will. Thanks @dominicm

rcanepa15:11:15

I removed the import statement and the repl started without problems. Then I added back the import statement, reloaded the repl and everything worked fine again. That is very weird. I guess now the java sources are compiled so I can import them.

rcanepa15:11:32

If I execute lein clean, I go back to the same problem as before.

dominicm17:11:33

Yeah, lein clean will clean up the target directory.

dominicm17:11:07

You might have a problem if you do lein repl then lein javac, you need to make sure javac finishes first. All I can think of

dominicm17:11:24

Hmm, you did do that

dominicm17:11:29

maybe someone else will know 🙂 ¯\(ツ)

rcanepa17:11:48

Yeah, I did that. Thanks anyway!

roelofw19:11:55

Why does f v are not resolved here :

(def mapset
  "works like a map but returns a set"
  [f v]
   (f v )
  ) 

jswart19:11:45

Show an example of ^ being used. How would you call it and what would you expect?

dpsutton19:11:19

you used def not defn

dpsutton19:11:46

you are trying to define a function

jswart19:11:13

^ thats it

roelofw20:11:32

hmm, when I do (mapset inc [1 1 2 2]) I see this error : ClassCastException clojure.lang.PersistentVector cannot be cast to java.lang.Number clojure.lang.Numbers.inc (Numbers.java:112)

cschep20:11:33

you’re trying to call “inc” on a vector, which you cannot do.

cschep20:11:45

you can see that it says, Vector cannot be cast to a Number

cschep20:11:51

inc expects a number.

cschep20:11:19

remember that excersizes 4,5,6 are considered “difficult” at that point and you can revisit them after reading the next two chapters

cschep20:11:35

map can be a tough concept to immediately grasp onto if you haven’t seen it before

roelofw20:11:21

yep, I had to use map

roelofw20:11:37

now I have to find out how to make a set of a map

roelofw20:11:33

tomorrow I will take a look at the last two exercises.

roelofw20:11:43

I have a idea for the 5th one

roelofw20:11:56

I have to find a function that will do the recur several times I think

roelofw20:11:54

Am I on the right track that I have to change this function :

(defn better-symmetrize-body-parts
  "Expects a seq of maps that have a :name and :size"
  [asym-body-parts]
  (reduce (fn [final-body-parts part]
            (into final-body-parts (set [part (matching-part part)])))
          []
          asym-body-parts))  

roelofw20:11:17

for both exercise 5 and 6 of do things of the brave book ?