Fork me on GitHub

@genec Atom tooling is much more polished than the VS Code options. I would recommend using Atom+Parinfer+ProtoREPL. There's a #protorepl channel for assistance.


@mikeb Thanks for the advice. That was my impression after trying both this afternoon. I prefer VS Code over Atom as an editor, but the Clojure support in Atom does seem more mature, but VS Code support is pretty good too. The proto-repl charts are a nice bonus too.


My favorite part of protorepl is the inline repl results. That said I really love VS Code as well, just not for clojure yet.


I've been using IntelliJ with Cursive


it's not bad, but it's a little finicky with formatting


maybe i'll try the atom route


but intelliJ is just so much smarter and more IDE-like than Atom


i was wandering how to configure postgresql with my SPA. I'm using IntelliJ with Cursive on windows


how can I filter a map. I want to keep all that have a certain field value and don't want to turn the result into a list


@hotbelgo Just change odd? in the above example with your predicate.


thanks - are you human or bot?


what does comp achieve here?


@Simon I'm human 🙂 . (comp odd? val) is the same as (fn [map-entry] (odd? (val map-entry)))


ah, I see, because val is a function composed with odd?


another variation is (into {} (for [[k v] {:a 0, :b 1} :when (odd? v)] [k v]))


what I thought I oculd best understand from this is (into {} (filter (fn [_ {:strs [bdType]}] (= bdType tp))) bindings))


but i seem to have made a mistake as it does not give the same results as @rauh example


(defn bindings-by-type [bindings tp]
    (into {} (filter (fn [_ {:strs [bdType]}] (= bdType tp))) bindings))


@Simon you're not destructing, the filter function is a predicate with exactly one argument. Add brackets to your fn: (fn [[_ {:strs ...}]] ...)


You're doing CLJS? Because this should give you an arity error in CLJ.


aaarrrrrr - only the 11000 time I've made that mistake


Last question I'm using the function above here

connected-in-bindings (->> (bindings-by-type bindings "QBSelect")
                                   (remove #(empty? (:in %))))
makes me think I should reverse the order of the parameters - are there any rules of thumb for that?


@hotbelgo Rule of thumb: If you're doing stuff with a sequence then the sequence should come last (`filter`, map, reduce, replace). If you're operating on one data-structure, it should come first (`conj`, update, assoc, dissoc, (most of?) the fns in clojure.string).


i would like to have java completions in lein repl, but i don't know how to look for it. any suggestions?


@matt.a.renfro let supports any number of forms in body. n the first case it’s treating each of assoc, m, k, etc as a body form


(it won’t behave as if assoc was wrapped in parentheses btw)


in the second case your assoc is within a if block, which only supports two forms


interesting I wouldn't expect that you could put anything not in parens


@matt.a.renfro what do you mean? you definitely can. For example, in (+ 1 2) the individual arguments 1 and 2 are not in parens


The way let works is it takes a bindings form and any number of body forms, and returns the result of the last body form


If your assoc on line 8 was wrapped in parens it would count as one body form, and the let block would return its result, e.g.


If you do not wrap it in parens, it counts as 4 forms. Neither of them have side-effects so they get executed unnoticed (the first one, assoc, will resolve to the funtion, the second one to an empty map, etc), and at the end it returns the last form, 42


You would have the same behaviour with a do block


Thanks, I just started learning the language yesterday so it was a bit unexpected. I'll keep that in mind.


Does anyone have a suggestion as to a good Clojure GUI library? I just want to throw together some UI's at work for prototypes and get some quick feedback from users.


From what I can tell, it seems like seesaw / swing is the only thing that's fully baked.


there's also javafx


Thanks, have you tried it?


no, but in my experience projects from that author are very good


I’m trying to execute a Clojure expression from the command-line without success. Here’s what I’ve tried:

java -cp clojure-1.8.0.jar clojure.main "(+ 2 3)" 
java -cp clojure-1.8.0.jar clojure.main  < "(+ 2 3)" 


@jaymartin check out java -jar clojure...jar --help


you want -e for a string, or << to make the shell hand it a string as stdin, or << to give it contents of a file (if you are using a normal shell at least). -i works instead of < for a file as well


@noisesmith Thank you pointing me to the docs for future reference. That did the trick.


With the Clojure 1.8.0 jar in my present working directory, the complete command line for future readers is:

java -cp clojure-1.8.0.jar clojure.main -e "(+ 2 3)"

Mike C16:09:24

Newbie question: I’m reading an XML file with (-> file name io/file io/input-stream io/reader xml/parse). The file has some invalid entities in it, which cause xml/parse to choke. I’d like to do a transformation on the string as it passes through. Is there a nice Clojure way to do that lazily on the way through, or should I just read in the full string, transform it, and then parse-str it?

Mike C16:09:54

s/file name/filename/


you could slurp the string, edit, and then make a StringReader and pass that to xml/parse


or you could use a tagsoup parser that just keeps chugging when it hits invalid stuff and lets you pick up the pieces

Mike C16:09:21

OK, thanks — so there’s no way of doing, in effect, a Regexp substitution on the string as it’s read, and have the system buffer enough characters to know whether there’s a possible match?


not that I know of...


you could likely use PushBackReader or StringReader to implement something that behaved like an InputStream or Reader but had that behavior, but I don't know of something that does that out of the box


it might exist though?


no built in way that I know of. I'd be wrapping the reader in a proxy

Mike C16:09:32

Great, thanks — just wanted to make sure I wasn’t re-inventing something that was already available


there's libs for java that do this sort of thing, I can't vouch for quality though


in clojure you can usually find a functionality for what you want by searching for java instead, interop is relatively easy


probably one of the best part about clojure actually


access to the rich java ecosystem of librairies without having to write java

Mike C16:09:31

Oooh. That looks like it might be just the ticket. Thanks!

Mike C18:09:44

So I’ve been playing around with streamflyer, and almost got it working. To run the transformation I need, I have to use proxy to make an object that implements a specific interface (`MatchProcessor`). The function of interest in that interface accepts a java StringBuilder, which (in the java example) it modifies in place.


sounds good so far - even clojure.core/str uses a mutable StringBuilder internally

Mike C18:09:42

I can run methods on the StringBuilder in my code, but the results are lost — do I need to do something to ensure that the updated StringBuilder is ‘seen’ by the calling java?


so it passes you a StringBuilder, and you are putting things in it, and they disappear?


it's a mutable thing, you shouldn't have to do anything special to make it work


other than the obvious eg calling the append method etc.

Mike C19:09:01

so I shouldn’t have to do anything special

Mike C19:09:09

Time to write some minimal test cases then, thanks


since you are here in #beginners I'll mention this one: make sure that you aren't calling the append method inside for or map


because for, map, and friends are lazy, and if nobody is using the sequence they generate, they do nothing. If you need to iterate for side effects use run! or doseq

Mike C19:09:47

Worth noting, thanks

Mike C19:09:24

I’ve fixed it though — it wasn’t mutability issue in the end (that was just my first concern). I was mis-counting where I wanted the scanner to restart, so it was missing some matches

Mike C19:09:29

thanks again


I'm playing around with SeeSaw. Everytime I close the window (frame) my repl crashes and I have to close it and restart it. I'm using Atom / Proto-Repl. Any ideas on how I can create, show, close windows without restarting the repl?


@genec When you say "crashes", what do you mean? Have you tried this from a REPL started from the command line outside of Atom?


@genec do you have :on-close :exit set on your frame?


does anyone advice for learning how to write REGEXs?


if you need to use regexes, this site is a great resource


@alexkeyes try things in until it works 😄