Fork me on GitHub

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>)))


(get-in <mapname> [:top :data :entry2])


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!


<mapname>[top][data][entry2] and (-> my-map :top :data :entry2) look very, very similar to me.


(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).


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.

👍 3

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! 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:


There's also Clojure Koans

Andrew Berrien16:07:29

I figured something was up with 4clojure because it's been giving that outdated certificate error for a while now...

Fahd El Mazouni13:07:36

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)


what tool are you using to manage deps? lein? deps.clj?

Fahd El Mazouni14:07:13

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

Fahd El Mazouni14:07:46

yeah I think it does depend on 4.1.1 specifically, a colleague told me that, I'll just check myself to confirm.

Fahd El Mazouni14:07:58

yep it does break with a higher version

Fahd El Mazouni14:07:21

I'm looking at right now, but if you have any other suggestions they would be much appreciated ! thanks for your help !

Jakub Šťastný16:07:33

What's the best way to check whether there's something in an atom in a non-blocking style? (deref a 100 :timeout)?

Russell Mull16:07:40

Atom reads are not blocking; just use deref or @ and you're good to go.


if you want a thing that you wait for a result on on a max delay, you probably want a promise

Jakub Šťastný16:07:35

Ah I see! Thanks!


that or a chan


(if you include core async)

Jakub Šťastný17:07:55

I have two futures 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?


(run! deref [fut1 fut2])

👍 3
Russell Mull17:07:52

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.

🎯 3
Russell Mull17:07:11

For posterity: someone asked what is the maximum length of a function name

Russell Mull17:07:10

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.