Fork me on GitHub

Howdy y'all! Is there a formatter for edn files? one that adds indentation and line breaks?


What is the output of clojure -Sdescribe ?


It might be that you have an older version of the Clojure CLI tools than Sean was using when creating those files -- there have been changes in the last few months, especially around handling of the -X command line options.


They asked this in #clj-new and it's because they have ... in deps.edn which causes the map literal error.


if I have a regex, is there a way to get a match object that has indices of groups instead of the groups themselves?


e.g. if I have .(.)x or something I’d like the indices of where each part starts and ends


The underlying Java APIs used by Clojure/JVM to do regex matching should provide these indexes. IIRC using those indexes is exactly how Clojure determines the substrings of the input string to return for the match groups.


Look at the methods start and end for the class java.util.regex.Matcher :


Thank you 🙂 that should do the trick


Finally looking at this, this is a great example of why mutability is a nightmare. This is so hard to work with!


It certainly can be. In this case, as long as you copy all of the pieces of a match result out of a mutable JVM object before using it again, you should be good.


Trying to do “Web Development with Clojure 3rd edition” and after creating the base app with luminus and h2 as suggested, still getting “No suitable driver” for database connection. H2 dependency is there. What the heck?


Everything is saved, and your REPL was restarted after adding the dependency?


@U01NN34TJUB I saw that you’d posted this same Q on StackOverflow so I’ve followed up there — I can’t repro the error based on the information you’ve provided so far (my answer shows the steps that work).


Yeah it’s silly, I literally created and ran. Which by all accounts should just work. Figure I missed a step. I’ll look at more tonite. Didn’t spend much time since I figure was a stupid omission that is common


If you update your SO post with any new information, LMK, so I can update my answer.


Hi team, please suggest a logging tool for Clojure application?



thanks2 3

@vnazaryan Now I’m at my desk I can expand on my answer: using, it will look for a Java logging library on your classpath. It looks for known libraries in a particular order, starting with slf4j. At work, we’ve decided to use log4j2, and we “bridge” all the other logging libraries over to log4j2 by having these dependencies in our project:

;; use log4j 2.x:
    org.apache.logging.log4j/log4j-api {:mvn/version "2.13.3"}
    ;; bridge into log4j:
    org.apache.logging.log4j/log4j-1.2-api {:mvn/version "2.13.3"}
    org.apache.logging.log4j/log4j-jcl {:mvn/version "2.13.3"}
    org.apache.logging.log4j/log4j-jul {:mvn/version "2.13.3"}
    org.apache.logging.log4j/log4j-slf4j-impl {:mvn/version "2.13.3"}
And we also have to tell to select log4j2 instead of just whatever it finds first (since most non-trivial apps end up with multiple logging libraries in play) so we pass this JVM option:
(how exactly you pass that in will depend on what tooling you’re using to run/test/build your program)


Also if you’re confused about various Java logging libraries (as most of us are) here’s some background:


>> (type (cons "asdf" [1 2 3]))
clojure.lang.Cons // expecting this to be persistentList
Any idea why this not persistentList.


If that where so what would happen if you did (cons 1 (range))


and also from the docstring you should not have that expectation: > clojure.core/cons > ([x seq]) > Returns a new seq where x is the first element and seq is > the rest.


I think my understanding of seq is flawed, cons returns a seq but why does the type say clojure.lang.Cons?


(seq? (cons "asdf" [1 2 3])) ;; true


this guide is by far the most authoritative:


but the short and sweet is that, if you're familiar with other lisps, seq provides the "car" and "cdr" to many different types not just the two pointer cons cell

👍 3