This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-29
Channels
- # babashka (64)
- # beginners (60)
- # calva (10)
- # circleci (3)
- # clj-kondo (62)
- # cljdoc (6)
- # clojars (2)
- # clojure (152)
- # clojure-europe (19)
- # clojure-nl (3)
- # clojure-uk (18)
- # clojurescript (50)
- # clojureverse-ops (12)
- # core-async (21)
- # cursive (6)
- # data-science (1)
- # datomic (17)
- # events (14)
- # fulcro (64)
- # graalvm (20)
- # graphql (5)
- # honeysql (14)
- # jackdaw (3)
- # jobs (1)
- # jobs-discuss (22)
- # kaocha (2)
- # lsp (9)
- # luminus (8)
- # malli (30)
- # meander (31)
- # other-languages (1)
- # polylith (8)
- # re-frame (15)
- # shadow-cljs (85)
- # specter (2)
- # sql (11)
- # tools-deps (56)
- # vim (39)
- # vscode (7)
- # xtdb (16)
noob question: If I've got a nested map structure... like so : {:top {:name "blah" :data {:entry1 "asdf" :entry2 "asdf"}}}
Is there a way of accessing the entry2 value like in other languages...? e.g. in python it'll accessed by <mapname>[top][data][entry2]
. The clojure notation that I've figured out so far is a lot of nested :keyname calls to the map... (:entry2 (:data (:top <mapname>)))
the "thread first", ->
macro is commonly used for this
(-> my-map :top :data :entry2)
Is there anything better than threading? This is why I was investigating the double colon notation, hoping that it'll help with resolving nested maps... but thanks for your help!
better how?
<mapname>[top][data][entry2]
and (-> my-map :top :data :entry2)
look very, very similar to me.
I don't know how
just asking
(and I prefer the latter due to "less syntax noise")
I think this is just a matter of familiarity. The more you use Clojure, the more natural this will seem to be (and the more ugly/verbose other languages will look).
thanks for that!!
It's definitely one of those things where I thought the threading macro was this really weird thing when I first saw clojure, and now I get really annoyed when I try to write js or python 🤷
it is definitely hard to wrap my head around the threading macro as my head is still thinking in C/python
practice makes perfect ... I guess
yea, I remember the threading macros being pretty jarring at first, but they grow on you after a while.
They're a little more flexible than the bracket syntax and they tend to work more universally in clojure since almost everything is immutable and returns a value. You don't have to go out of your way to write your api to return its value: eg. builder().addThing("asdf").timeout(10).execute().after(cleanup)
Are there libraries I might want to look if I want to take a video like say an .mp4 file and produce pixelized colour data of the frame by frame images
What's the recommended way to programmatically generate maps/edn that include custom tagged literals? Something like this:
{:db-spec {:host #aws/ssm "/app/_/db/env/host"
:db-name #aws/ssm "/app/_/db/env/db-name"
:user #aws/ssm "/app/_/db/env/username"
:pass #aws/ssm "/app/_/db/env/password"}}
In particular, is there a way than doesn't directly involve string manipulation?{:db-spec {:host (tagged-literal 'aws/ssm "/app/_/db/env/host")
:db-name (tagged-literal 'aws/ssm "/app/_/db/env/db-name")
:user (tagged-literal 'aws/ssm "/app/_/db/env/username")
:pass (tagged-literal 'aws/ssm "/app/_/db/env/password")}}
That seems to work (with a small modification):
(tagged-literal 'aws/ssm "/app/_/db/env/password")
=> #aws/ssm/app/_/db/env/password
(tagged-literal 'aws/ssm " \"/app/_/db/env/password\"")
=> #aws/ssm "/app/_/db/env/password"
Thanks a lot, that's exactly what I need 🙂user=> (tagged-literal 'aws/ssm "/app/_/db/env/password")
#aws/ssm "/app/_/db/env/password"
are you sure this modification is needed?Weird, it's not working like that on my end
strange. tagged-literal is a function of two arguments. Could it be a problem of the editor?
works just fine in sublimetext
Oh, I'm an idiot... I was in a clojurescript namespace/repl before, sorry. It works fine in clojure!
I would like to practice creating some programs in clojure... is there a puzzle book which forces one to think in clojure ways? ... I know... I am silly that way... 😁
try https://www.4clojure.com/! try to solve problems and after you’ve solved them look at other people’s solutions, that was a huge eye-opener for me when I started out
(there seems to be some certificate issue with the site, but it expired just a few days ago so I’m sure they’ll fix it soon)
this site doesn't work for me. FYI
@U022LK3L4JJ 4clojure is shutting down, but @U013MQC5YKD has made a CLJS replacement here: https://4clojure.oxal.org/
found it!! Thanks!
There's also Clojure Koans
I figured something was up with 4clojure because it's been giving that outdated certificate error for a while now...
Hello Hello everyone ! Is there a "clean" way to use a higher version of java library that is also a transient dependency of another package ? (using the newer version breaks the package)
Can you give an example? Hopefully you've already looked at exclusions
in https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L55 and https://clojure.org/reference/deps_and_cli#_dependencies.
we're using lein ! to be specific we use dk.ative/docjure that has a dependency on org.apache.poi, I'd like to use that library directly to work with charts (no support for that in the clojure library)
[dk.ative/docjure <version> :exclusions [org.apache.poi/poi]]
[org.apache.poi/poi <version>]
Should work unless docjure specifically depends on that particular version of org.apache.poi/poi
yeah I think it does depend on 4.1.1 specifically, a colleague told me that, I'll just check myself to confirm.
yep it does break with a higher version
I'm looking at https://github.com/benedekfazekas/mranderson right now, but if you have any other suggestions they would be much appreciated ! thanks for your help !
What's the best way to check whether there's something in an atom in a non-blocking style? (deref a 100 :timeout)?
Atom reads are not blocking; just use deref
or @
and you're good to go.
If you want the details: when you deref an atom, it just calls https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/atomic/AtomicReference.html#get().
if you want a thing that you wait for a result on on a max delay, you probably want a promise
Ah I see! Thanks!
I have two future
s running at the same time. Currently (as a hack) I use (Thread/sleep n)
so the main thread wouldn't quit, which is what happens without it, the main thread quits immediately without the futures actually ever finishing.
How do I I wait for both of these futures to finish before quiting?
That was a really interesting question, but it's gone now 😕
effectively no. (length of function names). It seems classfile names are limited to 65535 characters. So the munged namespace and function name cannot exceed that.
For posterity: someone asked what is the maximum length of a function name
I couldn't find a limit either, to speak of. It seems likely that you'll run into file name length limitations before anything else.