#clojure logs

2016-02-12

00:27bsimaskjljsk: looks like you're missing a dependency
00:30skjljskits complaining about boot.core
00:36bsimadid you `require` boot.core in build/tasks.clj?
00:40jack_rabbitI'm reading core.async docs. If I use >!! or <!! instead of >! or <! in a go block, what happens?
00:56rhg135you block the thread
00:59skjljskbsima: yes
01:00skjljskthis pod buisness is often very dangerous
01:00skjljski mean the boot pod
01:02skjljskshit man i can not test my code with boot
01:03irctcwould anyone be interested in using a version of Clojure, that implemented SystemF-omega type inference on the JVM?
01:03irctcbasically get all the type benefits of haskell, the syntax of clojure, and the power of the JVM
01:04irctcspecifically designed for industry, not academia
01:16rhg135I'm not sure what that means but it sounds cool
01:17python476hes gone anyway
01:17python476Fomega seems harder to do than gradual typing
01:27bsimaI'm a big fan of Shen. Uses sequent calculus for its types
01:36bsimaskjljsk: if you're still here, check out #bootclj
01:36bsimaalan and micha might be able to help you
01:39skjljskthanks
01:41skjljskbtw boot is great
01:41skjljski am sure it must be something i am doing
01:41skjljskat least with boot i can write my own test task
01:50python476bsima: is shen 'sound' ? or does it fail on some weird cases ? I've never used it. First time someone says he used it
01:52python476skjljsk: sean corfield made articles about moving his company app from lein to boot. At my level I don't see the value (except that boot task composition seems a good thing)
01:52skjljski have been on boot for a year now
01:52skjljskmore than that actually
01:52wmealingits on my list of things to look at
01:53bsimaI've been using boot for over a year as well
01:53skjljskit is mindblowing, but not as stable as lein i would say
01:53bsimaI actually use it on top of lein, to do some extra tasks. Specifically tests
01:53python476unstable mindblowing, 70s are back
01:53clojurebotTitim gan éirí ort.
01:54python476Gvgvz tna éveí beg
01:54skjljskhurmm i dont know i have contributed patches to it in the past
01:54skjljskrecently i changed job and get very little time to debug boot issues
01:55skjljskif you are in same position i would recommend lein
01:56skjljskbut i would still chose boot over lein no matter wat
01:56bsimaboot wins for clojurescript
01:56skjljskpython476: everything was once mindblowing unstable
01:57skjljskyour contribution makes it mindblowing stable
01:57python476hey
01:57skjljskin form of issues patched etc
01:57skjljskanyhow no debate here
01:57skjljskuse what suites you man
02:00python476no worries, I'm not complaining I'm far from that position
02:37jonathanjhow do you do the equivalent of setting jvm-opts to "-Djava.awt.headless=true" with boot?
02:39jonathanjactually, now i'm not sure if those are somehow also set when running via an uberjar
03:05bsimajonathanj: https://github.com/boot-clj/boot/wiki/JVM-Options
03:06bsimanot sure about uberjar settings. I would assume that they are carried over
03:08jonathanjwhat i'm wondering is how to do the same for boot uberjars, if they are included.
03:08Glenjaminjvm opts don't kick in for uberjars
03:08jonathanjanyway, i'm using boot too, it has some definite benefits, but i have to supply about 5 envvars to prevent permgen errors and such things
03:08jonathanjGlenjamin: okay, thanks
08:02timvisherjustin_smith, xemdetia: thought you might be interested in my solution to my TLS problems https://github.com/dakrone/clj-http/issues/304
08:02timvisheralso wondered if you had any thoughts on whether i did something wrong there :)
09:19benjyz1hello. I'm trying to do a transformation of a matrix
09:21benjyz1https://www.refheap.com/114737
09:23benjyz1,(def x {:a [[1 2] [2 5]] :b [[7 2] [8 9]]} )
09:23clojurebot#'sandbox/x
09:23justin_smith,(apply map into ((juxt :a :b) x))
09:23clojurebot([1 2 7 2] [2 5 8 9])
09:26benjyz1justin_smith: thx once yet again :)
09:26justin_smithnp
09:26benjyz1do you do clojure consulting or can recommend anyone?
09:27justin_smithbenjyz1: I'm busy with my day job. I do know some people who do consulting / contract work though.
09:28benjyz1I'll hope to give back to clojure one day.. still learning
09:29benjyz1pretty amazing that all the power is available in the browser also. using that code in CLJS
10:02Glenjaminjustin_smith: if you had a way to do microtransactions over IRC, i think you'd be minted
10:10ridcullyor when some philantrope starts paying out lazybots karma points as bitcoins
10:25justin_smithGlenjamin: hah
10:43benjyz1thanks to BTC thats now possible
10:47benjyz1anyone using H2?
10:47benjyz1I tried korma, but it still requires migration AFAICS
10:54justin_smithI worked on a db abstraction that supported h2 for a while
11:12cortexmanidiomatic way to loop over deeply nested hash map / edn file?
11:13justin_smitheither clojure.walk/postwalk or a recursive function that maps over each key/entry pair
11:15cortexmanget-in looks useful as well
11:16cortexmandoesn't seem to be good for looping though
11:18ridcullydepending on your data also tree-seq can help
11:19cortexmani am iterating over a very nested json / edn file and inserting into datomic
11:19cortexmani wrote a nested (for (let (for (let ... structure but it seems wrong
11:19cortexmani need access to each outer key/value
11:30justin_smithwhat does "outer" mean here? because by my definition of outer, all you need to do is map on the hash map if that's what you need
11:31cortexmanjustin_smith just like a deeply nested loop where you have access to all the outer loop variables from inside
11:31cortexmani'm trying to use postwalk but i don't get why this prints [nil nil] (postwalk (fn [x] (println x)) {:a "a" :b "b"})
11:31justin_smithcortexman: ok yeah, postwalk won't let you carry context like that
11:32justin_smithcortexman: the return value of your function replaces the item it receives as an argument
11:32justin_smithpostwalk is designed for nested transformations
11:33cortexmani think the recursive function approach is the natural way to clean up my (for (let structure
11:33cortexmanwith -> threads, maybe
11:33justin_smithfor nested context, you need a recursive function, calling map, for, or mapcat if done to generate data, calling doseq if it is done for side effects
11:57cortexmanjustin_smith, this is where i'm at. it doesn't work.. ;) https://gist.github.com/brianmingus/ffa2486b6d657ffaeeb2
12:10justin_smith,(defn loop-with-keys ([f e] (loop-with-keys f e [])) ([f e keychain] (f e keychain) (let [tr (cond (map? e) e (coll? e) (map list (range) e) :else nil)] (doseq [[k el] tr] (loop-with-keys f el (conj keychain k)))))) ; cortexman
12:10clojurebot#'sandbox/loop-with-keys
12:11justin_smith,(loop-with-keys #(println % "at" %2) {:a 0 :b [1 2 3]})
12:11clojurebot{:a 0, :b [1 2 3]} at []\n0 at [:a]\n[1 2 3] at [:b]\n1 at [:b 0]\n2 at [:b 1]\n3 at [:b 2]\n
12:12justin_smithcortexman: that's probably not what you want, but probably also close enough to adapt for what you want
12:12justin_smithcortexman: if you wanted values not side effects, change the doseq to for
12:13justin_smithwell I guess it would also need the call to f to move...
12:14justin_smithcortexman: if all you want is all the leaves, (remove coll? (tree-seq s)) suffices
12:15justin_smitherr, (remove coll? (tree-seq coll? seq s))
12:47ack006leiningen question here: why do some repl middleware projects suggest adding plugins to :user while others suggest adding to :repl in ~/.lein/profiles.clj? doesn't adding to :repl improve lein startup time when you don't need a repl?
13:53benjyz1hi, trying to understand this snippet
13:54benjyz1(defmethod attach-route :all
13:54benjyz1 [^Chain chain [method & handlers]]
13:54benjyz1what is "^" ?
13:54justin_smithit means apply this metadata to the next item
13:54justin_smith,(meta ^:foo [])
13:55clojurebot{:foo true}
13:55justin_smith,^:foo []
13:55clojurebot[]
13:55benjyz1how many input arguments does this method have?
13:55benjyz1chain, method & handlers?
13:55justin_smithtwo
13:55ridcullytwo
13:55ridcullya chain and some sequence
13:55justin_smith[method & handlers] is a destructuring of a single argument
13:56ridcullyis this from catacumba?
13:56benjyz1ridcully: yes, exactly!
13:57benjyz1https://github.com/funcool/catacumba/blob/master/src/clojure/catacumba/impl/routing.clj#L135
13:59benjyz1why?
13:59clojurebothttp://clojure.org/rationale
13:59benjyz1^^^
14:02ridcullybenjyz1: just out of curiosity. i spent quite some time reading the code to get my registry in there, so that rang a bell
14:02benjyz1ah good to know some people are using it
14:02benjyz1I've switched from ring
14:03benjyz1looking to contribute a little bit here and there
14:07benjyz1couldn't this methods be simplified there? :get :post :put are the same
14:09justin_smithbenjyz1: yeah, looks like someone doesn't know about :default for defmethod
14:10justin_smithin fact it looks like all the methods would be the default which means it doesn't even need to be a multimethod
14:11justin_smithoh wait, except for :error and :setup
14:11ridcullyand :any ?
14:12ridcullydifferent handler
14:12benjyz1:any and :all are the same
14:12benjyz1:get :post :put :delete
14:12fantazohi, why the f* is cider not listed doing package-refresh-contents && package-install on emacs 24.5?
14:13fantazodo I need to do something special just to get it working?
14:16fantazosry, I'm a little bit unrelaxed.
14:18benjyz1justin_smith: chaining of methods is the same as with functions?
14:18benjyz1:default doesn't help here
14:41justin_smithbenjyz1: what? I mean when you implement a method for :default then all unmatched args get that method. Then you only need to define :default, :error, and :setup
14:41justin_smithbenjyz1: when I suggested it could be a function, I had not noticed that :error and :setup were different
14:42ridcullyi guess the author wants the http verbs there explicitly
14:42benjyz1I'm trying to have a method call another method
14:42ridcullyor otherwise fail?
14:43benjyz1so (defn- addroute [..]) (defmethod :get [] addroute)
14:43justin_smithridcully: in that case you could have a method that mapped :get :put :post :patch :delete :any and :all to the same value
14:43justin_smith*a dispatch, that is
14:43ridcullythat sounds nice
14:43justin_smithbenjyz1: that would just return addroute
14:44benjyz1I mean (addroute) ... i.e. calling the function
14:44benjyz1better would be catching :get :put ... etc?
14:49benjyz1hmm, these functions are a bit weird. method is an argument an a type dispatch..
14:49justin_smith,(defmulti verb (fn [v & args] (get {:get :verb :put :verb :post :verb :patch :verb} v v)))
14:50clojurebot#'sandbox/verb
14:50justin_smith,(defmethod verb :verb [v & args] (println 'verbing))
14:50clojurebot#object[clojure.lang.MultiFn 0x4e5f2dd7 "clojure.lang.MultiFn@4e5f2dd7"]
14:50justin_smith,(verb :get)
14:50clojurebotverbing\n
14:50justin_smith,(verb :put)
14:50clojurebotverbing\n
14:50justin_smithetc.
14:52benjyz1thx. what does (get {..} v v) do?
14:53justin_smithbenjyz1: it looks up v in a hash map, returning v if not found
14:53justin_smith,(get {} :a :a)
14:53clojurebot:a
14:53justin_smith,(get {:a :b} :a :a)
14:53clojurebot:b
14:54justin_smithin other words, it looks for a replacement, but returns unchanged if no replacement is available
14:55benjyz1some more wisdom to digest. trying to follow in the context of this multi-method
14:55justin_smithbenjyz1: so it's using that hash-map to map multiple keywords to the same dispatch
14:57benjyz1what about something like this
14:57justin_smithso it's like implementing :default and not specifying those keys, but it explicitly specifies the keys and also errors if an unknown key is provided (which would not occur if :default was defined (unless you errored from default))
14:57benjyz1"(defmethod attach-route [:get :post] ..."
14:58justin_smithbenjyz1: that would work if your dispatch value was the vector [:get :post]
14:58benjyz1ah no. I want to dispatch for :get and :post
14:58justin_smithbenjyz1: vectors are valid dispatch values, they are not treated as a series of matches
14:58benjyz1individually
14:58justin_smithright, multimethods don't work that way
14:59justin_smithyou need a dispatch function that matches both of them to the same value, or to repeat your definition, or to have them use a default
14:59justin_smith,(defmulti vds identity)
14:59benjyz1I'll try
14:59clojurebot#'sandbox/vds
15:00justin_smith,(defmethod vds :default (constantly :unmatched))
15:00clojurebot#error {\n :cause "Unable to resolve symbol: vds in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: vds in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: vds in this conte...
15:00justin_smith,(defmulti vds identity)
15:00clojurebot#'sandbox/vds
15:00justin_smith,(defmethod vds :default (constantly :unmatched))
15:00clojurebot#error {\n :cause "Parameter declaration constantly should be a vector"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Parameter declaration constantly should be a vector, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.IllegalArgumentException\n :message "Parameter decla...
15:00justin_smithergh
15:00justin_smith,(defmethod vds :default [_] :unmatched)
15:00clojurebot#object[clojure.lang.MultiFn 0x5232c67d "clojure.lang.MultiFn@5232c67d"]
15:01justin_smith,(defmethod vds [:a :b] [_] :matched)
15:01clojurebot#object[clojure.lang.MultiFn 0x5232c67d "clojure.lang.MultiFn@5232c67d"]
15:01justin_smith,(vds :a)
15:01clojurebot:unmatched
15:01justin_smith,(vds [:a :b])
15:01clojurebot:matched
15:01justin_smithbenjyz1: ^ that's what I was trying to say about dispatch with a vector
15:02benjyz1in this case the code is a wrapper around the Java lib ratpack
15:03benjyz1I think ring uses a few simple macros for routing
15:03justin_smithbenjyz1: ring has no routing
15:03justin_smithbenjyz1: compojure uses a few moderately complex macros for routing
15:03benjyz1ah I see
15:04benjyz1the cool thing about catacumba is it has better async support (afaics)
15:04justin_smithwhat about ring prevents async from working? (honestly I don't know)
15:06benjyz1not sure. Ratpack and netty are highly optimized
15:06justin_smithaleph is ring compatible and uses netty
15:06justin_smithiirc
15:07benjyz1yes. cata is not aiming at that
15:07benjyz1"Provide a simple and lightweight approach for defining asynchronous web services with support for different abstractions such as promises, futures, core.async, manifold, reactive-streams, etc…​"
15:07benjyz1https://funcool.github.io/catacumba/latest/#rationale
15:07justin_smithyou're aware ring is a protocol and not a web server, right?
15:07benjyz1yes
15:07justin_smithOK
15:08benjyz1if I understand much of this is designed around jetty
15:08justin_smithno, it is a protocol
15:08justin_smithit has implementations for many servers
15:08benjyz1ok. it would be good if that doc would go into more details
15:08justin_smithjetty is the default for dev because it is a small dep
15:09benjyz1don't know too much about jetty itself, but it doesn't seem that active
15:10justin_smithI mean it could be that catacumba just wants to be less modular and do it's own monolithic thing, that's legit, but I don't see why avoiding ring would help them be more async or have better performance at all
15:10benjyz1or at least it looks to me not that versatile. its the old J2EE kind of stuff I'm trying to avoid
15:10justin_smithbenjyz1: I don't use jetty
15:10justin_smithI always use ring but I never use jetty
15:10justin_smithjetty isn't part of ring
15:10benjyz1you're right. I don't know the answer to that
15:11benjyz1its a young project and only 1 contributor
15:11benjyz1but leveraging Ratpack and Netty look like a good strategy
15:11benjyz1Ratpack is a kind of re-implementation of Grails
15:12justin_smithinteresting, not a reference to sinatra?
15:12benjyz1yes, it is
15:12benjyz1https://ratpack.io
15:13justin_smithyeah, looking at that now
15:13benjyz1the other thing what I thought would be cool is a full-stack Clojure/Clojurescript
15:13benjyz1I've seen some talk about it , and a few templates
15:13justin_smiththat's what luminus does
15:14benjyz1MeteorJS developed something like that in JS
15:14benjyz1where only data goes over the wire
15:14benjyz1and then gets re-rendered... so no HTML server side at all
15:14justin_smithwait what other than data would go over the wire?
15:15justin_smithoh
15:15justin_smithyeah, that's what reagent is like too
15:15benjyz1right. Om / React. but that's only on the client ;)
15:15justin_smithyou can render reagent's hiccup syntax on the server too
15:16justin_smiththey intentionally picked a syntax that had a server side implementation
15:16benjyz1e.g. what do you do if there is a change on the server
15:16benjyz1you have to send an update to the client
15:17benjyz1Meteor does this with keeping by keep a Mini Mongo database in the browser
15:17benjyz1but as its all in JS, I think the project is a failure. not so surprising
15:17justin_smithom puts a datascript impl in the browser
15:17benjyz1ah cool
15:18benjyz1yes, I'm sure a few people are doing similar cool stuff
15:18benjyz1with a full Clj/Cljs stack
15:21benjyz1,(defmulti verb (fn [v & args] (get {:get :verb :put :verb :post :verb :patch :verb} v v)))
15:21clojurebot#'sandbox/verb
15:21benjyz1,(defmethod verb :verb [v & args] (println 'verbing))
15:21clojurebot#object[clojure.lang.MultiFn 0x2cbcb5f6 "clojure.lang.MultiFn@2cbcb5f6"]
15:22sdegutisAha! I figured it out! (I think. Maybe.) This recursive algorithm should use /reduce/, not /for/!
15:22benjyz1,(verb :get)
15:22clojurebotverbing\n
15:22benjyz1,(verb :test)
15:22clojurebot#error {\n :cause "No method in multimethod 'verb' for dispatch value: :test"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No method in multimethod 'verb' for dispatch value: :test"\n :at [clojure.lang.MultiFn getFn "MultiFn.java" 156]}]\n :trace\n [[clojure.lang.MultiFn getFn "MultiFn.java" 156]\n [clojure.lang.MultiFn invoke "MultiFn.java" 229]\n [sandbox$eval103 invokeS...
15:22benjyz1,(verb :put)
15:22clojurebotverbing\n
15:25sdegutisreduce rocks
15:27justin_smith,(reduce :rocks nil (take 10 (iterate (fn [x] {:rocks x}) :rocks)))
15:27clojurebot{:rocks {:rocks {:rocks {:rocks {:rocks :rocks}}}}}
15:29justin_smithsdegutis: quick, without trying it, what happens if you change (take 10 ...) to (take 15 ...)
15:30sdegutisjustin_smith: you break 24 legacy .NET apps
15:30justin_smith,(reduce :rocks nil (take 15 (iterate (fn [x] {:rocks x}) :rocks)))
15:30clojurebot:rocks
15:30justin_smith!
15:30sdegutiswhaaaa?
15:30justin_smith,(reduce :rocks nil (take 16 (iterate (fn [x] {:rocks x}) :rocks)))
15:30clojurebot{:rocks {:rocks {:rocks {:rocks {:rocks {:rocks {:rocks {:rocks {:rocks {:rocks #}}}}}}}}}}
15:31sdegutisjustin_smith: you break my brain
15:31justin_smithyour welcome
15:31justin_smithsdegutis: I think it's a weirdo version of modulo
15:32justin_smithdiscovered accidentally
15:32sdegutisThat's insane.
15:32sdegutisjustin_smith: I am pretty printing your code and experimenting with it in CIDER to understand wth is going on.
15:33justin_smithsdegutis: reductions might help
15:33sdegutisAlso ->> considering you really just had (->> :rocks (iterate (fn [x] {:rocks x})) (take 10) (reduce :rocks nil))
15:34justin_smithsdegutis: oh wow nothing like modulo at all, this is a very odd pattern
15:35justin_smithoh, the pattern follows powers of 2
15:35justin_smithof course
15:35justin_smith1, 7, 15, 31, ... are all :rocks I think
15:36justin_smithand then it counts back to deeper and deeper nestings as you move back to lower numbers
15:36justin_smithoh and 3 duh
15:37sdegutis:D
15:38justin_smithor you could say instead that a power of two will have N repeats of :rocks, and then it counts down as you go up until you hit the next power of 2
15:39sdegutisHmm, (update-in m [:some-key last] ...) isn't a thing, is it?
15:39sdegutisDang.
15:39justin_smithno, unless last is a key!
15:39sdegutisHeh nope.
15:39justin_smith,(update-in {} [:some-key last] assoc :a 0)
15:39clojurebot{:some-key {#object[clojure.core$last__4383 0x11c286fb "clojure.core$last__4383@11c286fb"] {:a 0}}}
15:40sdegutisMy structure is like {:some-key [[:a] [:b :c] [:d]]} and given :e I need to derive {:some-key [[:a] [:b :c] [:d :e]]}
15:40sdegutisPerhaps I should reverse them and just use a constant 0 instead.
15:40justin_smithsdegutis: maybe you need to peek etc. in your update function
15:40sdegutispeek? hmm what's that?
15:40justin_smith,(peek [:a :b :c])
15:40clojurebot:c
15:40sdegutisNeat!
15:41justin_smith,(pop [:a :b :c])
15:41clojurebot[:a :b]
15:41sdegutisSo it's like conj but a getter for first.
15:41justin_smithsdegutis: "get the last thing conjd" is maybe one way to put it
15:41justin_smithuseful for stacks for obvious reasons
15:41sdegutisYeah I'll just use linked-lists then and use 0.
15:41justin_smith,(peek '(:a :b :c))
15:41clojurebot:a
15:42sdegutisOtherwise this requires counting the thing inside the structure, which kind of defeats the purpose of using update-in.
15:43justin_smith,(update-in {:a [1 2 3]} [:a] (fn [x] (conj (pop x) (inc (peek x))))) ; yeah kind of sucks
15:43clojurebot{:a [1 2 4]}
15:43sdegutis:D
15:43justin_smithsdegutis: though one could implement pupdate and make it nicer
15:43sdegutisMeh, nobody ever said the intermediate data structure needs to resemble how we logically think about it nor what the end result will be.
15:44justin_smith,(defn pupdate [s f] (conj (pop s) (f (peek s))))
15:44clojurebot#'sandbox/pupdate
15:44justin_smith,(update-in {:a [1 2 3]} [:a] pupdate inc)
15:44clojurebot{:a [1 2 4]}
15:44sdegutisSo this is a bit off topic, but are you able to automatically know/hear whether two different notes are the same note just in different octaves?
15:45justin_smithsdegutis: it's pretty distinctive and easy to learn
15:45justin_smithyes
15:45justin_smithI like pupdate because puppies
15:45justin_smithp(eek/op)update
15:46sdegutisIf someone plays two different C's on the piano, I can tell they're the same note. But nobody else in my family can, and I'm surprised because I thought it was something everyone automatically just knew.
15:46justin_smithsdegutis: well I think you kind of have to know what to listen for (though it is a simple thing to hear once you know what it is)
15:46sdegutisHmm. Yeah maybe.
15:47ridcullypubdate!
15:47justin_smithridcully: that would be a good one too
15:51amalloyhttps://github.com/amalloy/useful/blob/ecbdaf10ffe341d7af3ed47b2706d1c668a37da4/src/flatland/useful/utils.clj#L134
15:51amalloyupdate-peek
15:52justin_smithamalloy: ok I guess that name is easier to understand and all
15:53amalloyunlike a lot of the cutesy names in useful
16:01amalloyuseful, feature such obvious names as knit and glue
16:02ridcullyto knit a castle and sniff glue?
16:23justin_smithridcully: you know I would have said knit a scarf but I guess that works
16:26sdegutisRight.
16:33sdegutis,(update-in () [0] conj 1)
16:33clojurebot#error {\n :cause "clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.Associative"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.Associative"\n :at [clojure.lang.RT assoc "RT.java" 792]}]\n :trace\n [[clojure.lang.RT assoc "RT.java" 792]\n [clojure.core$assoc__4371 invokeStatic "core.clj" 191]\n...
16:33sdegutisOkay so that's unintuitive to me.
16:34sdegutis,(update-in [] [0] conj 1)
16:34clojurebot[(1)]
16:34justin_smithsdegutis: you are conjing onto element 0
16:34justin_smithelement 0 is nil, conj on nil gets a list
16:35justin_smithsdegutis: the first one fails because you can't look up 0 in ()
16:35justin_smithbecause () is not associative
16:35sdegutisRight, it just seems like you should be able to do nth on () though.
16:35justin_smithsdegutis: update* only work on associative things though
16:35justin_smiththere's no "replace-nth" for lists
16:36sdegutisOh right because you can't re-associate 0 in ().
16:36sdegutisWell technically you can but not 1 easily.
16:36sdegutisI see now.
16:36sdegutisThanks justin_smith.
16:36justin_smithit might be clearer if you were doing (update '(1 2 3) [2] inc)
16:37sdegutisRight on.
16:42fantazook. sometimes you need to throw away old elpa installed code just to be able to install new packages.
16:42fantazothx emacs, that's so totally obvious.
16:42justin_smithfantazo: common cider issue
16:44fantazojustin_smith, but why? this is so totally counter intuitive and you waste hours with this stupidity. no bells, no warnings.
16:44sdegutisfantazo: justin_smith isn't a fan of cider, but I'm a super fan of it ever since version 0.10.x
16:44sdegutisI really enjoy the inline execution results.
16:45fantazowell, I tried to install it and I wasted hours of why it didn't want to install from elpa
16:46fantazowhen you do a package-refresh-contents and a package-install ci<tab><tab> and are expecting that it completes with cider but no, just circe or any other package.
16:46sdegutisIs it inefficient to keep "appending" to a string via (str original-string new-string)?
16:47lockdownwhat I have noticed of cider is that they care more about features than improving stability
16:47lockdowns/about/about adding/
16:47sdegutisWould it be way more efficient to just keep a coll of strings, and then (apply str) them together at the end?
16:47justin_smithsdegutis: better to consolidate into one str call if you can, or use a StringBuilder (which is what str uses internally)
16:47sdegutisAh cool.
16:47fantazolockdown, like its normal in emacs?
16:47sdegutisI had my suspicion about that.
16:47justin_smithsdegutis: right, applying str will definitely do the trick
16:48sdegutisSweet.
16:48lockdownfantazo: no, core emacs is pretty stable ;)
16:48sdegutisrhickey thought of everything!
16:48fantazoemacs is all about features hacked together without spending any time on making them flow
16:48justin_smithsdegutis: though directly using a StringBuilder might be a little better than that (at the cost of explicitly mutating!)
16:48lockdownfantazo: if you mean external packages, then yes
16:49sdegutisjustin_smith: thanks
16:49justin_smithyeah, there's lots of featureful things for emacs that I try sometimes and find out there are still buggy and stop using again
16:49fantazohmm ok. still not convinced, but you have an opinion and I have mine.
16:49justin_smith*they are ...
16:50justin_smithfantazo: I've never seen serious issues with emacs itself (beyond how it handles long lines, and that's strightforward to avoid usually)
16:56sdegutisShould rest or next be used when you know it's a list?
16:57justin_smithnext, rest is the lazierer one
16:57justin_smithsdegutis: well, depends which you want really...
16:57justin_smith,((juxt next rest) [1])
16:57clojurebot[nil ()]
16:57sdegutisAh.
16:58sdegutis((juxt next rest) [1 2])
16:58sdegutis,((juxt next rest) [1 2])
16:58clojurebot[(2) (2)]
16:58sdegutisNeat.
16:58justin_smithyeah, they are the same until they return something empty
16:58justin_smithnext has to peek ahead
16:58justin_smithrest does not
16:59sdegutisI see.
17:00sdegutisI am determined to complete this recursive function before 5pm, one hour from now!
17:01sdegutisOh wait I think I just did.
17:35sdegutisWow. Nope. So close yet so far.
17:36sdegutisI'm just gonna roll this out with a bunch of (let)s and refactor once it's working. This is getting crazay.
17:41rcassidypost a gist!
17:41rcassidysdegutis: ^
17:41sdegutisOh yeah good idea.
17:41sdegutisIf I give up then I will.
17:41sdegutisBut it'll probably be an open source library anyway.
17:44sdegutisWhen you have more than one prefix is it prefices?
17:46AimHerePrefixes.
17:47sdegutisWow. SO MANY INTERMEDIATE VARIABLE NAMES.
17:47sdegutisI don't know if they're actually doing their job of increasing code readability.
17:47sdegutisThey're so long too!
17:53sdegutisHaha, turns out I forgot to use the recursed value from above in each deeper iteration of the function.
17:53sdegutisOops! LOL.
17:55rcassidylong variable names are a good thing if they are desceriptive
17:55rcassidydescri**
17:55sdegutis:D
17:55sdegutiscreat();
18:04sdegutisDang. Both clojure.math.combinatorics/cartesian-product and amalloy's hand-rolled version have unexpected behavior in the case of [[] [:a :b]]
18:05sdegutisFortunately remove empty? probably fixes that. But still, weird property of (for).
18:05amalloyunexpected? that's like, the obviously correct result
18:05amalloythe cartesian product of the empty set with anything is also empty
18:06sdegutisOh.
18:06sdegutisOkay then
18:06sdegutisWell I don't know math very well.
18:07amalloywell, the cartesian product of two sets isn't that hard to describe. suppose the two sets are colors and shapes
18:07amalloythen their product is all the ways to choose exactly one color and exactly one shape
18:08amalloyif there are zero colors to choose from, there's zero ways to make that choice
18:08sdegutisAhh!
18:08sdegutisKind of like multiplying by zero.
18:08sdegutisHence "product". Got it.
18:08amalloyexactly
18:10sdegutisThanks amalloy. I don't care what they say about you, you're a really helpful nice guy.
18:12sdegutisamalloy: (That's supposed to be a joke.)
18:12amalloyi laughed
18:12sdegutisYay!
18:21sdegutisDoes Clojure offer some simple way of "moving" an item matching a predicate to the beginning of a coll?
18:23TEttingeri liek malloy macro magic
18:29sdegutisTwo reduces in one day! Man I'm honor roll!
18:30sdegutis*on a
18:30ewilazarusHey guys! I would like some help here: I am trying to be smart with macros, but I think that what I'm trying to achieve is impossible. Please check out this snippet: https://gist.github.com/ewilazarus/76195fb152e843be7222 . Now, what I'm trying to do is to pass a list to a macro, which its contents should reference the variables in the scope "inside of the macro". Can you please help?
18:34sdegutisewilazarus: I think technically it may be possible, but it's "bad practice"
18:35sdegutisewilazarus: I think you have to do it by quoting them though. Try that.
18:37sdegutisOh man, I just used str/starts-with? and str/includes? !!!
18:37ewilazarussdegutis: thanks! I tried but I can't make it work
18:39sdegutisewilazarus: no idea then sorry :(
18:40ewilazarussdegutis: np, thanks anyways
18:55rhg135the thing is iit's always possible, just not sanely
18:55rhg135sun.misc.Unsafe exists
18:57justin_smithewilazarus: so you want to be able to use request and handler in mw-logic right?
19:00justin_smithewilazarus: if so, you want this --
19:00justin_smith,(defmacro defmw [mw-name & mw-logic] `(defn ~mw-name [~'handler] (fn [~'request] ~@mw-logic)))
19:00clojurebot#'sandbox/defmw
19:00justin_smith,(macroexpand-1 '(defmw wrap-options (handler request)))
19:00clojurebot(clojure.core/defn wrap-options [handler] (clojure.core/fn [request] (handler request)))
19:01justin_smithewilazarus: this is a problem in the general case (magic binding names, spooky action at a distance), but this is arguably idiomatic enough to work. It's a value judgment.
19:04rhg135hmm, if I read an use of that and say how the result is used I'd not be confused
19:04ewilazarusjustin_smith, that's exactly what I wanted!
19:06ewilazarusjustin_smith, thanks a lot!
19:08rhg135I do like how it discourages closing over (maybe stale) state
19:11ewilazarusthat's actually amazing...
20:22athinggo1ngonhi, can anyone help with the following problem? http://pastebin.com/j8b03FRY
21:25rhg135https://www.refheap.com/114756, something about that method implementation is offputting but I can't tell what
21:40justin_smithrhg135: I find the usage of vectors somewhat surprising - is it an api that takes List or something?
21:42rhg135That is me being too lazy to type the key names
21:45justin_smithathinggo1ngon: you can do it with a filter to remove the things lacking 'ds1 and a (map #(update-in % ... ) ...) to remove the 'nope things. It's about twice as big if you need the results to be a vector and lazy-seqs don't suffice
21:47pilnelisp/scheme/clojure/haskell (and to some extent forth) have ruined any other languages for me >.<
22:28rhg135That's good, they run everywhere
22:30rhg135Just lisp is near universal
22:31justin_smithrhg135: but forth runs on more cpus than all the others put together
22:32rhg135Elaborate, please
22:32justin_smiththere are processors that have never had an os implemented that still run forth
22:33rhg135And jvm bytecode too
22:33rhg135And probably js
22:33justin_smithforth easily runs on 100x the sheer number of processor models js and jvm combined run on
22:34justin_smithit's not even in the same league in terms of complexity / resources needed, by far
22:34rhg135That is true, but in practice, I only care about x86 and arm
22:34justin_smithrhg135: forth code is typically smaller in RAM usage than the equivalent assembly
22:35justin_smithrhg135: OK, I was just making a pedantic point
22:35rhg135Inb4 I write a clojure based toaster
22:39TEttingercloaster
22:40rhg135And a typo burnt my toast
22:41justin_smithquarter bagles for (), toast for [], eggos for {} and you are good to go
22:42justin_smithof course, # is a pat of butter, so a buttered eggo is a set, etc.
23:05rhg135When I first learned of C in cars, I thought why!?
23:31rhg135as an aside, what happened to the other 550 people in here?
23:32TEttingerrhg135: netsplit?
23:32TEttingerI see a ton of people
23:32rhg135maybe but none of the other channels I'm on seem affected
23:33rhg135ah there we go
23:33rhg135(dec znc)