This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-28
Channels
- # announcements (9)
- # aws (2)
- # beginners (45)
- # biff (2)
- # calva (20)
- # cider (4)
- # cljdoc (15)
- # cljs-dev (9)
- # clojure (102)
- # clojure-austin (14)
- # clojure-europe (39)
- # clojure-france (3)
- # clojure-germany (1)
- # clojure-norway (39)
- # clojure-spec (1)
- # clojure-uk (3)
- # conjure (8)
- # cursive (6)
- # datahike (3)
- # datomic (8)
- # emacs (28)
- # events (1)
- # holy-lambda (6)
- # hyperfiddle (13)
- # jobs (11)
- # keechma (2)
- # lsp (4)
- # malli (33)
- # nbb (36)
- # off-topic (52)
- # pathom (5)
- # pedestal (2)
- # portal (1)
- # reagent (2)
- # reitit (3)
- # remote-jobs (1)
- # scittle (1)
- # spacemacs (2)
- # xtdb (5)
I'm trying to translate (or rethink) a snippet from JS to clojure. It's an event handler that is supposed to update some data when the callback is called. Any way to achieve this without mutation?
let tree = …;
el.addEventListener('click', () => { tree = updateTree(tree); });
You can store the tree as an atom and reset it to the new state once the callback is fired. This is also kinda mutation but at least you will use mutable data structures designed for that instead of resetting a var
Hi there. Is there, currently, any way to write to a file raw string form? I’m working with CSV right now and currently if I do (.write (io/writer "some-file") {"category":[{"id":1,"name":"Just some category","type":"Category"}]})
then it will just write that string as-is to the file, which is
{"category":[{"id":1,"name":"Just some category","type":"Category"}]}
whereas I’m looking for
"{\"category\":[{\"id\":1,\"name\":\"Just some category\",\"type\":\"Category\"}]}"
Thanks in advance 🙂@U24QP2D4J Encode how though? I’m lost here 😅
greetings. best place to start from absolute scratch?
http://braveclojure.com is the (free) book that's generally recommended
https://clojure.org/guides/getting_started then https://clojure.org/reference/reader
Depending on your background, in addition to the resources already mentioned, try https://clojure.org/community/resources#_tutorials_and_learning_materials https://practical.li/
Thank you! Will have a look
https://aphyr.com/posts/301-clojure-from-the-ground-up-welcome I like this series a lot. Detailed enough that I still get bits of insight out of it when I re-read it.
If you have front-end (React & co) background or target it, you can also bookmark: • https://www.learnreagent.com/ • https://www.learnreframe.com/
First part of learnreagent course is free.
And for the back end: https://www.learnreitit.com/
There are 100+ hours of video covering basic Clojure development and solving small challenges on my website https://practical.li/
How do I go about copying a large data structure from my program into an EDN file so the spacing is nice?
Is it just a matter of doing something like (spit "output.edn" (pprint ds))
to skip the manual copypasta altogether?
depends, I might instead rebind *out*
to a printer writer that would write to the file

Hi everyone, quick Java interop question: How do I represent something like
SubscriptionCreateParams.Item.builder()
in Clojure?
If needed, these links can provide context:
• https://stripe.com/docs/billing/subscription-resource?ui=API#create-a-subscription-through-the-api
• https://stripe.dev/stripe-java/com/stripe/param/SubscriptionCreateParams.htmlInner classes use a dollar sign, e.g. in this case IIRC you'd import com.stripe.param.SubscriptionCreateParams$Item
and then do (SubscriptionCreateParams$Item/builder)
I generated some uuids with (random-uuid)
and saved them to my database. Now when I get the values from my DB and try to use them, some of them give me an error:
(identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
; => Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
I don't understand how this could happen. Did I just make a sloppy mistake somewhere in storing the data or is there some other potential cause?works fine in a vanilla clojure repl
% clj
Clojure 1.10.3
user=> #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
user=>
the issue is whatever bit of tooling you are using is sitting between you and the repl trying to do stuff with the results from the repl, and the tooling doesn't understand the uuid literal
java.lang.ExceptionInInitializerError
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at clojure.lang.Compiler$ObjExpr.eval(Compiler.java:5008)
at clojure.lang.Compiler.eval(Compiler.java:7193)
at clojure.lang.Compiler.eval(Compiler.java:7149)
at clojure.core$eval.invokeStatic(core.clj:3215)
at clojure.core$eval.invoke(core.clj:3211)
at nrepl.middleware.interruptible_eval$evaluate$fn__67379$fn__67380.invoke(interruptible_eval.clj:87)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$apply.invoke(core.clj:662)
at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1999)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at nrepl.middleware.interruptible_eval$evaluate$fn__67379.invoke(interruptible_eval.clj:87)
at clojure.main$repl$read_eval_print__9206$fn__9209.invoke(main.clj:437)
at clojure.main$repl$read_eval_print__9206.invoke(main.clj:437)
at clojure.main$repl$fn__9215.invoke(main.clj:458)
at clojure.main$repl.invokeStatic(main.clj:458)
at clojure.main$repl.doInvoke(main.clj:368)
at clojure.lang.RestFn.invoke(RestFn.java:1523)
at nrepl.middleware.interruptible_eval$evaluate.invokeStatic(interruptible_eval.clj:84)
at nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:56)
at nrepl.middleware.interruptible_eval$interruptible_eval$fn__67412$fn__67416.invoke(interruptible_eval.clj:152)
at clojure.lang.AFn.run(AFn.java:22)
at nrepl.middleware.session$session_exec$main_loop__67672$fn__67676.invoke(session.clj:218)
at nrepl.middleware.session$session_exec$main_loop__67672.invoke(session.clj:217)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NumberFormatException: Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
at clojure.lang.LispReader.readNumber(LispReader.java:352)
at clojure.lang.LispReader.read(LispReader.java:278)
at clojure.lang.LispReader.read(LispReader.java:216)
at clojure.lang.LispReader.read(LispReader.java:205)
at clojure.lang.RT.readString(RT.java:1876)
at clojure.lang.RT.readString(RT.java:1871)
at com.example.playgrounds.pathom$eval123662.<clinit>(NO_SOURCE_FILE:122)
... 32 more
I'm trying to understand what bit of tooling could be at fault here..but I would start by looking for any nrepl middleware / plugins / whatever and disabling them
Thanks @U0NCTKEV8.