This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-21
Channels
- # beginners (82)
- # bitcoin (1)
- # boot (38)
- # cider (6)
- # cljs-dev (13)
- # cljsrn (5)
- # clojure (320)
- # clojure-italy (22)
- # clojure-losangeles (6)
- # clojure-russia (55)
- # clojure-spec (25)
- # clojure-uk (48)
- # clojurescript (64)
- # component (16)
- # core-async (6)
- # cursive (54)
- # data-science (2)
- # datascript (2)
- # datomic (8)
- # docker (1)
- # ethereum (1)
- # fulcro (1)
- # garden (1)
- # graphql (16)
- # heroku (6)
- # hoplon (12)
- # jobs (4)
- # juxt (1)
- # leiningen (9)
- # off-topic (39)
- # om (13)
- # om-next (2)
- # onyx (9)
- # pedestal (2)
- # portkey (12)
- # re-frame (25)
- # reagent (6)
- # ring-swagger (4)
- # schema (1)
- # shadow-cljs (10)
- # spacemacs (11)
- # testing (19)
- # uncomplicate (1)
- # unrepl (6)
- # vim (21)
- # yada (3)
@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 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
@Simon I'm human 🙂 . (comp odd? val)
is the same as (fn [map-entry] (odd? (val map-entry)))
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 ...}]] ...)
Last question I'm using the function above here
connected-in-bindings (->> (bindings-by-type bindings "QBSelect")
vals
(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
@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
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
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)"
and
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)"
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?
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
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?
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 https://github.com/rwitzel/streamflyer
in clojure you can usually find a functionality for what you want by searching for java instead, interop is relatively easy
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
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.
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
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
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?
if you need to use regexes, this site is a great resource https://www.regular-expressions.info/reference.html
@alexkeyes try things in https://regex101.com/ until it works 😄