This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-14
Channels
- # aleph (2)
- # atlanta-clojurians (5)
- # beginners (38)
- # boot (2)
- # bristol-clojurians (1)
- # cider (31)
- # clara (8)
- # cljs-dev (136)
- # cljsrn (4)
- # clojure (86)
- # clojure-china (1)
- # clojure-greece (1)
- # clojure-italy (24)
- # clojure-nl (1)
- # clojure-spec (21)
- # clojure-uk (19)
- # clojurescript (68)
- # community-development (28)
- # core-async (35)
- # core-logic (4)
- # cursive (1)
- # data-science (1)
- # datascript (1)
- # datomic (46)
- # events (1)
- # figwheel (6)
- # fulcro (11)
- # graphql (3)
- # hoplon (1)
- # jobs (6)
- # jobs-discuss (94)
- # keechma (3)
- # luminus (4)
- # lumo (7)
- # mount (6)
- # off-topic (24)
- # onyx (6)
- # parinfer (31)
- # portkey (3)
- # programming-beginners (16)
- # re-frame (20)
- # reagent (69)
- # remote-jobs (4)
- # ring-swagger (25)
- # schema (1)
- # shadow-cljs (151)
- # spacemacs (2)
- # sql (14)
- # tools-deps (16)
- # uncomplicate (5)
- # unrepl (35)
- # vim (1)
- # yada (72)
https://insights.stackoverflow.com/survey/2018/#technology-most-loved-dreaded-and-wanted-languages
@mbjarland clojure is at 59.6% in most-loved!
I think only 2.7% of developers who are not developing with clojure have expressed interest in developing with it, leaves room for improvement…
What would people use to pretty print (indent etc) XML output, and do stuff like strip unused namespaces?
Don't mind using alpha versions if necessary. We're already on the 0.2.0-alpha5 version to get some other functionality we need
Are there function in clojure.data to apply an XSLT to an XML structure before emitting it as a string? That'd be ideal, but I couldn't find 'em 🙂
Well, there's ahem https://github.com/eerohele/sigel.
hi, how do you remove the namespace declaration in clojure without rebuilding the whole xml structure again ?
just realized, you don't have to pass every previous result to every next form in as->
.
it is not really useful for vanilla as->
, because it does not have any short-circuit behavior, though
if you want to ensure you match all input, you need to pass opts
By default, read-string reads a token and stops
@alexmiller in doc string I don't see any options to pass for this use case (read everything). @pesterhazy yeah, was not my expectation :)
yeah, I guess it’s really not options really more in calling structure in that you want to ensure you read to EOF
do you have a sample code you could point to? given I pass string, not reading from file, I don't see how I'd know where read-string stopped reading.
oh boy, my lein jar fails with: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Named but lein compile, everything else works. what could be the problem?
if former – you might have an extra set of brackets around some settings in project.clj
Is there any clojure core function I'm missing that might help in building up a sequence conditionally like this? I know there are various options to wrap this just wondering if I'm blanking out on a clojure core function
(let [version (rand-int 10)
SERVER-VERSION (atom (rand-int 122))]
(cond-> [:init1 :init2]
(>= version 3) (conj :key1 :key2 :key3)
(>= @SERVER-VERSION 50) (conj :key4)
(>= version 2) (conj :key5)
true (conj :keyA)
(>= version 4) (conj :key6)
(>= version 6) (conj :key7 :key8 :key9)
true (conj :keyB :keyC)
(>= @SERVER-VERSION 100) (conj :key10)
(>= @SERVER-VERSION 120) (conj :key11 :key12)))
I also tried this, which I think is probably worse:
(let [version (rand-int 10)
SERVER-VERSION (atom (rand-int 122))]
(->> [:init1 :init2
(when (>= version 3) [:key1 :key2 :key3])
(when (>= @SERVER-VERSION 50) :key4)
(when (>= version 2) :key5)
:keyA
(when (>= version 4) :key6)
(when (>= version 6) [:key7 :key8 :key9])
:keyB :keyC
(when (>= @SERVER-VERSION 100) :key10)
(when (>= @SERVER-VERSION 120) [:key11 :key12])]
(remove nil?) flatten))
@jjttjj: in code like this, (apply concat x)
tends to be better than (flatten x)
(let [version (rand-int 10)
SERVER-VERSION (atom (rand-int 122))]
`[:init1
:init2
~@(when (>= version 3) [:key1 :key2 :key3])
~(when (>= @SERVER-VERSION 50) :key4)
~(when (>= version 2) :key5)
:keyA
~(when (>= version 4) :key6)
~@(when (>= version 6) [:key7 :key8 :key9])
:keyB
:keyC
~(when (>= @SERVER-VERSION 100) :key10)
~@(when (>= @SERVER-VERSION 120) [:key11 :key12])])
t.e.jvm suffers quite a bit in performance because of its use of syntax-quote as a templating language
it essentially makes a function which takes an api response and turns specified keys into js/moment objects
why sorted-map
?
so that {:id 1 :createdAt moment } comes out the way it was put in rather than the [[:id 1] [:createdAt moment]] which is the result of the map
gotcha
I think this should work but bear in mind I'm assuming many things about params
and your intentions in general
a few things:
- using ->>
when using into
, map
, filter
and anything that takes coll as the last arg usually leads to easier to follow code
- for creating a map from a collection of k-v pairs it's common to do (into {} coll)
- using doall
when there are no side effects is usually useless or a code smell. in your example you could have also realized the coll using mapv
instead of map
- when you want to check if A is one of many things, use a set
from a brief read it looks like you're blocking the repl thread
(hence nothing will happen until you restart it)
I'm new to clojure so I don't fully understand how it works, but I thought that you could update a running clojure process with the repl?
yes, but not if you're running an infinite loop directly in the repl
a future
might work for you...
So in general, it's impossible to update the repl while the main thread is busy, is that correct?
a more clojurey solution would be to use go-loop
and core.async/timeout
For this problem, you could avoid the main thread with (.start (Thread. execute))
instead of (execute)
and generally a repl is sort of a client/server system, so while client x is waiting for the result of executing whatever, you can create a new client y and execute other stuff
so the exact behavior you see will depend on what repl client and server you are using
I have been having this weird race-condition like problem for ... maybe eight months now? I randomly get a "No namespace: twou.centralpark.async" (our own stuff) when I run clojure.tools.namespace/refresh. I think I've had it happen with another namespace, as well. Doing a lein clean
fixes it.
Hi all, what's the time complexity for comparing maps in clojure? I assume it hashes both, but if the hashes pass there's a chance of collision so does it do any further checks?
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/APersistentMap.java#L73
It looks like O(n)
but if the hashes don't match it can return faster of course
does it look at the hash for =
?
it's a relatively rare coding style, but it even has a name
it’s called Whitesmiths style https://en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style
hashing isn't an optimization there since hashing has to traverse the entire map anyway
but it can cache the hash code, I see that it doesn't check for cached hash, I guess because that would be fiddly
It does check for identical however, it’s pretty rare to compare two instances of huge data sets.