This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-13
Channels
- # aleph (1)
- # announcements (18)
- # babashka (11)
- # beginners (112)
- # business (1)
- # calva (19)
- # cider (8)
- # clj-kondo (63)
- # cljsrn (10)
- # clojure (188)
- # clojure-australia (1)
- # clojure-dev (38)
- # clojure-europe (112)
- # clojure-nl (3)
- # clojure-provo (1)
- # clojure-spec (22)
- # clojure-uk (108)
- # clojurescript (37)
- # cryogen (4)
- # cursive (8)
- # data-science (1)
- # datomic (13)
- # emacs (9)
- # events (1)
- # fulcro (26)
- # funcool (3)
- # graalvm (2)
- # graphql (11)
- # helix (8)
- # jobs (1)
- # jobs-discuss (7)
- # nrepl (3)
- # off-topic (72)
- # pathom (10)
- # pedestal (1)
- # reagent (6)
- # reitit (7)
- # remote-jobs (1)
- # shadow-cljs (28)
- # xtdb (12)
@deactivateduser10790 Hum, not that I know, you can make one yourself. That said, you could also consider using metadata to mark a namespace as pure or not, same on your functions.
Yeah that doesn’t let me differentiate at-a-glance in the filesystem (my main intent here is to communicate to humans, not to the computer).
Yep those could work, though neither qualify as “at a glance in the filesystem” mechanisms.
Ya, I have no idea what you want this for, so you know best. Just saying it's an option as well.
you can destructure though and let multiple values out of that (while if-ing on the collection)
(if-let [{:keys [foo bar]} some-maybe-nil-map] ... )
the if is based on whether some-maybe-nil-map is nil
@st3fan I've been using https://github.com/ptaoussanis/encore which includes when-let plus other -let constructs for multiple bindings
👋 hi all. Just wanted to introduce myself. I'm the co-founder of a startup in Canberra Australia that's building enterprise software on a clojure/script stack. key parts of our stack include datomic, keechma-next, sente and shadow-cljs. We're just starting out but over time I'd like to give back to the clojure community in various ways.
@st3fan https://github.com/Engelberg/better-cond exports a version of if-let
and when-let
that checks multiple bindings; I don't use them myself, but I do use the better/cond
macro that is useful when writing code that starts leaning right towards multiple indent levels.
Is there an idiomatic way to merge vector of maps so that some values for some keys are aggregated, but others are not? Something like
[{:a "1", :b :some-keyword, :c "x"} {:a "1", :b :some-keyword, :c "y"}]
would be transformed into
{:a "1", :b :some-keyword, :c ["x", "y"]}
I’ve been playing around a bit with merge-with
, but I can’t get it quite right.I wrote this for a colleague some weeks ago, you might find it useful https://gist.github.com/bsless/e76a6537907ad4eecd69dcb321318b95
(def data [{:a "1", :b :some-keyword, :c "x"} {:a "1", :b :some-keyword, :c "y"} {:c "z"}])
(apply merge-with (fn [m v]
(if (= m v)
m
(if (vector? m)
(conj m v)
[m v]))) data)
check the source code, it should be relatively simple to follow the code: https://github.com/clojure/clojure/blob/clojure-1.10.1/src/clj/clojure/core.clj#L3051
Thanks, I appreciate it 🙂
And thanks @UK0810AQ2, that also looks useful 🙂
my foldmaps might even be overkill for your task, because you have only one "index". You can ofc just rip the indexing part out of it
Yeah, I’ll take a closer look. I like to understand code I use 🙂
anyone used googles artifact repository with clojure jars managed to upload but cant convince deps to checkout the jar
help calling java method.
I'm looking at the source code for isa?
and I see the line:
(and (class? parent) (class? child)
(. ^Class parent isAssignableFrom child))
How can I call the isAssignableFrom
method from the repl? Do I need to qualify it with some java.this.and.that/isAssignableFrom
, or do I need to require
something into my repl? Here's the error I'm getting.
(. Number isAssignableFrom Long)
Syntax error (IllegalArgumentException) compiling . at (clojure-rte:localhost:51477(clj)*:318394:23).
No matching method isAssignableFrom found taking 1 args for class java.lang.Number
Sorry, realized that I wasn't actually answering your question, but the above should work nonetheless.
What is an idiomatic way to translate something like this to Clojure:
if (foo && bar) {
return;
}
if (something == false) {
return;
}
if (something_else) {
return
}
dosomething()
I’m trying to avoid inverting those conditions and creating a huge indented if pyramid
I mean, this is already weird because it's a void method and those don't exist in Clojure
but:
(cond
(and foo bar) nil
(false? something) nil
(something_else) nil
:else (dosomething))
is effectively the same
maybe at that point I'd do:
(when-not (or (and foo bar)
(false? something)
(something_else))
(dosomething))
from what I can figure out i need to use a wagon in deps.edn but not finding anything online
clj does not have support for custom wagons/transporters right now
filing a request at https://ask.clojure.org would be a great place to make a votable thing that we can track
the underlying tools.deps lib does support custom procurers but does not specifically support custom transporters or wagons, but that is possible to add
okay thanks for the info, i was about to ask on reddit 🙂 I will post on ask.clojure as suggested
well posting there will cause nothing to change if that is your goal
http://ask.clojure.org is where we collect and determine the priority of requests
it is github only right now
most devs have a github acct so that has not generally been an impediment so far. if you don't have one, I can file a request for you there
that would be very helpful, I am also a bit suspect of the legitimacy of that site as it has various issues or perhaps its just very new
https://ask.clojure.org is the official clojure Q&A site run by the core team, of which I am a member. I run it.
I'm also the primary dev on tools.deps and clj
that does look like the mobile layout - but it's a responsive layout so looks different as you widen it
I get column if i widen it and a categories box, not try to offend just thought i would point out if there is an issue
good work on tools.deps anyway I actually really like it as a build tool for managing my projects
I logged this at https://ask.clojure.org/index.php/9804/add-support-for-google-artifact-registry-tools-deps-and-clj and https://clojure.atlassian.net/browse/TDEPS-172 btw
{:mvn/repos
{"artifactregistry" {:url ""}}}
I have added the above to deps.edn but seems it does not understand artifact-registry from what i can work out it needs to launch something to add that protocol format, not finding any details on how to go about that how ever 😞I have read a bunch of stuff about spec, but still don't understand when I am supposed to use it. Should I spec every function definition? What about the performance costs of that? Also, spec suggests that the keywords I use in hash-maps should be namespaced, is that a standard practice? I haven't seen that recommendation anywhere else I think, besides fulcro docs maybe.
I believe it is fairly common for those who use spec to use it in production only to check inputs at the boundaries of major subsystems, e.g. for requests from outside of one piece of software, or perhaps sometimes between major subsystems. The run-time cost can be mitigated by being selective. For test time, it can be worth the extra checking time to enable checking at many more places. For testing individual functions or groups of your functions, generative testing, e.g. with test.check can help provide good test coverage at test time.
Is this one of the articles you read on spec? It is written by a long time Clojure developer who has used spec in their production Clojure code for several years now.
No, I don't think I have read that one, thank you!
So I should define some of the specs inside test namespaces then, if I want them to run during test time?
I believe some people create completely separate namespaces for spec definition, so that they can be loaded only when desired. By doing that, they can be loaded at test time, true, but they can also be loaded at production time without loading in all of the test code.
I see, makes sense, thank you. I'll read the post and ask more questions if I have any.
Probably the only reason the author didn't answer your question before I did is because it is very early Pacific time right now 🙂
seems mixing lein and deps.edn using this plugin https://github.com/lurodrigo/lein-artifact-registry/ and then using lein-tools-deps to read the deps.eddn file seems the dependencies are merged would be nicer to do this all in deps file if its possible ?
see my thread above
do I get it right that clojure.core.async/go
and future
have the exact same purpose, except for their respective thread/pool subtelties?
and then, considering the error handling overhead that comes with future
, I should use go
if I don't care about threading boundaries?
I'd say they have entirely different purposes actually but if you're not doing any async ops, I'd use future
what do you mean, "not doing any aync ops"?
parking ops like >! <! etc
my actual current project uses futures, but I never dereference them (their purpose is network side-effects)
you should not do blocking io operations in go blocks
and I'm really torn between keeping them and using core.async
as it is a fixed size pool and you can lock it up that way
it does not seem like you have a use case that matches core.async afaict
and using go blocks with futures inside for the IO parts, would be overkill?
I guess I really don't like the errors popping in places totally different from the actual crash place (I use try/catches with every futures), and naively believe that go blocks would somehow solve the problem
yeah, it would not help you with that
it does not seem like core.async solves any problem you have and likely introduces new ones :)
ok let's avoid that pitfall then, thank you!
Hi, I dont know if is a bug, but last week, this work like that:
> (format "%.3f" 2.0)
"2.000"
Now the same thing is giving to me:
> (format "%.3f" 2.0)
"2,000"
@contato509 that looks like something that would be controlled by the LOCALE
environment variable
oops - not LOCALE itself, but the locale system, that uses LANG, LANGUAGE, LC_CTYPE, LC_NUMERIC etc. (on linux at least)