This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-11
Channels
- # announcements (18)
- # beginners (57)
- # calva (20)
- # cider (4)
- # cljdoc (15)
- # cljs-dev (14)
- # clojure (124)
- # clojure-europe (5)
- # clojure-italy (5)
- # clojure-nl (10)
- # clojure-spec (4)
- # clojure-uk (44)
- # clojurescript (4)
- # clojutre (18)
- # clr (2)
- # cursive (25)
- # datomic (53)
- # emacs (18)
- # events (1)
- # figwheel-main (1)
- # fulcro (34)
- # joker (6)
- # kaocha (13)
- # nrepl (3)
- # nyc (24)
- # off-topic (1)
- # pathom (16)
- # protorepl (4)
- # re-frame (1)
- # reitit (27)
- # rewrite-clj (5)
- # shadow-cljs (38)
- # spacemacs (25)
- # sql (20)
- # vim (28)
- # xtdb (20)
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?
s/def is a macro and expects forms, not things to evaluate so most stuff like this won't work well
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?
spec 2 has much more extensive support for this
o.o spec2
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: https://github.com/yogthos/krueger
@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
@UBEP9B508 After scanning quite a few projects I think metabase could serve as an example: https://github.com/metabase/metabase/tree/master/src/metabase/api 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
1
2
3
echo -n 'line 1\nline 2\nline 3\n' | clojure in.clj
1
2
3
in.clj
:
(import ( BufferedReader))
(doseq [ln (line-seq (BufferedReader. *in*))]
(-> (clojure.string/split ln #" ")
second
read-string
prn))
@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
) :Sin.clj
with io/reader
instead of BufferedReader
:
(doseq [ln (line-seq ( *in*))]
(-> (clojure.string/split ln #" ")
second
read-string
prn))
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
1
line 2
2
line 3
3
is there a good way to do rename-keys but I'd like to use regex to change the keys
for some reason Datomic ions is giving me system parameters like
{"/hello" "world"}
where I'd like {"hello" "world"}
echo -n 'line 1\nline 2\nline 3\n' | clojure in.clj
1
2
3
in.clj
:
(import ( BufferedReader))
(doseq [ln (line-seq (BufferedReader. *in*))]
(-> (clojure.string/split ln #" ")
second
read-string
prn))
@sfyire One way that seems to work is mapping the keys with a string function (zipmap (map #(clojure.string/replace % #"/" "") (keys m)) (vals m))
look at load
or load-file
probably the latter if you're doing file stuff
But these scripts dont have namespaces so my world is upside down in terms of understanding
load-file is just like typing that stuff in in the current namespace context
(probably user
effectively)
Anyone could point me how I could interop C/C++ with Clojure? :)
Not at all :)
I am big JVM newbee
What is the difference with JNA?
This may also be handy: https://clojure.org/reference/java_interop
Thanks!
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.
https://github.com/jnr/jnr-ffi 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)
Hello everyone. Question: this fails with a syntax error, but looks like it should work:
(->> (constantly 1)
())
Looking at the source code at https://github.com/clojure/clojure/blob/clojure-1.9.0/src/clj/clojure/core.clj#L1696 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...