Fork me on GitHub

Hi everybody ! anybody got any issues ?


I'm trying to programatically build specs to match the data types of my target system The second form below fails `Assert failed: k must be namespaced keyword or resolvable symbol (c/and (ident? k) (namespace k))` even though the first parameter to both is a qualified-keyword `(s/def ::foo string?) (s/def (keyword (namespace ::here) (name :foo)) string?)` Is there a better way to go about this?

Alex Miller (Clojure team)00:09:09

s/def is a macro and expects forms, not things to evaluate so most stuff like this won't work well

Alex Miller (Clojure team)00:09:23

you can wrap it in another macro or use eval


yeah are you making a macro that is gonna write spec code that gets expanded later?

Alex Miller (Clojure team)00:09:36

spec 2 has much more extensive support for this


Thanks for the explaination, I'll try one of those options


Hey folks 👋 ! Is there a big-ish JSON-API that's open source that one could take a look at were one to write such a thing?


I assume you ask for a Clojure app. Although I know nothing about this one it looks interesting:


@U06BE1L6T yes should be written in clojure sorry 😅 krueger looks like you can get some good api basics from it but nothing too major. The reason I ask is that, while learning Ruby, I could always have a look at the source code for gitlab to how a well established, commercial app solved some of the issues I had. I was hoping for something in that vein for clojure as well


I don't think you're going to find such a large commercial open-source example


What scalewe're talking about?


(especially for #beginners ?)


@UBEP9B508 After scanning quite a few projects I think metabase could serve as an example: But again, it can also be misleading especially if we're talking about #beginners


Thanks! Thats exactly the scale I'm talking about. You're right that this may be a bit much for the #beginners , but I do consider myself a beginner so 😅


hi everyone, I am struggling with STDIn and STDOUT in Clojure, hope you can help me. The problem is that I have a multiline STDIN, like this for example:

line 1
line 2
line 3
let's say i want to print only the line number for each line only after all the lines have been input in the STDIN, so that the results is this:
;; input
line 1 
line 2
line 3

;; output


echo -n 'line 1\nline 2\nline 3\n' | clojure in.clj
(import ( BufferedReader))

(doseq [ln (line-seq (BufferedReader. *in*))]
  (-> (clojure.string/split ln #" ")


@U3D7T0REF: is this what you are looking for?


mm i think so, however i need to wrap it in my main- fn. at the moment i start my app with lein run <args> (i need one arg to do some stuff), then i use the following:

(with-open [reader (io/reader *in*)]
        (println "Please insert your input:")
        (doall (map (partial process-line time) (line-seq reader))))
the doall do the trick of printing everything at the end, while doseq was printing the result after each new line of the stdin. this kind of works, however i can never "exit" the stdin without shutting down the whole app (using System/exit) :S


nvm, i think I got it! 😄 many thanks @U0FEHF1RS!

👍 4

in.clj with io/reader instead of BufferedReader:

(doseq [ln (line-seq ( *in*))]
  (-> (clojure.string/split ln #" ")


i also tried with io/reader but still couldn't get out of the stdin input, both from the app and the from the repl :S however, i was focusing too much on the user's input after starting the app with lein run instead of the echo/`cat` commands. now the app works both ways, will decide if i want to keep the System/exit to exit the app after lein run


read-line and line-seq with doseq process one line at a time, and the result is something like:

line 1
line 2
line 3

Adrian Smith16:09:16

is there a good way to do rename-keys but I'd like to use regex to change the keys

Adrian Smith16:09:43

for some reason Datomic ions is giving me system parameters like

{"/hello" "world"}
where I'd like
{"hello" "world"}

Markus Kiili17:09:46

@sfyire One way that seems to work is mapping the keys with a string function (zipmap (map #(clojure.string/replace % #"/" "") (keys m)) (vals m))

Mario C.18:09:58

How can I include a clj script file in another one?

Alex Miller (Clojure team)18:09:08

look at load or load-file

Alex Miller (Clojure team)18:09:26

probably the latter if you're doing file stuff

Mario C.18:09:03

I want to re-use functions defined in another script'

Mario C.18:09:21

But these scripts dont have namespaces so my world is upside down in terms of understanding

Mario C.18:09:23

I think this what I am looking for

Alex Miller (Clojure team)18:09:45

load-file is just like typing that stuff in in the current namespace context

Alex Miller (Clojure team)18:09:05

(probably user effectively)

David Pham21:09:57

Anyone could point me how I could interop C/C++ with Clojure? :)


I can't imagine it's any different than regular JNI..


Are you familiar with JNI?

David Pham21:09:23

Not at all :)

David Pham21:09:40

I am big JVM newbee


That's the java native interface for calling into C/C++


but.. it's a bit of an advanced topic

David Pham21:09:07

What is the difference with JNA?


I'm not familiar with JNA, JNA looks like a wrapper on top of JNI


Maybe JNA is easier to get started with than JNI?


For a JVM newbee, I would strongly recommend JNA for C/++ interop. JNI is a cumbersome bear. I'd start purely with a small Java project first, get your JNA interop working & proven out. Then go to Clojure and interop with your Java (which should be an easier last-step). Then watch Inception.


you may also want to check out tools like swig

hiredman21:09:39 is also a neat thing, which I have never actually used, but I get the sense it is intended to provide a good ffi experience on the jvm (I think the jruby uses it for ffi stuff)

👍 4

Hello everyone. Question: this fails with a syntax error, but looks like it should work:

(->> (constantly 1)
Looking at the source code at it's quite clear why it fails, (first form) is nil. I'm not sure why the source code uses (~(first form) ~@(next form) ~x) instead of a simple (~@form ~x) though. Any ideas?


Hmm, I remember that being discussed somewhere at one time but I can't remember where right now...