This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-01
Channels
- # arachne (3)
- # bangalore-clj (8)
- # beginners (9)
- # cljsrn (3)
- # clojure (148)
- # clojure-filipino (2)
- # clojure-russia (25)
- # clojure-serbia (3)
- # clojure-spec (14)
- # clojure-uk (61)
- # clojureremote (7)
- # clojurescript (38)
- # clojurewest (2)
- # cursive (2)
- # data-science (9)
- # datomic (4)
- # emacs (4)
- # jobs (6)
- # lein-figwheel (3)
- # leiningen (2)
- # off-topic (1)
- # om (3)
- # onyx (1)
- # pedestal (16)
- # perun (2)
- # powderkeg (1)
- # protorepl (2)
- # re-frame (1)
- # reagent (10)
- # spacemacs (2)
- # unrepl (5)
- # untangled (4)
instead of having to thread the new state through all the time, we can just make modifications, and the modifications are carried through until the persistent! call
qqq: not true, you still have to thread, check the docstring about "bashing in place". And try yourself with say, 100 insertions. I can t recall the exact limit for every datastructure but bashing in place only "works" for a few modifications and its an impl detail.
i think the more salient issue is that reality usually categorizes only approximately, so if you need exact categorization, or an exact taxonomy of something that is supposed to be a representation of reality, the more realistic you make your representation, the more often you have to revise or rethink your whole taxonomy
i like to compare the ease with which mathematics can be categorized, and the ease with which simulations can be categorized against the difficult of categorizing (with exactness) biology, economy, or even something more mundane like postage stamps
The crucial difference between these two classes of things is rampant chaos-- its not present in all the structures of mathematics, and can be avoided a priori in a simulation; but it is inextricably a part of our reality
thus any time you try to hedge yourself against chaos by adopting rigid types, you are hedging yourself against reality
(except in the cases where you aren't dealing with reality in the first place, for instance a haskel library for matrix algebra)
"transient" is shallow right? in the sense if if we have a map of map of values, i.e. k1 k2 -> v, then in using transient, it's on the "top level of keys" that become transient, the 'inner map' of k2 -> v is still persistent
There s a wrong assumption that using a strongly typed lang like ocaml will be less productive. Also a huge diff with schema/spec and the like is inference. Very often with ocaml you dont even have to add any type annotation and you get whole program coverage for free. That said that language has other issues (for now) imho. But that s #offtopic material
https://clojuredocs.org/clojure.core/definline <-- is this the right way to inline functions in clojure?
(doseq [:let [x 20]]
(println x))
this code works. Can I rely on some spec guaranteeing this works, or is the first element of a doseq supposed to be a (var, seq) pair ?The doc string indicates the latter, the keywords are modifiers of the previous sequence. I suspect this is a pathological case, since you're binding a constant value. I guess the real surprise to me is that with an empty set of bindings, it executes the body at all. 🙂
(-> amap keys set (clojure.set/difference , (set ks) ) (#(select-keys amap %))) if amap have a lot of keys.
does anybody use this library? https://github.com/funcool/cats
I do. I find it very useful for the Either Maybe and Try monads.
Most recently, it has been mentioned here: https://blog.skyliner.io/fourteen-months-with-clojure-beb8b3e4bf00
cheshire seems to have a lot of CBORfactory annotations that it doesn’t import: https://github.com/dakrone/cheshire/blob/master/src/cheshire/core.clj
Im reading the HN comments on https://blog.skyliner.io/fourteen-months-with-clojure-beb8b3e4bf00 Which you can find here: https://news.ycombinator.com/item?id=14006242#14011870 and their is a specific complaint that inexperienced clojure devs are more likely to create a single global state then inexperienced devs in other languages. Also that this single application state is bad: > I know Python doesn't come with atoms, but you could certainly stick the whole application state in a global variable. You wouldn't though if you're a working programmer with a modicum of experience on your first Python project. Do people just see some new idioms and forget everything they already knew about programming? Isn't a single application state what Om.Next does? Is the complain about how its done? Or i'm I missing something. I thought a single DB was a very common and reliable pattern in clojure because it put all the real state in one place and made sure your changes were more transnational.
@istvan The problem isn’t that it isn’t used; the problem is that it annotates with CBORFactory but doesn’t import it
Yeah, I have to disagree with the whole one atom is bad thing.
@drewverlee it matters if you have atomic reference in the language and you put the global state or you have python where everything is global and there is no atomic reference 😉
From what I understand, even Datomics transactor works that way
And normally Clojure programs use pure functions to mutate that state.
def addList(val, list=[]):
list.append(val)
return list
addList(10)
addList(10,[])
addList(10)
addList(10)
its because the list=[] isnt doing what you think
(note: please don’t ask gotchas as interview questions unless you can demonstrate they’re predictive (and they’re probably not))
and if cannot write reliable code you cannot deliver mission critical systems and my company is in the business of delivering mission critical systems (but we do not use python 🙂 )
So is the real complaint isn't having global mutable state, its that you don't have good tools to deal with it?
Scratch that, the complaint is that when people write bad code in clojure its harder then usually to figure out whats going on.
Is there a way to get core.match
to only be required at compile time? I’m trying to avoid e.g. org.objectweb.asm.*
being in the resulting uberjar; that is pulled in tools.analyzer.jvm, and I think it should only be required at compile time (but i’m happy to be wrong about that)
i watched clj talk on clojureTV about java9 modules ( https://www.youtube.com/watch?v=4fevIDAxQAM ) i feel concerned could someone maybe shine little bit of light on the topic? are modules really a problem that affects us deeply? Will at some point clojure have to let go of it's unique philosophy to still be able to run on JVM? (btw i am beginner)
while it’s pretty clear oracle wants modules to happen, they don’t get to comically break the ecosystem
is there something weird about instant?
that would make removing clj sources (in an :aot
uberjar) fail?
Caused by: java.io.FileNotFoundException: Could not locate clojure/core_instant18__init.class or clojure/core_instant18.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
I have a list of items. Each is of the form [a b c d e] What is the fastest (runtime) way to create a 4- level map of the form {a {b {c { d e}}}} ? There's group-by, but it only does it 1 level.
@qqq assoc-in
@tbaldridge: reduce + assoc-in ? this is performance sensistive
@dthurn Pretty sure it’s ClojureScript only. Not sure what it’s even mean for clojure
I have a list of [a1 b1 c1 d1 e1] [a2 b2 c2 d2 e3] [a3 b3 c3 d3 e3[ .... with assoc-in, I'd have to use reduce
yes then assoc-in + reduce
if its too slow you can sometimes replace assoc-in with a macro
@lepistane no reason to cross post between channels. Most of us hang out in both this channel and #beginners
Well, I was hoping for some figwheel-like way to auto-reload files in my clojure application when I modify them. The figwheel workflow is pretty great.
dthurn have you looked at https://github.com/clojure/tools.namespace?
it looks like I could maybe get what I want by hooking that up to a filesystem watcher
Have a look at system. It does what you want. https://github.com/danielsz/system
Guys, I need a mentor. Really successful person who wants to grow another successful person. I am in Turkey, but my English is not really bad. I want to become a professional.
What's the best way to make a macro in one namespace have reference to a function in that namespace, regardless of where it is called
Something like (defmacro a (b) (...Replace all symbol K with a call to C, a function defined in this namespace...)
right now Im just doing simple symbol substitutions, but I want a more robust way of replacing function calls
just make it explicit? or wrap stuff in let to bind the sym? (let [+ package.core/add-ten] ...). (untested, guessing from memory 😉 )
or "binding" or some such. i've done this sort of thing but it's been a while. pt being i don't think you need to crawl the input if you just want to rebind some syms.
clojure complaining about symbol rebinding is not unusual. you can use "refer-clojure" to deal with that.
@emccue here's my take on what I believe you're trying to do: https://gist.github.com/moxaj/da60985e609916361a550a5f130df11f
if you understand abstract algebra, and you're bordeline insane, you can study the code behind . https://github.com/mobileink/lab.clj.polymorphism/blob/master/src/clojure/multimodels/examples.clj it demonstrates among other things how to make the same group multiplication operator work for the 2 basic groups (+, 0, N) and (*, 1, N+), using clojure's binding ops.
and quasiquote and unquote have some wierd behaviour in clojureland that I have yet to reconcile in my head
@emccue it's well documented - we call it syntax-quote and it always qualifies symbols https://clojure.org/reference/reader#syntax-quote
lxsameer I think you want the first three in this file, at least https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/protocols.cljs#L13
ReadPort, WritePort, Channel
(well, maybe just two if you are read-only / write-only I guess)
(empty? (transient {}))
throws an exception -- so how do I check if a transient is empty?see http://stackoverflow.com/questions/9396987/how-do-you-get-the-keys-from-a-transient-map-in-clojure maybe it will hwlp.
@mobileink : that explains it; thanks!
@noisesmith thanks man
@qqq - turning a transient persistent is just a single bit flip, use persistent! with empty?