workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
<@Berry> you know that conj takes multiple args and that you can use into as well right?
2017-12-21T17:41:26.000303
Margaret
clojurians
clojure
yes, but I believe that becomes liner time, not O(1)
2017-12-21T17:46:33.000238
Berry
clojurians
clojure
doesn’t a doubly linked list do that for you?
2017-12-21T17:53:25.000112
Thu
clojurians
clojure
doubly linked lists really aren't functional
2017-12-21T17:56:25.000113
Berry
clojurians
clojure
ot "merge" the two lists, you have to modify the prev/next pointersx
2017-12-21T17:56:39.000229
Berry
clojurians
clojure
is there a way to make jdbc dump the sql statements it’s making? I have a sql query that is working through psql but it doesnt return anything through jdbc, and I don’t get any errors either…
2017-12-21T17:57:25.000198
Williemae
clojurians
clojure
yeah, you can’t do the sharing clojure would normally do with lists
2017-12-21T17:57:25.000319
Margaret
clojurians
clojure
what about those zipper things that I refused to learn about when i was trying to learn haskell
2017-12-21T18:00:47.000205
Thu
clojurians
clojure
&gt; to make a doubly-linked list, you need to construct it all at once, and if you ever want to change any part of it, you either need to use a Zipper or just make a complete copy of it every time <https://stackoverflow.com/questions/10386616/how-to-implement-doubly-linked-lists>
2017-12-21T18:08:44.000005
Margaret
clojurians
clojure
<@Berry> did anyone mention finger trees yet?
2017-12-21T18:08:56.000268
Margaret
clojurians
clojure
ok
2017-12-21T18:09:12.000031
Williemae
clojurians
clojure
why do sql query examples not use the goddamn results
2017-12-21T18:09:24.000248
Williemae
clojurians
clojure
<@Berry> <https://github.com/clojure/data.finger-tree>
2017-12-21T18:09:41.000329
Margaret
clojurians
clojure
<@Williemae> Ask in <#C1Q164V29|sql> if you want to avoid the noise of this channel...
2017-12-21T18:10:57.000210
Daniell
clojurians
clojure
<@Margaret> fingertrees look interesting
2017-12-21T18:36:55.000064
Berry
clojurians
clojure
I just had an epiphany while implementing Joy in Clojure. Stack based langauges = basicaly programming iwth de bruijn indices instead of variable names.
2017-12-21T18:37:39.000028
Berry
clojurians
clojure
If you are worried about constant factors in run time, you might want to do some profiling of finger trees vs. other data structures like plain old Clojure vectors and/or RRB vectors. I haven't done it myself, but recall that finger trees have constant factors of run time significantly higher than the others. Not O() bad things, but something that might affect what you want to use anyway.
2017-12-21T18:51:42.000172
Micha
clojurians
clojure
yeah, profiling with actual runtime conditions is always called for if there are performance problems
2017-12-21T19:03:34.000172
Margaret
clojurians
clojure
speculatively optimizing before you have something that works is a great way to waste a lot of energy
2017-12-21T19:03:58.000047
Margaret
clojurians
clojure
It just occurred to me... we should update our multi-version testing to check code against `clojure-1.10.0-master-SNAPSHOT` now that 1.9 is released! :laughing:
2017-12-21T21:24:24.000236
Daniell
clojurians
clojure
When using `pprint` on a map containing namespaced keywords, long namespace prefixes are kind of a headache, pushing the output far to the right. Is there a way (short of writing my own formatter) of having it substitute aliases for the full namespace name?
2017-12-21T21:30:30.000043
Edmond
clojurians
clojure
`(set! *print-namespace-maps* false)` perhaps?
2017-12-21T21:40:36.000202
Daniell
clojurians
clojure
(not sure how you'd get an alias substituted in -- unless you wrote your own `print-method` for `clojure.lang.IPersistentMap`?)
2017-12-21T21:42:30.000062
Daniell
clojurians
clojure
`*print-namespace-maps*` is a little better, though it sort of shifts the readability problem. I guess I'll think on making a custom `print-method` that interrogates the current ns aliases or something.
2017-12-21T22:20:50.000007
Edmond
clojurians
clojure
how expensive is the overhead of a vector with one element ?
2017-12-22T01:34:29.000073
Berry
clojurians
clojure
(compared to just storing that element)
2017-12-22T01:34:37.000110
Berry
clojurians
clojure
~sizeof(Object[32]) IIRC
2017-12-22T02:07:06.000175
Charity
clojurians
clojure
So probably not very
2017-12-22T02:07:14.000111
Charity
clojurians
clojure
Is there a builtin for: ``` (defn u-in [obj path f] (let [o (get-in obj path) [nv &amp; rst] (f o)] (into [(assoc-in obj path nv)] rst))) (u-in {:a {:b 2} :foo :cat} [:a :b] (fn [x] [(inc x) :foo])) ```
2017-12-22T04:22:25.000275
Berry
clojurians
clojure
is there a better way to write: ``` (fn [[o f]] (f o)) ``` it seems like a weird enough function there should be some weird name for it
2017-12-22T04:45:27.000233
Berry
clojurians
clojure
(eval (rseq ....)) :bomb::boom:
2017-12-22T05:02:11.000244
Lucretia
clojurians
clojure
is there a 'stateful iterate' ? i.e. suppose (f x0) = [x1, v1] (f x1) = [x2, v2] (f x2) = [x3, v3] .... I want something where (g x0 3) = [x3, [v1 v2 v3])
2017-12-22T05:57:28.000267
Berry
clojurians
clojure
is there a way to ask cloc to count test code separately?
2017-12-22T07:10:51.000084
Berry
clojurians
clojure
basically, anything defined via (ct/...) where ct = clojure.test
2017-12-22T07:11:01.000117
Berry
clojurians
clojure
(def fapp (fn [[f &amp; args]] (apply f args))) &lt;-- wtf, is this function just #(apply apply %) ?
2017-12-22T08:02:49.000011
Berry
clojurians
clojure
woah clojure is just incredible, there are plenty of different macros and then you think “super handy - if there was only a way do _slightly_ diverge from the default behavior”, and then you google a bit and there *is* for sure something build in :smile:
2017-12-22T08:41:08.000086
Marcel
clojurians
clojure
<https://clojurians.slack.com/archives/C03S1KBA2/p1513940248000267> `(map second (iterate f x0))`
2017-12-22T09:18:31.000203
Xavier
clojurians
clojure
ah, didn’t notice you want all the `v`s
2017-12-22T09:19:11.000007
Xavier
clojurians
clojure
```(-&gt;&gt; [0 []] (iterate (fn [[x vs]] (let [[x' v'] (f x)] [x' (conj vs v')]))) next (take 3))```
2017-12-22T09:27:29.000562
Xavier
clojurians
clojure
<@Heriberto> a lumo version issuer. <#C4C63FWP5|unrepl> is a better place for unravel issues
2017-12-22T09:58:57.000095
Marla
clojurians
clojure
<@Marla> Thanks!
2017-12-22T10:08:43.000237
Heriberto
clojurians
clojure
Who said that Clojure's long startup time can't be fixed? :grinning: See <https://stackoverflow.com/questions/19107683/speed-up-clojure-startup-time-with-nailgun>
2017-12-22T10:39:02.000408
Heriberto
clojurians
clojure
&gt;In my case, startup time of the actual script went down to 80ms
2017-12-22T10:39:28.000113
Heriberto
clojurians
clojure
is there a way to make `clj` start the repl in a certain namespace?
2017-12-22T11:49:23.000553
Judy
clojurians
clojure
`:repl-options :init-ns`
2017-12-22T11:50:07.000526
Leann
clojurians
clojure
so, in project.clj, you could add: `:repl-options {:init-ns user :port 4001 :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}`
2017-12-22T11:50:29.000591
Leann
clojurians
clojure
no i'm talking about `clj` which comes with tools.deps, not leiningen
2017-12-22T11:50:52.000081
Judy
clojurians
clojure
it’s a little cumbersome but you could do
2017-12-22T14:06:56.000087
Sonny
clojurians
clojure
`clj -e "(use 'clojure.set) (in-ns 'clojure.set)" -r`
2017-12-22T14:06:57.000501
Sonny
clojurians
clojure
my favorite golfing of require / switch ns is `(doto 'clojure.set require in-ns)`
2017-12-22T14:09:36.000223
Margaret
clojurians
clojure
What would you call the value that `peek` returns? You can't call it "first" or "last" since that depends on the type you supply.
2017-12-22T15:12:11.000154
Liza
clojurians
clojure
not only that but first and last are functions you probably don't want to shadow
2017-12-22T15:14:26.000179
Margaret
clojurians
clojure
for a stack, it would be the top value
2017-12-22T15:14:40.000241
Margaret
clojurians
clojure
That's true. Doesn't really matter what the type of the structure is because chances are good you're using it as a stack or queue if you're using `pop` and `peek`.
2017-12-22T15:15:24.000154
Liza
clojurians
clojure
Thanks. I just needed a gut check on that.
2017-12-22T15:15:31.000258
Liza
clojurians
clojure
I needed an appropriate name for this convenience function I just wrote: ``` (defn update-top [coll fun &amp; args] (conj (pop coll) (apply fun (peek coll) args))) ```
2017-12-22T15:19:20.000152
Liza
clojurians
clojure
does anyone know how to _write_ to STDIN from clojure? I'd like to write a string to STDIN so that a process listening to `*in*`would be able to consume the string
2017-12-22T15:40:56.000055
Eldridge
clojurians
clojure
unorthodox, i know, but mostly for hacky purposes
2017-12-22T15:41:38.000229
Eldridge
clojurians
clojure
<@Eldridge> are these 2 separate processes?
2017-12-22T15:47:22.000046
Ambrose
clojurians
clojure
well one of them is a repl and the other is a server receiving messages across a web socket
2017-12-22T15:48:39.000121
Eldridge
clojurians
clojure
is the repl running in the same process as the server?
2017-12-22T15:49:07.000159
Ambrose
clojurians
clojure
yes
2017-12-22T15:49:15.000040
Eldridge
clojurians
clojure
AFAIK you need to resort to OS functionality to write to STDIN - it's something I wouldn't expect the jvm to abstract or provide for you
2017-12-22T15:52:17.000188
Margaret
clojurians
clojure
is the server listening on both stdin and the websocket?
2017-12-22T15:53:09.000106
Ambrose
clojurians
clojure
what is the interpretation of this `(spit *in* some-string)`
2017-12-22T15:53:14.000234
Eldridge
clojurians
clojure
no
2017-12-22T15:53:20.000269
Eldridge
clojurians
clojure
server only listens to websocket
2017-12-22T15:53:27.000204
Eldridge
clojurians
clojure
you can't spit to `*in*`, that will just throw an exception; beyond the obvious `*in*` can be freely rebound, and the binding only has to support reading
2017-12-22T15:53:46.000281
Margaret
clojurians
clojure
which process is listening to `*in*`
2017-12-22T15:54:08.000014
Ambrose
clojurians
clojure
the repl
2017-12-22T15:54:17.000017
Eldridge
clojurians
clojure
to rephrase my question: there is a websocket server running in a repl and I want the msg coming through the socket to be interpreted by the repl as if it was entered from STDIN
2017-12-22T15:55:16.000368
Eldridge
clojurians
clojure
you can easily start a repl that listens to a fifo or socket btw
2017-12-22T15:55:26.000444
Margaret
clojurians
clojure
I'd start a repl on a new thread in the same process, and bind `*in*` to the input from the socket
2017-12-22T15:55:59.000118
Margaret
clojurians
clojure
STDIN isn't special
2017-12-22T15:56:03.000209
Margaret
clojurians
clojure
true. thats a good idea.
2017-12-22T15:56:39.000124
Eldridge
clojurians
clojure
thank you
2017-12-22T15:56:43.000221
Eldridge
clojurians
clojure
and you probably want it's `*out*` to send back to the client too, for that matter
2017-12-22T15:57:04.000359
Margaret
clojurians
clojure
clojure has a built in socket repl class, but for a websocket you might need to write your own (also I'm sure you're aware this a security nightmare)
2017-12-22T15:57:38.000209
Margaret
clojurians
clojure
yeah =/ other than an http request, websockets seemed the only way to talk to a remote repl from the browser
2017-12-22T15:59:57.000225
Eldridge
clojurians
clojure
right, the problem is that a repl effectively gives root because every single mainstream OS has local root holes that don't require physical access
2017-12-22T16:01:20.000155
Margaret
clojurians
clojure
if you trust everyone who can load the web page to have root, that works out (I'd be very careful about who can visit the page of course)
2017-12-22T16:01:45.000368
Margaret
clojurians
clojure
it would be internal to my company's network, but yes I understand the implication. Are jupyter notebooks with ipython kernels similarly insecure?
2017-12-22T16:02:40.000068
Eldridge
clojurians
clojure
I don't know python - but a good indicator would be how hard is it to make a shell call inside the python code... if they can run a system command then it's probably about the same
2017-12-22T16:03:42.000213
Margaret
clojurians
clojure
indeed you can with little in the way. thats at least *a bit* comforting
2017-12-22T16:04:27.000055
Eldridge
clojurians
clojure
<@Sonny> have a quick question about `clojure.java.classpath/classpath-directories` with JDK 9
2017-12-22T16:06:32.000267
Elanor
clojurians
clojure
I got an issue for migratus recently <https://github.com/yogthos/migratus/issues/126>
2017-12-22T16:07:13.000077
Elanor
clojurians
clojure
and traced it down to the fact that the behavior of `classpath-directories` changed when using JDK 9
2017-12-22T16:07:59.000195
Elanor
clojurians
clojure
when I run it with JDK 8 or below I see something like: ``` (#object[java.io.File 0x30efe7c "/Users/yogthos/src/migratus/test"] #object[java.io.File 0x70111841 "/Users/yogthos/src/migratus/src"] #object[java.io.File 0x51ee3ff3 "/Users/yogthos/src/migratus/resources"] #object[java.io.File 0x24a1e205 "/Users/yogthos/src/migratus/target/classes"]) ```
2017-12-22T16:08:40.000045
Elanor
clojurians
clojure
however running on JDK 9 returns an empty seq
2017-12-22T16:08:54.000001
Elanor
clojurians
clojure
is this a bug?
2017-12-22T16:09:00.000131
Elanor
clojurians
clojure
3 lines of unit test per line of code -- is this within reasonable limits, or is it ridicilous ?
2017-12-22T16:30:30.000077
Berry
clojurians
clojure
depends on how much logic you like to put on a line I guess
2017-12-22T16:31:23.000234
Margaret
clojurians
clojure
here's an example of code + unit tests: ``` (do ;; stateful (def si (fn [f s] (itr #(f (first %)) [s]))) (def sic (fn [f s n] (take (+ n 1) (siter f s)))) (def sics (juxt #(first (last %)) #(map second (rest %)))) (def sis (fn [f s n] (sics (sic f s n)))) (def sfc (fn [f c [o sf] i] (va [id #(c sf %)] (f o i)))) (def smap (fn [f o lst] (reduce #(sfc f conj %1 %2) [o []] lst))) (def swu (fn [s t f] (if (t s) (recur (f s) t f) s))) (let [g0 (juxt inc #(* 2 %)) g1 (fn [s i] [(+ s i) (+ (* 10000 s) i)])] (ct/is (= (sic g0 0 3) [[0] [1 0] [2 2] [3 4]])) (ct/is (= (sis g0 0 3) [3 [0 2 4]])) (ct/is (= (smap g1 0 [1 2 3 ]) [6 [1 10002 30003]])) (ct/is (= (swu 1 #(&lt; % 10) #(+ % 2)) 11)))) ```
2017-12-22T16:32:12.000003
Berry
clojurians
clojure
looks like things break down here: ``` (map get-urls (take-while identity (iterate #(.getParent ^ClassLoader %) (clojure.lang.RT/baseLoader)))) =&gt; (nil nil nil nil nil nil) ```
2017-12-22T16:49:09.000277
Elanor
clojurians
clojure
while you can create new functions for various combinations of builtins, there’s something to be said for writing most of your code in terms of more common functions
2017-12-22T17:14:54.000010
Jonas
clojurians
clojure
for example, if you us `smap` somewhere
2017-12-22T17:15:43.000077
Jonas
clojurians
clojure
to figure out what it does you have to then go and figure out what `sfc` does
2017-12-22T17:15:59.000224
Jonas
clojurians
clojure
which means you have to figure out what `va` does
2017-12-22T17:16:13.000055
Jonas
clojurians
clojure
and I don’t know what `va` does
2017-12-22T17:16:27.000203
Jonas
clojurians
clojure
nothing like a codebase that forces you to master a language only used in Tolkien's Sylmarillion in order to understand it
2017-12-22T17:19:05.000128
Margaret