Fork me on GitHub
#clojure
<
2021-05-14
>
oboff05:05:32

why does this not work?

(#(+ %&) 1 2 3)
Execution error (ClassCastException) at java.lang.Class/cast (Class.java:3068).
Cannot cast class clojure.lang.ArraySeq to class java.lang.Number

djm05:05:46

(#(apply + %&) 1 2 3)
6

djm05:05:06

(apply + [1 2 3])
6
(+ [1 2 3])
Execution error (ClassCastException) at java.lang.Class/cast (Class.java:3816).
Cannot cast clojure.lang.PersistentVector to java.lang.Number

phronmophobic05:05:37

yea, %& is a seq:

> (#(prn %&) 1 2 3)
(1 2 3)

oboff05:05:44

how is (+ 1 2 3) different?

oboff05:05:53

thank you for the replies

djm05:05:50

(+ 1 2 3) calls + with three arguments. (+ [1 2 3]) calls + with only argument (of the wrong type, so it gives an error).

3
djm05:05:32

Hence you need apply - you can see some examples here https://clojuredocs.org/clojure.core/apply

👀 3
oboff05:05:03

I understand now, thank you @U015KH5ENEM

djm05:05:23

You're welcome

Juλian (he/him)08:05:18

where did the clojure logo come from? I get the lambda in the middle, but why on top of a green-blue yin-yang?

Ivan Koz17:05:47

^ yep, reference to an iconic book, look at the crystal ball in the mage's hand

rickmoynihan08:05:49

And lets not forget the clear reference to the international peace symbol ☮️. A truly genius logo!

Ramon Rios16:05:35

Did someone already tried to, when execute a lein test or lein midje . It also executes a docker-compose up for integration testing?

Rob Haisfield17:05:33

How do EDN and JSON compare to each other? Thoughts and resources?

Alex Miller (Clojure team)17:05:21

I wrote this comparison of edn, transit, and fressian long ago, but I think it's still a good overview https://groups.google.com/g/clojure/c/9ESqyT6G5nU/m/2Ne9X6JBUh8J

👍 9
Alex Miller (Clojure team)17:05:34

for edn vs JSON, edn has a richer base set of data types and importantly is extensible so you can define your "date" or anything else (via tagged literals). it also tends to be more concise (mostly due to the absence of : and , in maps/arrays)

Alex Miller (Clojure team)17:05:49

edn is imo strictly better than JSON, yaml, or whatever as a human-centered data format for configuration etc

☝️ 30
Rob Haisfield18:05:13

Can you elaborate on the human-centered data format point?

Alex Miller (Clojure team)19:05:35

a format you expect people to read/write/edit in a file

Alex Miller (Clojure team)17:05:36

but, you're going to find much higher performance parsers for json than for edn (particularly in the browser) so then I'd consider transit (or fressian)

flowthing18:05:45

What does the last c in .cljc stand for? "Common"?

flowthing19:05:52

Thanks. :thumbsup::skin-tone-2:

borkdude18:05:16

or "c"onditional?

3
Rob Haisfield18:05:47

Do other programming languages have good ways to interpret and use EDN?

blak3mill3r04:05:44

Lots of them do. I have personally used EDN libraries in C++, Haskell, Ruby, and Python. I have seen more out there that I have not used.

Sam Ritchie19:05:11

hey all, qq on sorted maps… is it expected that this should throw?

Sam Ritchie19:05:13

((sorted-map 0 2) :face)

Sam Ritchie19:05:20

class java.lang.Long cannot be cast to class clojure.lang.Keyword (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.Keyword is in unnamed module of loader 'app')

Sam Ritchie19:05:22

ah, it’s happening here. it’s because the sorted map keeps an internal comparator, so (compare 0 :face) fails for the same reason

Alex Miller (Clojure team)19:05:38

sorted maps/sets should have a comparator that handles whatever you put in it (or you should not put that stuff in it)

Sam Ritchie19:05:07

👍 thank you!

Adam Kalisz21:05:44

I have this problem, that our WebSocket messages over 64 kB in size break the connection. The message seems to go to the server, where Sente + Aleph somehow drop the ball: https://github.com/ptaoussanis/sente/issues/389 @ptaoussanis Is there some hard limit somewhere that could be tweaked or worked around?

Adam Kalisz21:05:49

This seems to happen both when using EDN and/or Transit as well