#clojure logs

2015-12-03

03:07kenrestivo i'm getting a classnotfound error, but the jar is on the classpath and the class is inside the jar... are there weird java version mismatch issues that might be causing this?
03:07kenrestivoi'm not a java guy so please forgive my jvm ignorance
03:21tolstoy,(String. (byte-array '(-61 -72)))
03:21clojurebot"ø"
03:22tolstoyAre you using -jar?
03:26TEttingerkenrestivo: what does your command line look like?
03:26TEttingerif it isn't an uberjar you likely need -cp to change the classpath
03:28jonathanjugh
03:28jonathanj Error compiling:
03:28jonathanj /Users/jonathan/Coding/clj-documint/test/documint/session_test.clj:21:14 No
03:28jonathanj single method: get_session of interface: documint.session.ISessionFactory
03:28jonathanj found for function: get-session of protocol: ISessionFactory
03:29jonathanjthe slightly important part that error seems to totally forget to mention is the object the method is trying to be invoked on
03:30jonathanjpretty sure if it had said "No method get-session for object HeyGuysThisIsNotASessionFactory" i would have spent a lot less time scratching my head
03:30tolstoyI get those a lot. Missing parameter for me. ;)
03:37thatslifesonhow to convert a string to a vector without all of the additonal \? i.e. 12345 => [\1 \2 \3 \4 \5]
03:37thatslifesonlooking for [1 2 3 4 5]
03:38thatslifesoninto [] is adding the \
03:42tolstoy,(mapv str "abc")
03:42clojurebot["a" "b" "c"]
03:43beakyi love mapv
03:43TEttinger,(mapv #(- % 42) 12345)
03:43clojurebot#error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.core$seq__4116 invokeStatic "core.clj" 137]\n [clojure.co...
03:43TEttinger,(mapv #(- % 42) "12345")
03:43clojurebot#error {\n :cause "java.lang.Character cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Character cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers minus "Numbers.java" 137]}]\n :trace\n [[clojure.lang.Numbers minus "Numbers.java" 137]\n [clojure.lang.Numbers minus "Numbers.java" 3692]\n [sandbox$eval77$fn__78 invoke "NO_SO...
03:43TEttinger,(mapv #(- (int %) 42) "12345")
03:43clojurebot[7 8 9 10 11]
03:43TEttinger,(mapv #(- (int %) 48) "12345")
03:43clojurebot[1 2 3 4 5]
03:44tolstoy,(mapv #(Integer/parseInt %) (mapv str "123"))
03:44clojurebot[1 2 3]
03:44TEttingeryeah, tolstoy has a good approach
03:45TEttingerthe two mapv
03:45tolstoyIsn't that a function that turns a method into a clojure function?
03:45TEttingermemfn
03:45TEttinger(doc memfn)
03:45clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. name may be type-hinted with the method receiver's type in order to avoid reflective calls."
03:45TEttingerbut your case is a static function not a method
03:46tolstoyAh. I think I've been down that road before.
03:46TEttinger,(mapv (comp read-string str) "12345")
03:46clojurebot[1 2 3 4 5]
03:46tolstoy,(mapv #(Integer/parseInt (str %)) "1234")
03:46clojurebot[1 2 3 4]
03:47tolstoyOr turn it into a transducer? ;)
03:47TEttinger,(mapv (comp read-string str) "123+-")
03:47clojurebot[1 2 3 + -]
03:47TEttingerneat
03:47TEttingerit works for one-char variable names too...
03:49tolstoyEver had the case where there's a ö in your json on the client and when it arrives in your java server (aleph) over a websocket (FreeBSD), it because a "?"?
03:50beakyhttps://www.youtube.com/watch?v=c2wyg9-4rR0 wow his posteroir deltoids
03:50beakyoops wrong channel
03:54jonathanji read some interesting anecdote that people like Lu Xiaojun have a mechanical advantage in weightlifting by having a shorter than normal femur
04:15jonathanjcan i combine (doto) and (..)?
04:15jonathanj(doto obj (.. some nested method arg))
04:16jonathanjto mean, in Java: obj.some.nested.method(arg)
05:06sara_Hi,Do anyone know how to redirect into a new page in clojure using om and react
05:07jonathanjI have a concurrency problem I'm not too sure how to resolve: https://pb.codehash.net/17aa60b4ee7a4e34bb2d4b1677325451
05:08jonathanjI don't know when to (.close src-doc) because I don't know how to tell when all the futures have been resolved.
05:08beakyis there something like >>=, <$>, and <*> in clojure
05:08jonathanj(piped-input-stream) is ring.util.io/piped-input-stream: https://github.com/ring-clojure/ring/blob/1.4.0/ring-core/src/ring/util/io.clj#L11
06:57ashwin_how can I decode cookies recieved in a request?
06:57ashwin_is there a standard library?
07:03ashwin_I think this must be a standard problem
07:03ashwin_has'nt anyone faced this before?
07:14the_nonameguyashwin_: https://ring-clojure.github.io/ring/ring.middleware.cookies.html ?
07:15the_nonameguyare you looking for this, or the decoder function itself?
07:20ashwin_the_nonameguy, I need the decoder function itself
07:21ashwin_the_nonameguy: even the ring library just url decodes the string
07:41jonathanjhrm, i'm having some trouble getting clojure.data.json/write to do the right thing
07:48jonathanj(clojure.data.json/write {:some "fields"} (OutputStreamWriter. output-stream)) doesn't seem to actually write stuff
07:50jonathanj(.write output-stream "HELLO") appears to work fine
07:52jonathanjhrm, i guess i probably need to close the writer
07:52jonathanj(and use clojure.java.io/writer)
08:03the_nonameguyashwin_: well then the decoder depends on the cookie encode, which you didn't state
08:04the_nonameguyif you do it yourself, the namespace containing the encoder usually contains the decoder as well
08:05ashwin_hmm
08:05ashwin_thanks I'll look into it
08:05the_nonameguynp
08:06the_nonameguyjonathanj: you possibly need to flush the buffer
09:12jonathanjhrm, is there any obvious way to convert https://pdfbox.apache.org/docs/2.0.0-SNAPSHOT/javadocs/org/apache/pdfbox/cos/COSDictionary.html to a Clojure map?
09:17the_nonameguyhave you tried (into {} dict)?
09:19jonathanjyeah, it looks like that works, although i'm left with all these stupid java objects as keys and values
09:20jonathanjguess there's not really any way around writing a bunch of code to convert them
09:20the_nonameguyyeah, Clojure doesn't know how to turn Java classes into keywords :)
09:22the_nonameguyjonathanj: maybe this? http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/bean
09:23the_nonameguyalso checkout: http://blog.jayfields.com/2011/05/clojure-converting-java-object-to.html
11:07beakyhttp://www.thedotpost.com/2015/11/rob-pike-simplicity-is-complicated wow what a contrast to rich hickey's philosophy :D
11:12jonathanjholy crap, (bean) works magic
11:12jonathanjwhat the heck is a JavaBean?
11:14sdegutisIs it possible to make `cider-interrupt` cancel a ProcessBuilder's Process on the main thread?
11:14sdegutisThat would rock you know.
11:15jonathanjinterface{} everywhere definitely feels the opposite of simple
11:17sdegutisjonathanj: we talkin about Go?
11:19jonathanjsdegutis: beaky linked Rob Pike's talk on simplicity in Go
11:19sdegutisHeh.
11:19sdegutisOh Rob Pike, you're such a character.
11:19jonathanj<beaky> http://www.thedotpost.com/2015/11/rob-pike-simplicity-is-complicated wow what a contrast to rich hickey's philosophy :D
11:28beakybtw how come logic programming hasnt taken over programming
11:28beakylike oop and fp have
11:28beakyi dont see scala or js bragging about 'wow we have a logic constraints engine baked into the stdlib now! :D'
11:29beakyinstead its all about lambdas or mixins and classes
11:29beakyor some sort of concurrency paradigm
11:29sdegutisbeaky: it aint easy
11:29sdegutisbeaky: oop is easy
11:30beakylogic is pretty simple imo you just list a bunch of rules and the system figures out what you want
11:33xemdetiabeaky, well there was those couple disasters in the 70s
11:33xemdetiaor was it the 80s?
11:35beakyah those disasters
11:36beakyidk isnt oop also a failed disaster in a way (what happened to all those 90s stuff like COM+ and CORBA)
11:36xemdetiayeah but then java happened
11:36xemdetiacorba is more an interop thing that kind of works
11:36beakyah
11:37xemdetiaC++ was still hot too
11:37xemdetialogic programming never really had a C++ or Java level penetration
11:37xemdetiasounds like we need a rebranding!
11:37xemdetiabecause even if its the same thing called something different somehow this works
11:38sdegutisafaiui, C++ and Java were highly corporation-friendly because they allowed strong decoupling of system components, so that teams could work on it simultaneously
11:38sdegutisplus they had a low barrier to entry, being so unfortunately similar to what was taught in university
11:38sdegutisthat's a recipe for large scale adoption
11:38sdegutisanyway im just guessing
11:39xemdetiaso lets call it aool
11:39xemdetiaagile object oriented logic
11:39xemdetiajust enough buzzword soup
11:40xaxes`xemdetia: you forgot web-scale! everything has to be web-scale these days
11:41xemdetiaxaxes`, but I thought that was yesterday's words
11:41xemdetiahow about webscale 2.0
11:41xemdetiaagile web scale oriented object logic 2.0
11:41xemdetiaawsool
11:42xemdetiawe're one vowel-prefixed word away from almost having something convenient to say and also under the dos filename limit!
11:42xaxes`we're closer to awesome
11:42xaxes`:D
11:44gfredericks, #_ #nope 42
11:44clojurebot#<RuntimeException java.lang.RuntimeException: No reader function for tag nope>
11:44beakybtw why cant you nest #()
11:44gfredericksbeaky: the arg symbols would be ambiguous
11:44beakyah
11:44beakywhy not just have an extra % for each level deep :D
11:44gfredericks:P
11:45gfredericksthat would make moving code around a pain
11:49xaxes`justin_smith: so, I have to (ns luthien.palantiri (:require [(file-load "path/to/plugin.clj") :refer [name-of-some-function-from-file]))?
12:01seppohi
12:02seppodoes anyone know how to require this library in clj file? https://clojars.org/org.clojars.nakkaya/jnativehook
12:04devnseppo: you can open up the jarfile and see which files exist in there
12:07seppodevn sure
12:07keymoneis there a way to make read-string not evaluate anything?
12:08seppokeymone for which purpose are you using read-string
12:08seppodevn I opened the jar file. what's next?
12:09keymoneseppo: i want to write a simple s-exp diffing program, need to read clj file into tree and compare that to another tree - don't care about correctness of stuff in those trees
12:13fuuduCoderi want to be able to pass a filter condition to distinct. https://clojuredocs.org/clojure.core/distinct
12:14gfredericksfuuduCoder: what would the filter do?
12:14fuuduCoderwhat would be the best way. i want to filter out distinct maps from a vector of maps using certain keys
12:15gfredericksseppo: for the most part read-string already doesn't evaluate anything
12:15gfredericksfuuduCoder: maybe try giving an example?
12:15fuuduCoderyeah. so for e.g [{:a 1 :b 1} {:a 2 :b 2} {:a 1 :b 2}] on filter key :a would give me [{:a 1 :b 1} {:a 2 :b 2}]
12:15fuuduCoderi ahte emoticons.
12:15fuuduCoder*hate
12:16gfredericksfuuduCoder: that sounds like something that doesn't exist in clojure called distinct-by
12:16gfredericksgithub.com/Prismatic/plumbing has it
12:16fuuduCoderyeah. so for e.g [{:a 1 :c 1} {:a 2 :c 2} {:a 1 :c 2}] on filter key :a would give me [{:a 1 :c 1} {:a 2 :c 2}]
12:17gfredericksfuuduCoder: a quick and dirty impl is
12:17gfredericks,(defn distinct-by [f coll] (->> coll (group-by f) (vals) (map first)))
12:17clojurebot#'sandbox/distinct-by
12:17gfredericks,(distinct-by :a [{:a 1 :c 1} {:a 2 :c 2} {:a 1 :c 2}])
12:17clojurebot({:a 1, :c 1} {:a 2, :c 2})
12:17fuuduCoderhaha ..
12:17gfredericksnot even all that dirty really
12:17fuuduCoderthats cool. but my map can get complex with multiple keys
12:18gfredericksso what would it mean to pass in multiple keys?
12:18fuuduCoderlets say keys :a and :b together would determine whether your map is unique or not
12:18fuuduCoder:a and :c
12:18gfredericks(juxt :a :c) would be your function then
12:18gfredericks,(distinct-by (juxt :a :c) [{:a 1 :c 1} {:a 2 :c 2} {:a 1 :c 2}])
12:18clojurebot({:a 1, :c 1} {:a 2, :c 2} {:a 1, :c 2})
12:19fuuduCoderlet me try that.. seem spromising. thanks gfredericks
12:20gfredericksnp
12:20fuuduCoderdo you have functions at the tip of your mouth. i spent last 30 mins trying to figure out if there’s a useful function i could reuse
12:20fuuduCoder:-)
12:20gfredericksyes
12:30fuuduCodergfredericks++
12:44justin_smith,(defn distinct-by' [f coll] (peek (reduce (fn [[found results] e] (let [index (f e)] (if (contains? found index) [found results] [(conj found index) (conj results e)]))) [#{} []] coll)))
12:44clojurebot#'sandbox/distinct-by'
12:44justin_smith,(distinct-by' (juxt :a :c) [{:a 1 :c 1} {:a 2 :c 2} {:a 1 :c 2}])
12:44clojurebot[{:a 1, :c 1} {:a 2, :c 2} {:a 1, :c 2}]
12:45justin_smiththe (only?) advantage of my version is that with longer inputs the output would still be in order
12:55gfredericksoh yeah that's why it's dirty
13:37JDShuhi, does anybody have experience getting cider to work with maven?
13:38justin_smithJDShu: cider needs lein, and lein works well with maven
13:38justin_smithJDShu: are you trying to add deps at runtime? pallet / alembic makes that easy
13:39JDShujustin_smith: I'm working on a project that uses only maven and I'd like to use cider the same way I would with lein
13:39justin_smithJDShu: good luck, I think that would be a lot of work
13:41JDShu:( I'll try something else then - thanks though! good thing I asked here so I didn't end up spending a ton of time trying to do this
13:41justin_smiththough I guess the main things you need are the same things that you would need to set up with boot https://github.com/boot-clj/boot/wiki/Cider-REPL
13:42justin_smithboot also doesn't use lein, so the instructions for making cider work with boot should be transferrable to a maven based project maybe?
13:42justin_smiththe tricky part I guess is getting the right middleware injected for nrepl
13:43amalloyclojurebot: justin_smith is (paraphrased) boot is basically just maven
13:43clojurebotOk.
13:43justin_smithumm....
13:43justin_smithamalloy: not quite what I meant
13:43amalloywell of course not, but what is the point of having factoid lookups for a person if not silly misquotes
13:44justin_smithhaha, OK
13:45JDShuheh
13:45JDShualright thanks, I'll give that a shot
13:46justin_smithI wouldn't be surprised if you could load some of boot from within a maven launched repl (but don't have proof it works either)
13:49dxlr8ranybody tried coils? web framework for clj
14:03tolstoyIs it possible, using leiningen, to use JDK8 to target JDK7 for an uberjar?
14:06amalloytolstoy: yes, set the appropriate javac-otions
14:06amalloysee sample.project.clj
14:07tolstoyamalloy: Okay. It wasn't clear to me those options weren't just for the javac task. Thanks.
14:11bendlastolstoy: they are just for the javac task, what else would you need to customize for targeting different jdks?
14:11tolstoybendlas I want to build an uberjar with JDK8 to run on JDK7.
14:12justin_smithtolstoy: nothing in clojure itself targets jdks after 6
14:12justin_smithonly the java compilation would do that
14:13tolstoyAh, I'm getting java.lang.ClassNotFoundException: java.util.concurrent.CompletableFuture which must mean some lib or other I'm using deps on Java 8.
14:13tolstoyOr Oracle's JVM or something. Oy.
14:14justin_smithone of your deps must be trying to use that
14:14bendlastolstoy: yes, ClassNotFound is a source code issue. If it were a target-jdk issue, you'd get some errors about invalid byte code versions or such
14:15tolstoybendlas Yeah. I didn't even read the stack-trace when asking. Oops!
14:16justin_smithbendlas: "incompatible major/minor version...." iirc
14:16tolstoyAnd then it mentions 54. Or something like that.
14:16bendlasjustin_smith: yes, I think YRC
14:29jonathanj(:a {} 42)
14:29jonathanj,(:a {} 42)
14:29clojurebot42
14:30jonathanj,({} :a 42)
14:30clojurebot42
14:30jonathanjhrm
14:30justin_smith,(:a 42 42)
14:30clojurebot42
14:30jonathanji thought there was one of these forms that didn't support a default value
14:30clojurebotTitim gan éirí ort.
14:30justin_smith,(nth nil 42 42)
14:30clojurebot42
14:32beaky,(apply (partial apply +) [[1 2 3] [4 5 6] [7 8 9]])
14:32clojurebot#error {\n :cause "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers add "Numbers.java" 128]}]\n :trace\n [[clojure.lang.Numbers add "Numbers.java" 128]\n [clojure.core$_PLUS_ invokeStatic "core.clj" 962]\n [clojure.core$_PLUS...
14:32beaky:(
14:33justin_smith,(apply + (map (partial apply +) [[1 2 3] [4 5 6] [7 8 9]]))
14:34clojurebot45
14:34jonathanji don't think there's any point trying to partially apply + without any arguments, it takes & args anyway
14:34justin_smithjonathanj: you need apply
14:34jonathanj(reduce + (flatten [[1 2 3] [4 5 6] [7 8 9]]))
14:34jonathanj,(reduce + (flatten [[1 2 3] [4 5 6] [7 8 9]]))
14:34clojurebot45
14:34justin_smith,flatten
14:34clojurebot#object[clojure.core$flatten 0x3ec68d46 "clojure.core$flatten@3ec68d46"]
14:34justin_smith~flatten
14:34clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
14:34justin_smithjonathanj: flatten is the worst thing
14:34justin_smith,(flatten {:a 1 :b 2})
14:34clojurebot()
14:35jonathanj(reduce (partial apply +) [[1 2 3] [4 5 6] [7 8 9]])
14:35jonathanj,(reduce (partial apply +) [[1 2 3] [4 5 6] [7 8 9]])
14:35clojurebot#error {\n :cause "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentVector cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers add "Numbers.java" 128]}]\n :trace\n [[clojure.lang.Numbers add "Numbers.java" 128]\n [clojure.core$_PLUS_ invokeStatic "core.clj" 962]\n [clojure.core$_PLUS...
14:35jonathanjoh, that's the same problem as originally
14:35jonathanjjustin_smith: why does flatten even exist then?
14:35justin_smithit's a mistake, and it is still there for backward compatibility I guess
14:36justin_smithI take the urge to flatten something as a sign I have made a mistake in my design
14:36justin_smithusually mapcat suffices
14:36jonathanji've never actually called (flatten) before, i've just seen the function
14:39gfredericks,(flatten {:a 1 :b [3]})
14:39clojurebot()
14:39gfredericksI guess it treats maps as scalars doesn't it
14:39gfredericks,(flatten [{:a 1 :b [3]}])
14:40clojurebot({:a 1, :b [3]})
14:40justin_smithgfredericks: yeah, same with strings and sets iirc
14:41jonathanj,(reduce (partial apply +) 0 [[1 2 3] [4 5 6] [7 8 9]])
14:41clojurebot45
14:42gfredericksthe other use cases of flatten are solved better by tree-seq
14:43gfredericks,(tree-seq coll? seq {:a 1 :b [3]})
14:43clojurebot({:a 1, :b [3]} [:a 1] :a 1 [:b [3]] ...)
14:43gfredericks,(remove coll? (tree-seq coll? seq {:a 1 :b [3]}))
14:43clojurebot(:a 1 :b 3)
14:43justin_smith,(remove coll? (tree-seq coll? seq {:a 1 :b [3 "hello"]}))
14:43clojurebot(:a 1 :b 3 "hello")
14:44justin_smithinteresting
14:44gfredericksit's customizable as hell
14:44gfredericks,(let [coll? (some-fn coll? string?)] (remove coll? (tree-seq coll? seq {:a 1 :b [3 "hello"]})))
14:44clojurebot(:a 1 :b 3 \h ...)
14:45gfredericksyou could treat integers as collections of 1s if you wanted to
14:45justin_smithgfredericks: I still stand by flattening being a sign of either a bad design or a bad api (AKA someone else's bad design, but maybe you are stuck with it)
14:45gfredericksjustin_smith: some things are treeful
14:50justin_smithgfredericks: hmm, I'll accept it as long as you name it "rake-leaves"
14:51gfredericksI think $ would be a good namespace for global mutable stuff
14:51gfredericksprobably just repl-oriented
14:52justin_smithgfredericks: like how vinyasa does stuff?
14:52gfredericksmaybe, I forgot that existed
14:54gfrederickswoah this library is crazy
14:57gfredericksI wonder if he thought of the . namespace himself
15:26jonathanjis there a better way of spelling (- 0 n)?
15:28matthavenerjonathanj: you can do (- n)
15:28jonathanjah, thanks, i didn't even think to try that
15:30jonathanjhas anyone used Graphics2D.rotate?
15:32domokato_in a macro, how do i get the namespace-qualified symbol of a passed-in symbol, for use in derive
15:32domokato_?
15:33gfredericksdomokato_: I'm not sure if that problem is well-defined
15:34gfredericksdomokato_: my guess is it'd be easier/cleaner to always have explicit namespaces anywhere you intend to use inheritance
15:35domokato_gfredericks: ah okay, that makes sense
15:37TrioxinI was surprised to not see any youtube vids on work in convolutional neural networks in clojure using opencl and/or cuda.
15:39Trioxinsee libs in google though
15:40domokato_gfredericks: hm, in my macro i'm using the symbol to defrecord before using it in derive, which means I can't fully qualify it in the macro call since it doesn't exist yet
15:42Trioxineh, https://github.com/whilo/nd4clj "Not really usable yet, as it is not compliant to core.matrix"
15:42gfredericksdomokato_: symbols don't have to be "created", you can use any symbol anywhere anytime
15:43gfredericks,'my.ns.SomeDefRecord
15:43clojurebotmy.ns.SomeDefRecord
15:43gfredericksdomokato_: I'm starting to think you might be asking about something else
15:43gfredericksprobably the class instead of the symbol
15:44domokato_,(doc derive)
15:44clojurebot"([tag parent] [h tag parent]); Establishes a parent/child relationship between parent and tag. Parent must be a namespace-qualified symbol or keyword and child can be either a namespace-qualified symbol or keyword or a class. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to, and modifies, the global hierarchy."
15:44domokato_i tried passing in the full symbol, org.aiinventions.aetherships.model/ShieldState, for example
15:44domokato_but i'm getting "java.lang.RuntimeException: Can't refer to qualified var that doesn't exist" at compile time
15:47domokato_,(defrecord sandbox/test-record [thing])
15:47clojurebot#error {\n :cause "Can't refer to qualified var that doesn't exist"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Can't refer to qualified var that doesn't exist, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.RuntimeException\n :message "Can't refer to qualified var that do...
15:48domokato_gfredericks: so it looks like i need a non-fully qualified symbol for defrecord but a fully qualified symbol for derive. not sure how to do that
16:07gfredericksdomokato_: I think you're still confused about the difference between a symbol and a class, but I can't help any further right now
16:08justin_smithdomokato_: what are you doing with derive?
16:09domokato_justin_smith: i'm trying to implement polymorphic records
16:10justin_smithso you are using multimethods on records, and using derive to describe their heirarchy?
16:10domokato_haven't gotten to the multimethods yet, but yes
16:10justin_smithrecords are already "polymorphic", they can hold any data type you like
16:10jakedusthi, what's the most idiomatic way to test unexported functions (unexported as in `defn-`)
16:11justin_smithjakedust: @#'the-ns/the-private-fn
16:11domokato_justin_smith: i mean records that can be extended by other records
16:12justin_smithdomokato_: so you want multimethod dispatch to find defaults based on some other more general record type?
16:12jakedustjustin_smith: thanks! what's the difference between derefing it and not derefing it? both ways seem to work
16:12justin_smithbecause records don't do field inheritence or protocols or interface inheritence
16:13justin_smithjakedust: #'foo when called does an automatic deref
16:13jakedustoh, I see, thanks!
16:13justin_smithjakedust: but if you are using a value, you need the explicit @, so it's good to get in the habit
16:13justin_smiththe calling case is special and the @ is optional then
16:15domokato_justin_smith: not sure what you mean by defaults. My "super records" are just lists of fields and don't have an actual class. When a record extends a super record, i just conj those super fields and put them in the defrecord call
16:15justin_smithso you are rolling your own inheritence by hand
16:15domokato_yep
16:16domokato_i have different records that share a sprite field, for example, and i'd like to be able to get the sprite field out of all of them without having to switch on the type
16:16justin_smithdomokato_: (map :sprite coll-of-heterogenous-records)
16:17domokato_i'm using records because keyword access to records is slow for some reason
16:17domokato_er
16:17domokato_.field
16:18justin_smith#(.field %) then ?
16:18hiredmanit is slow because you have many different types so you are blowing the catch
16:18hiredmancache
16:18domokato_justin_smith: doesn't that need to be type hinted to avoid reflection?
16:19domokato_hiredman: oh, i didn't know that. but in my case there's not really a way around that, or is there?
16:19hiredmanwhy aren't you using a single record type if they all have the same field?
16:20hiredmanif you do keep them as distinct records, use a protocol
16:20domokato_hiredman: because they have different fields in addition to that shared field. A ship has a sprite and a pilot, etc.. A bullet has a sprite and a lifespan
16:21hiredmanuse a protocol
16:22domokato_hiredman: use a protocol in what way?
16:22hiredman(defprotocol IHaveASprite (get-sprite [thing-with-a-sprite]))
16:23justin_smithagreed, if you find keyword lookup too slow, you won't like multimethod dispatch time
16:23hiredmanextend the protocol to the records inline in your defrecords
16:23domokato_hiredman: also, going back to what you said before. are you saying if i process all of my ships in order, then all of my bullets, etc, i won't blow the cache and it'll be much faster?
16:24hiredmandomokato_: no, the cache is monomorphic if I recall
16:24hiredmanonce you start having different types going through callsite performance will tank
16:25hiredmanthat is the case in generally for exverything on the jvm
16:26hiredmanan inline defprotocol on the jvm actually works around that (because everything that implements the protocol inline shares an interface)
16:27hiredmanso instead of having a bunch of types which, as far as the jvm and the jit knows, having nothing to do with each other, you get a bunch of types that the jits knows share some structure
16:31domokato_hiredman: okay! i think i got it
16:31domokato_hiredman: for a second i forgot defrecord can extend protocols
16:32domokato_thx hiredman and justin_smith
16:42hibou,(map #(apply + %) (map list '(1 2 3) (rest '(1 2 3))))
16:42clojurebot(3 5)
16:42hibouis there any better way to do that ?
16:42justin_smith,(map + '(1 2 3) (rest '(1 2 3)))
16:42clojurebot(3 5)
16:42hibouyes of course thanks justin_smith
16:43gfredericks,(->> '(1 2 3) (partition 2 1) (map #(apply + %)))
16:43clojurebot(3 5)
16:43gfredericksnah justin_smith's is better
16:43justin_smithyours is more clever though
16:52gfredericksno way man
16:57didibusI'm calling into a java method, but Clojure seems to be selecting the wrong overload. I've tried to type hint, but I'm not sure how to do so it can pick the right overload
16:58gfredericksdidibus: does *warn-on-reflection* still give you reflection warnings?
16:58justin_smithdidibus: is it varargs? varargs methods from clojure are a bit weird
17:01hiredmandidibus: why do you think it is picking the wrong overload?
17:01didibusHum, actually, it might be my fault.
17:01didibusI think I might just have the signature wrong
17:08WorldsEndlessAny ideas why my repl tells me "Please, install (or update) cider-nrepl 0.10.0 and restart CIDER" when I'm using today's package?
17:12codahaleWorldsEndless: CIDER 0.10 was released today.
17:12WorldsEndlessRight. And I'm using it (was using snapshot before)
17:12WorldsEndlessThe start of that message, before it starts warning about all the unspported nREPL ops, is:
17:12WorldsEndless; CIDER 0.10.0 (package: 20151203.822) (Java 1.8.0_65, Clojure 1.7.0, nREPL 0.2.12)
17:13codahaleOdd. No idea, sorry.
17:16hibouhttp://paste.ofcode.org/JbLWDZqqVRs287ReQESUFL
17:17hibouI got the error java.lang.ArithmeticException: integer overflow
17:17hibouin the last test https://www.4clojure.com/problem/132
17:18gfrederickshibou: looks like that means your function isn't lazy
17:18gfrederickshibou: the sequence created in that test throws that exception if you consume too much of it
17:18hiboubecause I used that zip (map list l (rest l)) ?
17:19gfredericksnot sure, I didn't look at your code much after I didn't find any arithmetic there
17:19hibouwhen I do a (rest l) then my code is not lazy anymore ?
17:20gfrederickshibou: I suspect it's because you're using recur, which is eager
17:32pvinishello. i wanna test all the things in a vector, without having many `(is (somefn item))`
17:32pviniscan i do that?
17:32gfredericksdoseq
17:32gfredericks(doseq [item items] (is (somefn item)))
17:32pvinisaha
17:32pvinisawesome. thanks
17:44kenrestivoi love destructuring. makes code so much cleaner and concise
18:11MONODAI'm using cursive and intellij to debug some code but in order for my repl session to see the changes I make I need to restart the repl and start over again. any ideas why?
18:11cflemingMONODA: What sort of changes are you making?
18:12MONODAI'm writing the matrix library protocols for my matrix implementation
18:12justin_smithMONODA: higher order functions won't see new definitions for your defs / defns unless you re-run them
18:12justin_smiththat's a common gotcha
18:13MONODAHow do I rerun the defs? I thought I was doing that when I synced the current file with the repl
18:13justin_smithMONODA: oh, yeah, protocols are not very nice about reloads
18:13MONODAhmm ok... any workarounds?
18:13justin_smithyou can make the protocol method call a def - then changing the def will update what the protocol does
18:14justin_smithbut you would want to move it back from the def into the protocol when done debugging - you lose performance when you move it out to a def
18:14MONODAsounds easy enough
18:14MONODAthanks
18:15alive876_i, could anyone take a look at my project.clj file, getting loading error http://pastebin.com/DdTmryNL much thanks!
18:15MONODAIm also having another problem where I get a stack overflow when I run some buggy code and then the repl starts acting weird until i reset
18:15MONODAis that expected? any solutions other than restarting repl session?
18:16cflemingMONODA: What do you mean by acting weird?
18:17MONODAit will only respond with "stack overflow" until i restart it
18:17MONODAbut there are some functions I can call and it will respond as expected
18:18cflemingIs the loop in the stacktrace in your code, or in something else? It sounds like your buggy code is hanging around and being called somehow.
18:19MONODAim not sure, would I just check that with (pst) ?
18:20cflemingYeah, or you can use the button in the Cursive REPL window to print the last exception
18:20MONODAso how would I kill my buggy code?
18:27justin_smithMONODA: is it happening in a thread somewhere?
18:27MONODAno im not doing any concurrency
18:28justin_smiththen I don't see how the errors are repeating if you have a repl prompt...
18:49pvinisi want to chck if numbers in a seq are continious, is that close? `(reduce (fn [a b] (= (inc a) b)) (list 4 5 6))`
18:49j-pb_monotonic, or really off by one?
18:50pvinisby one
18:50justin_smithpvinis: that won't work because you need to return the previous item
18:50pvinis456 is true, 356 is false
18:50pviniscould you point me to the correct function?
18:50pvinismaybe with doseq?
18:51justin_smith(every? #(= 1 %) (map - (rest coll) coll))
18:51j-pb_(= s (range (first s) (inc (last s)))
18:52justin_smithj-pb_: oh, that's a good one
18:52pvinisok, i have to try them to understand
18:52pvinisone sec
18:52j-pb_missing paren in my one, add one to the end ;D
18:53j-pb_probably not the most efficient one, since last is O(n)
18:54justin_smith(every? (map = s (range s Integer/MAX_VALUE)))
18:54pvinisj-pb_: ah cool! so you make the range from the first, and just cheeck if same
18:54pvinisinteresting..
18:54j-pb_justin_smith: nice even better :D
18:55pvinisjustin_smith: trying yours now
18:55justin_smithpvinis: I think every? might be missing an arg there
18:56pvinisthe first one is fine
18:57pvinisyea, the second one is complaining
19:02pvinis(every? (fn [[a b]] (= (inc a) b)) (partition 2 1 s))
19:02pvinissomeone on slack offered this..
19:03pvinispartition with step works interestingly too
19:05domokatojustin_smith, hiredman: it works! extensible records! http://pastebin.com/Xw796bk3 one level deep at least
19:07j-pb(= (rest s) (butlast (map inc s)))
19:10pvinisj-pb: is butlast faster?
19:10pvinisisnt it same as last?
19:10justin_smithpvinis: butlast is all elements but the last
19:11j-pbnope
19:11pvinisyea. so to get that, itsnt it O(n) again?
19:11j-pbyeah
19:11pvinisoh linear time says the doc
19:11pviniscool
19:12pvinislast is also linear..
19:12j-pb(or how about this
19:12pviniswhat was O(n) that you said before?
19:12j-pb(apply = true (map = s (range (first s))))
19:12j-pblast
19:13pvinisomg the one with butlast is magic!
19:13justin_smith(every? true? (map = s (range (first s)))
19:14j-pb(every? true? (map = s (iterate inc (first s)))
19:14justin_smithj-pb: that won't work actually - first is is used as the upper limit
19:14justin_smithright
19:14j-pbdoesn't have chunking though so slower
19:14j-pbyeah
19:14justin_smithor (range (first s) Integer/MAX_VALUE)
19:14pvinismy brain = mush
19:14j-pbyeah but dat max_val D:
19:15j-pb;D
19:15j-pbbut has chunking so thats nice
19:15j-pbI wonder, does inc autoconvert to bignums once it hits the limit?
19:15justin_smithj-pb: it stops when the shorter collection runs out
19:15justin_smithj-pb: nope, but inc' does
19:15justin_smith,(doc inc')
19:15clojurebot"([x]); Returns a number one greater than num. Supports arbitrary precision. See also: inc"
19:15j-pbnoice
19:15j-pb,(doc inc")
19:15clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
19:16justin_smith,(inc' Long/MAX_VALUE)
19:16clojurebot9223372036854775808N
19:16justin_smith,(inc Long/MAX_VALUE)
19:16clojurebot#error {\n :cause "integer overflow"\n :via\n [{:type java.lang.ArithmeticException\n :message "integer overflow"\n :at [clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]}]\n :trace\n [[clojure.lang.Numbers throwIntOverflow "Numbers.java" 1501]\n [clojure.lang.Numbers inc "Numbers.java" 1839]\n [sandbox$eval93 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval93 invoke "NO_SOURCE_FIL...
19:16j-pbah, you never stop learning
19:17irctcHi all. :)
19:17j-pboi
19:17pvinisok tried the apply one, and the too every
19:17pvinisonly this worked
19:17pvinis(every? true? (map = s (iterate inc (first s)))
19:17j-pbyeah, I used range wrong
19:18justin_smith(every? true? (map = s (range (first s) Integer/MAX_VALUE)))
19:18pvinis,(inc" Long/MAX_VALUE)
19:18clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
19:18justin_smithpvinis: not inc", but inc'
19:19irctcInstead of printing output how do I save the output from this code to a separate variable outside the go block? (go (while true (println (<! c))))
19:19j-pbirctc: atom
19:19irctcj-pb: I am completely unfamiliar with atoms, xould you please explain?
19:20pvinisbut j-pb and justin_smith, nice solutions. creative
19:20j-pbirctc: however, this will probably negate many of the advantages of core async, so data should be passed around through channels whenever possible
19:20pvinisi wrote them down so i can check them out again later
19:20pvinisthank you :D
19:21irctcj-pb: well now I get data really fast just printed to stdout. Instead of that I want that data to be saved in a collection in some variable.
19:21j-pbirctc: what do you want to do? clojure doesn't really have variables, and assigning the value to something in the scope around the go block doesn't really make sense because of the while true
19:21j-pbso you can later look at the values?
19:21j-pb(def events (atom [])
19:21irctcWell, I just want to put the data returned from my async calls to a {}.
19:22irctcYes.
19:22j-pb(go (while true (swap! events conj (<! c))))
19:22j-pbthat puts them into the events atom
19:22j-pbbut what do you want to do with that data?
19:23j-pbI mean, putting it into the atom, doesn't nessecarily make it accessible
19:23j-pbI mean, you need to get at it from some context right?
19:23irctcWell, I want to later process that data in other functions.
19:23j-pbpvinis: np, thanks for the nice riddle :D
19:24j-pbirctc: why not pass that data to the processing functions via channels?
19:24pvinis:)
19:24irctcj-pb: How do I do that?
19:24j-pbirctc: alternatively you could do something like this if you just want to store the messages locally in the go loop
19:25j-pb(go (loop [e (<! c)])))
19:25j-pburgh sorrry
19:26j-pb(go (loop [e (<! c)
19:26j-pb acc []]
19:26j-pb (recur (<! c) (conj acc e))))
19:26irctcI know about the lets, and I tried that and it works, but outside the scope of the go block I can't access those bindings. I need to be able to access the results outside the go block.
19:26j-pbwhy?
19:26clojurebotwhy not?
19:27j-pbwhy not put the processing in other go blocks?
19:27justin_smithj-pb: if you exit the loop, the channel returned by the go block will be able to read whatever you returned from that loop
19:27j-pbthe above is an example of a statefull goroutine btw
19:28j-pbjustin_smith: yeah sure, but if you have while true in there, then you never exit from it
19:28justin_smithj-pb: oh wait, you probably know that, and irctc was asking, never mind
19:28irctcWell, I have five calls to the same function with different data that need to happen simultaneously so that's why I'm using async. This processes the whole lot a lot faster. So far I can print the results but I want the results to be saved in a map so that I can use them later.
19:28j-pbirctc: honest suggestion, use futures
19:29irctcI need the while true to read the data as it is being fed into the channel.
19:29j-pbcore async is great for coordination, but not that great for parralel computation
19:29j-pbif you just want more performance, I'd suggest
19:29j-pbpmap for example
19:29j-pbor if you want to do something 5 times on the same data
19:29justin_smithirctc: looping infinitely is incompatible with returning a result
19:29justin_smith~pmap
19:29clojurebotpmap is not what you want
19:30irctcSo how do I create a loop that continually checks wether I have something in my channel that needs to be taken out?
19:30justin_smithirctc: loop while the channel is open, close the channel when done feeding it
19:30j-pb(let [r1 (future (expensive computation))
19:30j-pb r2 (future (expensive computation2))
19:30j-pb r3 (future (expensive computation3))
19:30j-pb [@r1 @r2 @r3])
19:30justin_smithor use a special :finished value
19:30j-pbwill do r1 r2 and r3 in parralel
19:32j-pbunless you have a huge amount of coordination, core.async is usually not what you want
19:32j-pbhell I just wrote a kafka inspirte persistent log for clojurescript so that I don't have to use the core.async sausage machine
19:33j-pbirctc: so yeah, if you
19:34irctcj-pb: so what you're saying is that there is no way I can do this with core.async?
19:34j-pb're new to clojure, learn about futures and pmap first, to speed things up
19:34j-pbirctc: I'm not saying there is no way
19:34j-pbI'm just saying it might not be the best option
19:34j-pbwhat is your scenario?
19:34j-pbyou get data in?
19:35j-pband you want to do different things on it in parralel?
19:35irctcyes
19:36j-pband what do you want to do with the results?, just keep them?
19:36j-pbwhat do you want to do in parralel?
19:36irctcWhat is that website where I can quickly paste code to show you what I'm up to?
19:36j-pbgist
19:36j-pbpastebin
19:38irctchttp://pastebin.com/M4H0ypw6
19:38irctcThat's my function.
19:39j-pbwhere does in-chan come from?
19:39irctcNow if instead of conj take-ipnut I just put println, it prints out the results really quickly. But as soon as I try to conj to take-input I get nil returned and take-input remains empty.
19:40irctcIt's defined outside and it's allready filled with data to be processed.
19:40j-pbfilled by what?
19:40j-pbcan you show me?
19:41irctcSure it's a map of key-value pairs.
19:41j-pbno no :), not with what, by what ^^
19:41j-pbhow do you fill it
19:42irctcI have a function that generates the data when it's called.
19:42j-pbcan you show me the code where you put it in in-chan :)
19:43irctchttp://pastebin.com/DKSpSwr1
19:44irctcAnd stdin-reader is where the data is stored to be put in in-chan.
19:44j-pband the content of stdin-reader is finite?
19:44j-pbor an infinite stream?
19:44irctcYes, it's finite.
19:44j-pbsmall enough to hold it in memory?
19:44irctcYes.
19:45j-pb(pmap (fn [line] (create-ratings api-key line)) stdin-reader)
19:45j-pbdoes exactly what you want
19:45j-pbexcept that it automatically chooses the right amount of threads for maximum performance
19:46j-pband would generally faster than core.async I think because of less locking/sheduling overhead
19:48j-pbon a side node, when you close the channel you can dump all it's contents into a collection with into
19:48j-pbbut don't do this
19:48j-pbuse pmap
19:49irctcj-pb: Thank you a thousand times!!!! :D
19:49j-pbmost welcome :)
19:49irctcIt does exactly what I needed it to do! :D
19:50irctcI really appreciate your help. :)
19:50j-pbno worries, glad I could :)
19:50j-pbcore.async is cool tech, but the most powerfull stuff is the simple things in the std lib :D
19:56kenrestivoi'm trying to use a library that uses JSR47 for logging, with timbre. how much pain and suffering will i have to endure to get that to happen?
20:02pvinisgood night all
20:03j-pbnight :)
20:11irctcGood night everyone!
20:15MONODAI'm writing a recursive protocol, how can I be sure that I am calling my new protocol rather than the protocol written for another datatype?
20:16MONODAI'm getting a type error so i guess clojure doesnt know about my new implementation?
21:01kenrestivono love for jsr47, eh?
21:04kenrestivohmm, i guess this jsr47 thing uses java.util.logging as a back-end. so now i just have to figure out how to grab those messages and get them into timbre, i guess? this java logging thing is... complected.
21:59krabadorhttps://www.youtube.com/watch?v=CdPn1mCmqoE