Fork me on GitHub

Hey guys. I’m hand-rolling my own solution for a static site generator. Now I’d like to have multilingual support, I’m wondering what the best way to go about that is. I assume I’ll have to deal with routing eventually, using something like bidi or reitit. What other things should I consider in order to keep things neat?


Hi everyone, I'm looking for something I encountered before (but can't think of the right search terms). What is the website that analyses clojure code and helps you to "fill in the blanks" of the code using core.logic (?) which is based a haskell's implementation


Something simliar to lein kibit it helps to fill in the blanks based on the output


not core.logic based, but a similar idea,


I haven't seen this before, this looks quite useful! I also like the way the examples slowly cycle, that is a really nice touch that I have not seen before.


Thanks! 🙂


Team I am trying to add all the name from database to vector and I wrote below code


(let [name (.next list-of-statement)
            v (conj [] (->> name (.getName) (.toString)))]


this code can’t return nil because (conj [] …) will return a vector


ya empty vector,, how can I append values?


empty vector or [nil]?


Even (conj [] nil) returns [nil] , i.e. a vector with one element (which is nil), so I don't see how that expression you gave can possibly return an empty vector.

👍 3

i want to add each value of (->> name (.getName) (.toString))


is it possible that this peace is working in bigger context? I’m expecting you are trying to append an element to vector in a loop

Daniel Stephens12:02:10

is list-of-statements an iterator? If so you could use iterator-seq to turn it into a seq which is a lot easier to work with. Then you can use more standard/idiomatic clojure.

(do (defn db-values [] (iterator-seq all-db-vals-iterator))

    (defn db-value-name [db-value] (-> db-value (.getName) str))

    (defn db-value-names (->> (db-values)
                              (map db-value-name))))


Is list-of-statement a Java Iterator object?


(recur (.listStatements name) giving me infinite object


See comment above about iterator-seq which looks like good recommendation


it returns nil because of immutability


how can I get all the names into vactor from database


Hi there. Can anyone give me a recommendation on what good mock/spy/stub testing library to use in Clojure/Script? Thanks in advance.


Did a quick googling and there's but I'm just wondering what other good library I might miss out on 🙂


You can also use with-redefs fn's from the standard library to mock out functions I do this in tests to avoid a db hit and return the rows I need for my test if your not aware of these functions.


the best way (imho) to get advantage from mocking/stubbing/spying is to make such ability first-class citizen in your application. libraries for dependency injections will help a lot there. You could have a look at integrant for example.


Thanks guys. I just need a way to do some simple testing for a small project I'm working in. At this scale I don't think I'd need something like Integrant, but thanks regardless 🙂

Illia Danko14:02:16

Good day. I'm curious is there any guide about the argument position convention of clojure.core? I know some excerpts are: • Object as the first argument • Sequence as the last argument But every time I confuse where to put a numeric argument and also the last bullet not 100% truth.


some info about that topic - not complete answer thou

Eamonn Sullivan17:02:31

Hopefully a quick one: Is there a usual approach for mocking a function to first throw an exception and then return something else? I'm trying to test a catch clause. In mockito I would have done something like andThen ...


like the first invocation would throw and subsequent invocations would return a value?

Eamonn Sullivan17:02:17

yes, that's what I'm doing in this particular case.

Eamonn Sullivan17:02:03

But having a pattern for returning one value, then another, etc., would be useful. The thing I'm mocking is making a REST call and returning the response, so it's not pure.

Eamonn Sullivan17:02:39

In another project, I did this with an atom holding a list and then popped them, but I must have done it wrong, because it's flaky. I'm hoping someone has a tried and true pattern.

Eamonn Sullivan17:02:21

Or it's just a feature of clojure.test I'm missing, and I don't have the right terms to google.


clojure test doesn't have any mocking functionality. its just assertions and such. if you're single threaded its possible to use with-redefs and temporarily replace things with functions that do what you want. if you've got a system engineered where you construct a system graph, you could construct it with subsystems that do what you want


For mocking out REST calls, I use wiremock

Eamonn Sullivan17:02:29

Ah, yeah, that's what I use in Scala (the Java version of that). I always forget I've got the whole JVM world to draw on...


there's no access to the jvm from scala?

Eamonn Sullivan18:02:04

Yes, of course, but Clojure is so different that it just doesn't occur to me as easily. I just forget!


indeed, tis a beauty 🙂


     [{:req [:GET (str "/tenant/v1/" rsc-tenant-id)] :res [200 {:body (utils/map->string {:tenantCode rsc-tenant-code})}]}]
     (->> (generate-email-payload rsc-investigations rsc-tenant-code 12 app-config)
          (expect (assoc rsc-email-configuration :body email-body))))))


bit like that 🙂

Eamonn Sullivan17:02:33

Right, so I can make the first attempt return some non-200 (404) and then return a 200. Got it. Looks like what I want. Thank you!


Is there a CLJ(S) library out there to make and subscribe to cursors from an atom?


Is there a good way to make a transit api request from the CLI?


I have a list of dictionaries as such:

[{:id 1 :key 1 :value 1}
 {:id 1 :key 0 :value 0}
 {:id 2 :key 1 :value 1}
 {:id 2 :key 0 :value 0}]
and id like to group this list by id as such:
[{:id 1 :attributes [{:key 1 :value 1} {:key 0 :value 0}]}
 {:id 2 :attributes [{:key 1 :value 1} {:key 0 :value 0}]}]
This wouldnt be too hard in python but im scratching my head for how to write this in clojure 😅


clojure.core/group-by or clojure.set/index


thanks! will go do some doc reading 🙂