beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
vlad_poh 2021-03-21T10:05:52.198900Z

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

dharrigan 2021-03-21T10:48:23.199100Z

Maybe this? https://github.com/kkinnear/zprint

šŸ‘ 1
ā˜ļø 1
Aya 2021-03-21T13:56:53.199600Z

Aya 2021-03-21T13:57:08.199700Z

Aya 2021-03-21T13:57:17.199800Z

Aya 2021-03-21T13:57:26.199900Z

2021-03-21T14:28:05.200Z

What is the output of clojure -Sdescribe ?

2021-03-21T14:28:43.200200Z

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.

grazfather 2021-03-21T15:09:55.201400Z

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

grazfather 2021-03-21T15:11:06.202500Z

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

grazfather 2021-03-27T14:47:22.195500Z

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

2021-03-27T14:57:12.195700Z

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.

2021-03-21T15:21:09.202700Z

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.

2021-03-21T15:22:56.202900Z

Look at the methods start and end for the class java.util.regex.Matcher : https://docs.oracle.com/javase/9/docs/api/java/util/regex/Matcher.html

Todd 2021-03-21T15:29:16.204500Z

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?

grazfather 2021-03-21T15:55:29.204600Z

Thank you šŸ™‚ that should do the trick

Karo 2021-03-21T15:59:04.205300Z

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

javahippie 2021-03-21T16:34:35.205500Z

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

seancorfield 2021-03-21T17:08:08.206900Z

@vnazaryan clojure.tools.logging

1
seancorfield 2021-03-21T17:10:06.207300Z

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

seancorfield 2021-03-21T18:09:00.207500Z

@twcrone 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).

seancorfield 2021-03-21T18:12:51.212600Z

@vnazaryan Now Iā€™m at my desk I can expand on my answer: using clojure.tools.logging, 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 clojure.tools.logging 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:
-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory
(how exactly you pass that in will depend on what tooling youā€™re using to run/test/build your program)

Todd 2021-03-21T18:14:07.214300Z

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

1
seancorfield 2021-03-21T18:14:40.214600Z

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

valtteri 2021-03-21T19:41:45.216400Z

Also if youā€™re confused about various Java logging libraries (as most of us are) hereā€™s some background: https://lambdaisland.com/blog/2020-06-12-logging-in-clojure-making-sense-of-the-mess

piyer 2021-03-21T19:41:56.216700Z

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

dpsutton 2021-03-21T19:47:24.217500Z

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

dpsutton 2021-03-21T19:53:45.218100Z

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.

piyer 2021-03-21T20:42:11.218200Z

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

piyer 2021-03-21T20:43:53.218400Z

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

dpsutton 2021-03-21T20:55:20.218600Z

this guide is by far the most authoritative: https://clojure.org/reference/sequences

dpsutton 2021-03-21T20:55:55.218800Z

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

šŸ‘ 1