Fork me on GitHub
#clojure
<
2017-03-19
>
schmee01:03:18

does anyone here know Aleph?

schmee01:03:48

When I send stuff to the server with the slow-echo-handler with netcat, I get a response the first time and then nothing

schmee01:03:09

and I have to restart the server to get another response

schmee01:03:15

what I’m I misunderstanding?

mars0i03:03:24

@xiongtx Clojure maps don't implement any of the Java map interfaces. http://static.javadoc.io/org.clojure/clojure/1.8.0/clojure/lang/APersistentMap.html I don't know the reasons for that, though.

mars0i03:03:53

However, you can convert a Java hash map into a Clojure hash map using into:

mars0i03:03:35

user=> (assoc (java.util.HashMap.) :a 1)
ClassCastException java.util.HashMap cannot be cast to clojure.lang.Associative  clojure.lang.RT.assoc (RT.java:807)
user=> (assoc (into {} (java.util.HashMap.)) :a 1)
{:a 1}
user=> (class (into {} (java.util.HashMap.)))
clojure.lang.PersistentArrayMap
user=> (class (into (sorted-map) (java.util.HashMap.)))
clojure.lang.PersistentTreeMap

johnnyillinois04:03:38

Anyone using: https://github.com/nberger/ring-logger and configuring the log level at runtime?

hamid07:03:59

Is there way to manually set the number of threads used in core.async?

hamid07:03:15

Any comment? :/

xiongtx08:03:15

PersistentHashMap extend APersistentHashMap, which implements java.util.Map.

yonatanel09:03:59

@hamid The newer unaccepted answer seems to be what you're looking for. Also check out manifold if you're interested in a more flexible alternative: https://github.com/ztellman/manifold/blob/master/docs/execution.md

rauh09:03:25

@hamid It's also described in the ns-docs string: https://clojure.github.io/core.async/

yonatanel09:03:11

@johnnyillinois I'm using ring-logger-timbre and configure per-namespace levels at runtime

hamid14:03:10

Thanks guys ;)

mars0i15:03:47

@xiongtx thanks for correcting me.

bcbradley17:03:12

should character 160 be treated as whitespace by clojure regex?

bcbradley17:03:22

just wondering if that was an oversight

noisesmith17:03:48

clojure regex is just java regex

noisesmith17:03:04

(on the jvm at least)

bcbradley17:03:11

same question then, @ java

noisesmith20:03:46

@bcbradley - looks like java doesn't think it's whitespace

+user=> (Character/isWhitespace 160)
false
https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#isWhitespace(int)

bcbradley20:03:49

i had to convert everything into a vector of characters and map over the integer codes myself, what a pain

noisesmith20:03:23

it explicitly doesn't consider nonbreaking spaces whitespace, if you look at that javadoc link

bcbradley20:03:59

thats interesting, but other people do consider it whitespace, and use it that way

bcbradley20:03:26

for instance, in any standard javadoc-- the space between the type of a parameter and the name of the parameter is a 160

noisesmith20:03:09

@bcbradley here's a unicode regex that matches whitespace

+user=> (re-matches #"\p{Zs}" (str (char 160)))
" "

jmp21:03:13

So… I’m trying to remove the first string from a vector. And when i remove the first sting the function returns [#function[clojure.core/filter/fn—####] “other string"]

jmp21:03:09

Any ideas what that is? tried googling it but it just shows unrelated issues

jmp21:03:41

Disclaimer: I’m really new to clojure btw

noisesmith22:03:50

@juanmp when you give filter only one argument, it returns a transducing function

noisesmith22:03:10

it looks like, instead of filtering the vector, you are replacing the first element of the vector with a filter transducer

jmp22:03:29

Oh.. is there any easy way to get rid of the transducer? I’m googling right now what those are 😅

noisesmith22:03:41

juanmp you shouldn't be creating one

noisesmith22:03:47

I don't even know why you are using filter

noisesmith22:03:02

it might be useful to share some of your code at this point

jmp22:03:22

(map #(vector (remove (first %)) (second %)) (load-csv csv-file)))

noisesmith22:03:44

OK - that's not how remove works

jmp22:03:51

so I’m getting a sequence of vectors with two strings in it

noisesmith22:03:55

remove happens to use filter internally

noisesmith22:03:13

you can't use map to return a different number of items than the seq you provide

noisesmith22:03:26

you can't use remove to remove an item by index

noisesmith22:03:43

if you want the item without the first entry, just use rest

noisesmith22:03:10

if you are literally looking for the first string in the vector, and replacing that, this is a trickier problem, but it won't involve map or filter

jmp22:03:41

so basically I have a sequence of vectors with 2 strings in it each. and I want to remove the first sting on each vector

jmp22:03:50

that’s what I was trying to do with it

noisesmith22:03:53

juanmp (map rest coll)

noisesmith22:03:07

if they need to remain vectors (map (comp vec rest) coll)

noisesmith22:03:43

remove takes a collection and removes every item that has a truthy result for its function arg

jmp22:03:47

Oh alright, I’ll check what rest and coll do right away 🙂 Thank you @noisesmith !

noisesmith22:03:59

oh - coll was just a placeholder

noisesmith22:03:16

your code would be (map rest (load-csv csv-file))

jmp22:03:39

Sorry, I’m really new at this haha

noisesmith22:03:15

it's OK - coll is a common name for collection arguments in clojure

jmp22:03:43

Oh, that’s good to know! And that worked perfectly @noisesmith ! Thank you very much

jmp22:03:17

Thank you, Clojure is the first programming language I’m trying to learn. So please excuse my stupid questions and thank you for your patience ! 🙂

rbertrand22:03:42

Nice choice!! 😊

cfleming22:03:31

I’m having a very strange problem with classloading.

cfleming22:03:59

When running my tests (in an admittedly funky environment), I’m suddenly getting a NoClassDefFoundError.

cfleming22:03:20

The class it can’t find is one of my application classes, written in Java.

cfleming22:03:42

If I break on that Error, it’s trying to use a DynamicClassLoader to resolve the class. The 5 ancestor classloaders above that are also DCLs, and then there’s the AppClassloader.

cfleming22:03:02

The AppClassloader can load that class, but the DCLs for some reason cannot.

cfleming22:03:41

Class.forName("cursive.repl.Printing", false, ClassLoader.getClassLoader(caller).getParent().getParent().getParent().getParent().getParent().getParent()) works fine from within Class.forName()

cfleming22:03:49

Oh, wait, hang on - the problem is not that it can’t find the class, but that the class initialisation fails.

cfleming22:03:54

Never mind me.