gn
hmmm - so the message passing part is something that akka solves no?
I'd agree that the ability to share memory is an issue, but you could just choose not to right?
or like, choose not to make use of that
Naming is hard. But functions like this are common in “util” libraries out there. I haven’t felt a need for them in core.
I’ve always just used reduce-kv
for any transformation over a hash map. Well, since it was added to Clojure in 1.4 🙂
I feel I rarely need to apply the same transform to all values in a map. Generally my maps model compound types, so the keys are specifically to distinguish the kind of values. And so I rarely need to make the same value change to all of them. With reduce-kv I can switch on the key to apply the appropriate transformation to the value.
@didibus re Perl/Ruby heredocs: our Perl code at work, iirc, only has a few heredocs and I can’t think of any in our ruby codebase either
Is there a way to do lein install clj-http
? I am expecting lein to install the dep and update the project.clj file.
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.
Gauging interest to a Google Calendar client – published a scribble with specs. https://github.com/spacegangster/gcal-clj
Probably not. But it’s a good intent. Clojure’s build/task system could use an upgrade – maybe a new client written on babashka.
For lein there is https://github.com/johnwalker/lein-plz
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.
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?
@rossajmcd Probably worth asking this in #practicalli
thanks for the heads up - didn’t spot that 🙂
That's most definitely a typo
Latest is 1.1.646
Yes
2.0.193 is for depstar
<https://github.com/seancorfield/depstar/releases>
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)
"x"
is clearly not null?
I would read it as if x
is the name of the variable that's supposed to contain a character. (.charValue x)
.
ah indeed
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".
(nth [1 2 3] nil)
Nope, still same message. Probably some difference in REPL/JVM.
user=> (nth [1 2 3] nil)
Execution error (NullPointerException) at user/eval159 (REPL:1).
null
I get the error I posted. this is all from the REPL. might be jdk15?
Perhaps, mine is 14.
yeah newer jdk's added better null pointer messages i believe
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8218628
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},
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.
Oh, wait - I'm wrong. Your values are also maps. So you want a sorted-map-by
, not sort-by
.
(into {}
(map (fn [[id datum]]
[id (into (sorted-map) datum)]))
data)
Besides what @p-himik 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},
...]}
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]
@pavlos it is what is being processed (inherited) I'll give
(into {}
(map (fn [[id datum]]
[id (into (sorted-map) datum)]))
data)
A shot@p-himik Thanks! That appears to do the trick : ]
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.
My dot-clojure file has a :j14
alias that enables a JVM option that produces the more verbose exceptions.
{:jvm-opts ["-XX:+ShowCodeDetailsInExceptionMessages"]}
It was new in JDK 14.