Fork me on GitHub
#clojure
<
2021-03-20
>
piyer07:03:33

Is there a way to do lein install clj-http ? I am expecting lein to install the dep and update the project.clj file.

Ivan Fedorov07:03:26

Probably not. But it’s a good intent. Clojure’s build/task system could use an upgrade – maybe a new client written on babashka.

dpsutton07:03:11

lein install is a task to install the current project into your local repository, not add deps into your current project. There might be a plugin that achieves what you want but i'm not familiar with it. And with the speed of lein, I'd probably prefer to just go grab things myself.

Ivan Fedorov07:03:47

Gauging interest to a Google Calendar client – published a scribble with specs. https://github.com/spacegangster/gcal-clj

didibus17:03:51

Looks like this is coming sooner then I thought: https://openjdk.java.net/jeps/401 https://openjdk.java.net/jeps/402 These could be pretty impactful for Clojures performance and memory use I think.

👍 3
rossputin17:03:27

Hi - latest version of Practicalli’s Clojure Deps.edn is giving me ‘Could not find artifact com.github.seancorfield:next.jdbc:jar:2.0.193 in central (https://repo1.maven.org/maven2/)’ on running clojure -X:project/jar - anyone else seen this?

robertfw17:03:55

@UV23GRRR7 Probably worth asking this in #practicalli

rossputin17:03:08

thanks for the heads up - didn’t spot that 🙂

dharrigan17:03:28

That's most definitely a typo

dharrigan17:03:37

Latest is 1.1.646

dharrigan17:03:19

2.0.193 is for depstar

practicalli-johnny22:03:33

Sorry, I copy-pasted next.jdbc instead of depstar into the alias... and its not even April 1st. Sorry for the mistake. Its been fixed and pushed to GitHub Also suppressed the logging warning for :project/outdated And a few more library verison updates.

thheller17:03:43

what kind of a lie is this exception? anyone have a clue what this could be about?

NullPointerException Cannot invoke "java.lang.Character.charValue()" because "x" is null
        clojure.lang.RT.intCast (RT.java:1220)

thheller17:03:53

"x" is clearly not null?

p-himik17:03:19

I would read it as if x is the name of the variable that's supposed to contain a character. (.charValue x).

p-himik17:03:57

But now I'm interested in how one would get the message that reads "Cannot invoke blah-blah". :) All I get is "Execution error (NullPointerException) at blah-blah".

thheller17:03:35

(nth [1 2 3] nil)

p-himik17:03:39

Nope, still same message. Probably some difference in REPL/JVM.

p-himik17:03:04

user=> (nth [1 2 3] nil)
Execution error (NullPointerException) at user/eval159 (REPL:1).
null

thheller17:03:46

I get the error I posted. this is all from the REPL. might be jdk15?

p-himik17:03:32

Perhaps, mine is 14.

dpsutton17:03:11

yeah newer jdk's added better null pointer messages i believe

seancorfield22:03:48

My dot-clojure file has a :j14 alias that enables a JVM option that produces the more verbose exceptions.

seancorfield22:03:16

{:jvm-opts ["-XX:+ShowCodeDetailsInExceptionMessages"]}

seancorfield22:03:30

It was new in JDK 14.

JL20:03:55

Question for the guru's - I'm stuck on sort-by with nested data. I want to sort by :class then by :key alphabetically I've tried

sorted (sort-by :key #(> %1 %2) data)]
sorted (sort-by (juxt :class :key) data)
With no luck input data is:
{0 {[Wizard :true-strike] {:key :true-strike, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard}, 
	[Wizard :acid-splash] {:key :acid-splash, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard}, 
	[Cleric :word-of-radiance] {:key :word-of-radiance, :ability :orcpub.dnd.e5.character/wis, :qualifier nil, :class Cleric}, 
	[Cleric :encode-thoughts-dimir-guild-] {:key :encode-thoughts-dimir-guild-, :ability :orcpub.dnd.e5.character/wis, :qualifier nil, :class Cleric}}, 
1 {[Cleric :sanctuary] {:class-key :cleric, :key :sanctuary, :class Cleric, :ability :orcpub.dnd.e5.character/wis},
   [Cleric :protection-from-evil-and-good] {:class-key :cleric, :key :protection-from-evil-and-good, :class Cleric, :ability :orcpub.dnd.e5.character/wis}, 
   [Wizard :absorb-elements] {:key :absorb-elements, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard}, 
   [Wizard :unseen-servant] {:key :unseen-servant, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard}, 
   [Cleric :cure-wounds] {:class-key :cleric, :key :cure-wounds, :class Cleric, :ability :orcpub.dnd.e5.character/wis}, 
Desired output is:
{0 { [Cleric :encode-thoughts-dimir-guild-] {:key :encode-thoughts-dimir-guild-, :ability :orcpub.dnd.e5.character/wis, :qualifier nil, :class Cleric}}, 
     [Cleric :word-of-radiance] {:key :word-of-radiance, :ability :orcpub.dnd.e5.character/wis, :qualifier nil, :class Cleric}, 
     [Wizard :acid-splash] {:key :acid-splash, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard}, 
     [Wizard :true-strike] {:key :true-strike, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard}, 

1 { [Cleric :cure-wounds] {:class-key :cleric, :key :cure-wounds, :class Cleric, :ability :orcpub.dnd.e5.character/wis}, 
    [Cleric :protection-from-evil-and-good] {:class-key :cleric, :key :protection-from-evil-and-good, :class Cleric, :ability :orcpub.dnd.e5.character/wis}, 
    [Cleric :sanctuary] {:class-key :cleric, :key :sanctuary, :class Cleric, :ability :orcpub.dnd.e5.character/wis},
    [Wizard :absorb-elements] {:key :absorb-elements, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard}, 
    [Wizard :unseen-servant] {:key :unseen-servant, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard}, 

p-himik20:03:45

Your second attempt looks fine to me. But it acts on separate values of that map - just apply it to them in reduce-kv or into with a transducer.

p-himik20:03:08

Oh, wait - I'm wrong. Your values are also maps. So you want a sorted-map-by, not sort-by.

p-himik20:03:04

(into {}
      (map (fn [[id datum]]
             [id (into (sorted-map) datum)]))
      data)

3
pavlosmelissinos20:03:49

Besides what @U2FRKM4TW said, the data looks really weird to me. Does it have to be so nested? Wouldn't something like this be much more simple and clean?

{0 [{:key :true-strike, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard},
    {:key :acid-splash, :ability :orcpub.dnd.e5.character/int, :qualifier nil, :class Wizard},
	...],
 1 [{:class-key :cleric, :key :sanctuary, :class Cleric, :ability :orcpub.dnd.e5.character/wis},
    {:class-key :cleric, :key :protection-from-evil-and-good, :class Cleric, :ability :orcpub.dnd.e5.character/wis},
    ...]}

p-himik20:03:00

Indeed. I would also add that if you only need to index via consecutive natural numbers then it might be better to use a vector. Vectors are associative and their keys are natural numbers - indices of the elements:

=> (assoc [1 2] 1 3)
[1 3]

3
JL21:03:28

@UEQPKG7HQ it is what is being processed (inherited) I'll give

(into {}
      (map (fn [[id datum]]
             [id (into (sorted-map) datum)]))
      data)
A shot

👍 3
JL21:03:45

@U2FRKM4TW Thanks! That appears to do the trick : ]

👍 3