#clojure logs

2014-12-30

00:00rritochandyf: This is effectively a code generator that generates java code from a .grammar file so it needs to run before javac
00:02rritochandyf: It is a command line tool, I'm assuming that the maven plugin handles downloading and executing the compilation process for maven projects, and I'd like to do the same from a leiningen project.
00:04andyfok, not aware of anything there. The generation of code sounds similar to the way cljx generates Clojure/Java and ClojureScript code from common source files before the rest of compilation proceeds, but I think in that case you have to enter a separate Leiningen command first -- I believe it is not integrated in the way you describe.
00:08luxbockrritoch: creating your own SableCC watching task with https://github.com/boot-clj/boot/wiki might be easier than with Leiningen
00:10rritochluxbock: Thanks for the suggestion. This is my first time seeing that project.
00:12luxbockthe version 2.0 is rather new, so there might be some rough edges, but I think the ideas behind it are very promising
00:12luxbockI haven't used it myself yet but I plan to
00:12rritochandyf: It sounds like I'd need to make a leiningen plugin myself than. Is there a standard place for dropping executables needed by leiningen plugins? I would think it should go into the .m2 folder, but I don't see anything in my m2 folder thats executable.
00:12luxbockthe #hoplon channel is very helpful for Boot related problems
00:14andyfrritoch: I don't know. If you just needed to hack something up, rather than distribute something others can use, it seems you should be able to put an executable anywhere in your command path.
00:14rritochluxbock: I'm going to need to look into boot more. Leiningen has a lot of issues related to build-order which can be very frustrating to deal with, and if it has a good solution for third party compilers than I may be better off changing the platform.
00:15rritochandyf: Ok thanks. It sounds like a gray area. I've run into the same issue with phantomjs where there's really no standard place to drop third party command line tools.
00:18celwellDoes anyone know how I can easily get the client's IP address? I.e., the equivalent of $_SERVER['REMOTE_ADDR'] in PHP. I'm running ring on a Tomcat server.
00:19rritochandyf: If I did make a plugin like this I'd probably want it distributed just to save the next-developer with this issue some time. But there should be some standard "safe" place to drop command line tools. I'll poke around the leiningen script to see if maybe there's something undocumented that's already available.
00:21andyfThere's also the #leiningen IRC channel, and an email list for Leiningen, where people may know an answer. The IRC channel might be a bit lower populated than usual, and asking here is usually at least a good a place to ask as there, on IRC at least.
00:22rritochcalwell: You get all that information from the servlet request http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getRemoteAddr()
00:26rritochandyf: I'm also in #leiningen, but I don't think technomancy is around. I also prefer IRC since it is much less formal and there's less chance of clients reading it.
00:28rritochandyf: The last thing I want are my clients to start asking me to build them programming languages for their end users. I'm having a hard enough time doing it for myself. This is nothing more than a proof of concept project.
00:29rritochandyf: Trying to produce a C language interpreter that can define operators at runtime. Effectively a LISP that uses C syntax.
00:31andyfI've run across 1 or 2 interpreters for C-like languages, but not one based on a Lisp before, unless you count the data format I've heard about used within GCC as an intermediate compilation format.
00:37rritochandyf: This is the resurrection of an issue that I ran into using the Pike language which is similar to C. Clojure is the first language I've ever modified, though I've studied compiler design for awhile. I'm trying to go from theoretical to a practical application, and LISP is really an ideal backend since it is so mutable and concepts can be tested and debugged much more quickly from LISP.
00:38rymndhngdoes anyone know in Datomic what the difference is between :db.unique/identity and :db.unique/value -- I'm assuming that for non-ref types, they're the same thing?
00:42rritochandyf: I acctually have a lot of the framework in place for this already, and by extending JCPP I was able to quickly produce a preprocessor with the features I need. SableCC seems to be the best tool for building the compiler so that is where I'm at now.
00:43rritochandyf: But getting seemless integration between clojure and the SableCC produced code is going to take some effort.
00:44andyfyou've considered simply having a separate manual step to run SableCC to generate Java, followed later by Leiningen commands for building Java and/or Clojure?
00:44andyfwrapped up in a bash script or something?
00:45rritochandyf: I have considered compiling the C like language directly to LISP which would be ideal, but that is probably beyond my current capabilities.
00:45andyfSableCC compiles the C-like language to Java source code?
00:45rritochandyf: Yes, that is what I'm going to do to get started, but I wanted to ask if any resources were already available so I'm not re-inventing too many wheels.
00:46andyfUnless you need that automated within Leiningen itself, seems you could consider making it a separate step to generate the Java first.
00:48rritochSableCC: Not exactly. SableCC produces java source code to do all of the lexical analysis and parsing. Action classes are responsible for generating the final output, which could be anything from bytecode to an interpreter.
00:51rritochandyf: Once the java classes are produced I would believe I could write all the action classes in clojure
00:52rritochandyf: Outputing clojure code is probably a possiblity, but I'm starting with the interpreter direction since that should be slightly easier.
00:55rritochandyf: If I ever make it to the point of outputing clojure code that would have some powerful implications since it would then be possible to compile almost any language into clojure.
00:56rritochandyf: But that isn't really my goal.
01:06rritochandyf: Now if I could do the opposite, compile clojure forms into C language, that is something that would be extremly useful when combined with OpenCL, but I've never seen any technology that can do it.
01:07rritochandyf: I had a client ask for that but it was and still is, beyond my capabilities since there's no JVM in most OpenCL driven hardware.
02:20fairuzIf I have something like [{:name "foo" :age 22} {:name "bar" :age 44} {:name "meh" :age 22}]. Is there any easy way to know if "foo" is inside this vector?
02:26akkadfind-if?
02:28fairuzakkad: Is this not in core? Which lib can I find find-if?
02:30justin_smith,(some (comp #(= % "foo") :name) [{:name "foo" :age 22} {:name "bar" :age 44} {:name "meh" :age 22}])
02:30clojurebottrue
02:31justin_smithchange "some" to "filter" if you want to get all matches, or (comp first filter) if you want to get the first match
02:33fairuzneat. Thanks. I'll never find this on my own :)
02:34Empperi'some' is one of those wierdly named functions which has a sensible reason to be named like that
02:34Empperi:)
02:34justin_smithfairuz: you know about the cheatsheet right? and grimoire
02:35justin_smithhttp://clojure.org/cheatsheet
02:35justin_smithhttp://conj.io/
02:35fairuzjustin_smith: Yes. I was looking into conj.io. Did find some but have no idea idea combining it with comp
02:36justin_smithfairuz: there is probably a at least 3 useful ways to use comp with just about every clojure function
02:36Empperilol, so true
02:36Emppericlojure is a functional language and those are all about function composition
02:37Empperiwhich comp does
02:38jwis the grimoire up to date?
02:38theme2How do I test if a character is upper case?
02:40justin_smith,(Character/isUpperCase \B)
02:40clojurebottrue
02:40justin_smith,(Character/isUpperCase \b)
02:40clojurebotfalse
02:40theme2thanks
02:41Empperi,(map #(Character/isUpperCase %) "asdfBcsd")
02:41clojurebot(false false false false true ...)
02:41justin_smith,(Character/isUpperCase \☃)
02:41clojurebotfalse
02:41theme2justin_smith: that character looks like a circle pointing up
02:41justin_smiththeme2: it is a snowman
02:42theme2O_o
02:42theme2doesn't work on tryclj.com
02:42justin_smithhttp://www.utf8-chartable.de/unicode-utf8-table.pl?start=9728
02:43justin_smithoh, I think tryclj may be clojurescript?
02:43theme2O_o
02:44justin_smithwait no, Character/isUpperCase works in tryclj
02:44Empperi,(reduce (every-pred true?) (map #(Character/isUpperCase %) "ASD"))
02:44justin_smithor do you mean snowman doesn't work in tryclj?
02:44clojurebottrue
02:44Empperi,(reduce (every-pred true?) (map #(Character/isUpperCase %) "aASD"))
02:44clojurebotfalse
02:44theme2justin_smith: "java.lang.RuntimeException: Unable to resolve symbol: isUpperCase in this context"
02:44Empperiok, got carried away
02:44jwwould Character/isUpperCase be valid in clojurescript?
02:45justin_smiththeme2: no
02:45Empperijw: no, it's java call
02:45justin_smitherr sorry
02:45justin_smithjw, no it would not
02:45jwok, yeah that's what I was thinking...
02:45justin_smiththeme2: what does you call look like? it should work
02:45theme2justin_smith: (Character/isUpperCase \b)
02:46theme2,(Character/isUpperCase \b)
02:46clojurebotfalse
02:46theme2-_-
02:46theme2wtf
02:46justin_smiththeme2: that exact call works in tryclj for me
02:46theme2wtf
02:46theme2refreshed and doesn't work
02:48EmpperiGive me some Clojure:
02:48Empperi> (Character/isUpperCase \b)
02:48Empperifalse
02:48theme2,(print "wtf")
02:48clojurebotwtf
02:48Empperistraight copy-paste from tryclj
02:49theme2by any chance, does tryclj use locally installed java?
02:49theme2> (Character/isUpperCase \b)
02:49theme2,(Character/isUpperCase \b)
02:49clojurebotfalse
02:50theme2*_*
02:50theme2orz
02:58theme2,(str (filter #(Character/isUpperCase %) "abc"))
02:58clojurebot"clojure.lang.LazySeq@1"
02:58theme2what is that?
02:59theme2nvm
03:02Empperi,(type (filter true? [true]))
03:02clojurebotclojure.lang.LazySeq
03:02Empperiit's that :)
03:05dagda1_how do I reference clojure 1.7 in my project.clj
03:05dagda1_or how can I use transducers is really my question
03:06Empperiadd clojure 1.7 as a dependency into your project.clj
03:06Empperi[org.clojure/clojure "1.7.0-alpha4"]
03:10justin_smiththeme2: try apply str
03:11justin_smith,(apply str (filter (Character/isUpperCase %) "aBcD"))
03:11clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0:0)>
03:11justin_smith,(apply str (filter #(Character/isUpperCase %) "aBcD"))
03:11clojurebot"BD"
03:21theme2,
03:21clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
03:21theme2,()
03:21clojurebot()
03:21theme2,(())
03:21clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IFn>
03:21theme2,((()))
03:21clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IFn>
03:21theme2O_o
03:22justin_smith() is unambiguous, so it does not need quoting
03:22theme2,()()
03:22clojurebot()
03:22theme2what?
03:22clojurebotwhat is not a bug
03:22theme2O_o
03:22justin_smith() is always an empty list
03:22theme2x?
03:22theme2wat?
03:22theme2what?
03:22clojurebotwhat is this
03:23theme2-_-
03:23theme2,'(1)()
03:23clojurebot(1)
03:23justin_smithlazybot, is it time for bed???
03:23lazybotjustin_smith: How could that be wrong?
03:23justin_smithseeya
04:11krat0sprakhar,(println "wassap people")
04:11clojurebotwassap people\n
04:29hellofunk,(apply str (interpose " " [(apply str (seq (concat "no" "thing"))) "much"]))
04:29clojurebot"nothing much"
04:39tsunnyhello clojurebot
04:40tsunny(+ 1 2)
04:40clojurebot3
04:41tsunny(println "Clojure Bot is Cool")
05:03theme2,(println "Clojure Bot is Cool")
05:03clojurebotClojure Bot is Cool\n
05:03theme2,(print "Clojure Bot is Cool")
05:03clojurebotClojure Bot is Cool
05:03theme2:)
05:21hellofunk(print "no comma")
05:21hellofunk(println "no comma")
05:21theme2,(print "no comma")
05:21theme2:)
05:21clojurebotno comma
05:21hellofunk(+ 1 3)
05:21clojurebot4
05:21hellofunkhuh. no comma there
05:22theme2(print "no comma")(1)
05:22theme2(print "no comma") 1
05:22theme2(print "no comma") '(1)
05:22theme2,(print "no comma") '(1)
05:22clojurebotno comma
05:22theme2-_-
05:22hellofunkweirdness
05:22theme2weird
05:22hellofunkjinx
05:23theme2,(print "Clojure bot is weird")
05:23clojurebotClojure bot is weird
05:23theme2,(println "I am weird")
05:23clojurebotI am weird\n
05:24theme2,(println "\\\\\\\\\\\\\\\\\\\")
05:24clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
05:24theme2,(println "\\\\\\\\\\\\\\\\\\\\")
05:24clojurebot\\\\\\\\\\\n
05:24theme2extra n :)
05:24theme2,(doc clojurebot)
05:24clojurebotTitim gan éirí ort.
05:24theme2lol
05:28hellofunkclojurebot: explain yourself!
05:28clojurebotexcusez-moi
05:28hellofunkclojurebot: i said, explain yourself!
05:28clojurebotIt's greek to me.
05:28hellofunkclojurebot: explain yourself!
05:28clojurebotTitim gan éirí ort.
05:28theme2,(recur)
05:28clojureboteval service is offline
05:28theme2whoops
05:29hellofunkyou broke the bot
05:29hellofunk,(println "we are sorry")
05:29clojurebotwe are sorry\n
05:29theme2,(fn [] (recur))()
05:29clojurebot#<sandbox$eval239$fn__240 sandbox$eval239$fn__240@2d0df534>
05:29theme2,((fn [] (recur)))
05:29clojureboteval service is offline
05:29theme2,(print "test")
05:29clojurebottest
05:29theme2,((fn [] (recur)))
05:29theme2,(print "test")
05:29theme2,(print "test")
05:29theme2,(print "test")
05:29theme2,(print "test")
05:29clojureboteval service is offline
05:29clojurebottest
05:29clojurebottest
05:29clojurebottest
05:29clojurebottest
05:30theme2lol
05:40m1dnight_Is there an idiomatic way to raise and handle events in clojure?
05:41m1dnight_Atm I have the idea of writing a function that says "(subscribe :event <fn>)" that will add this function to a list, and when :event happens, trigger all functions in that list
05:41m1dnight_but I think there is a better way
05:41brainproxym1dnight_: maybe something like https://github.com/clojurewerkz/meltdown
05:42brainproxythough, there might be something similar which is based on core.async, not sure
05:42m1dnight_hmm, something like that yes
05:47m1dnight_perhaps channels are an other way to go about it
05:48brainproxysure, you can build little loops and do all sorts of stuff even w/in a single thread
05:48brainproxyif you use the (go ...) and (go-loop ...) macros
05:49m1dnight_Well the architecture I'm building is a loop that receives messages and I want to subscribe multiple modules to it. Each module should look at each message that is produced by the loop and determine for itself it want sto do something with it or not
05:49m1dnight_So i'm thinking, each module will create a channel to the loop, and the loop will put each message on each channel it has available
05:49m1dnight_something like that might do the trick
05:49brainproxyhave you looked over core.async's API?
05:50m1dnight_I've got my cojure book by hand and on that now :)
05:50brainproxythere are facilities for pub/sub, etc.
05:50m1dnight_hrm, neither books I have contain chapters about core.async (or channels)
05:51brainproxyhttps://github.com/clojure/core.async
05:51brainproxyhttp://clojure.github.io/core.async/
05:52m1dnight_I think it might be interesting to go about it with core.async yes
05:53m1dnight_thanks for the links brainproxy !
05:53m1dnight_(inc brainproxy)
05:53lazybot⇒ 4
05:53luxbockm1dnight_: check out the core.async videos from the Clojure Conj
05:58m1dnight_cool :) Looking at a video by Timothy Baldridge
05:58m1dnight_thanks for the hints
05:58m1dnight_oh well, it's christmas!
05:58m1dnight_(inc luxbock)
05:58lazybot⇒ 2
06:06slipsetcore.async has pub/sub as well http://yobriefca.se/blog/2014/06/04/publish-and-subscribe-with-core-dot-asyncs-pub-and-sub/
06:28slipsetI've tried to implement a version of the sleeping barber problem (http://en.wikipedia.org/wiki/Sleeping_barber_problem) using core.async
06:29slipsetcode is here: https://gist.github.com/slipset/fb7d2a44303481731d89
06:29slipsetProblem is that the customer never gets to know if he has his hair cut or not.
06:30slipsetIs there any way to know for someone who put! on a dropping-buffer if the value was dropped or not?
06:35slipset /whois luxbox
06:38akkadmagic
06:40slipsetluxbock: re transducers, I think Rich Hickey mentions in either this years conj or strange-loop talk that the transducer impl lets the collections which knows how to step themselves handle the operation internally.
06:42slipsetluxbock: see bottom of this https://gist.github.com/runexec/06b56a9dbd15e43145b9
06:42luxbockslipset: thanks
07:03FrozenlockAnyone has a link to an example of Stuart Sierra's Component? I found this https://github.com/danielsz/system/tree/master/example/src/example, but there doesn't seem to be dependencies between the components.
07:06slipsetfrozenlock: could be something here http://www.uswitch.com/tech/more-open-source-clojure-systems-please/
07:08Frozenlockslipset: thanks!
07:21mi6x3mclojure what is the type for Java variadic args?
07:21mi6x3mX[] ?
07:21mi6x3mand how can I specify that in gen-class
07:33SagiCZ1it is an array yes
07:34mi6x3mSagiCZ1: but how do you use it with gen-class? through the [L notation?
07:35SagiCZ1mi6x3m: i am not sure, let's wait for someone else
07:35mi6x3mgood call :)
07:41KU0NHello. Given (let [h {:foo "bar" :foo2 "bar"}]) how can I call function f with each key/val as argument, like (f :foo "bar") (f :foo2 "bar") ?
07:42SagiCZ1use map
07:43SagiCZ1,(map identity {:foo "bar" :a 0})
07:43clojurebot([:foo "bar"] [:a 0])
07:43SagiCZ1if you call seq on hash map, it creates a sequence of key value pairs
07:43SagiCZ1map calls seq for you and applies given function on each element of that seq
07:43KU0NHoo, like hash.to_a in ruby. Ok.
07:43KU0NThanks.
07:44slipset(map (fn [[k v]] [(name k) (keyword v)]) h)
07:44slipset,(let [h {:foo "bar" :foo2 "bar"}] (map (fn [[k v]] [(name k) (keyword v)]) h))
07:44clojurebot(["foo" :bar] ["foo2" :bar])
07:45SagiCZ1thats not necessary slipset
07:45slipsetwhat's not necessary?
07:47hyPiRion,(let [h {:foo "bar" :foo2 "bar"}] (for [[k v] h] [(name k) (keyword v)]))
07:47clojurebot(["foo" :bar] ["foo2" :bar])
07:49slipset hyPiRion: cool, haven't used for much
07:49hyPiRionYou can also go bonkers like me and implement the util fn beside.
07:49hyPiRion,(defn beside [& fs] (fn [vs] (mapv #(%1 %2) fs vs)))
07:49clojurebot#'sandbox/beside
07:49hyPiRion,(map (beside name keyword) {:foo "bar" :foo2 "bar"})
07:49clojurebot(["foo" :bar] ["foo2" :bar])
07:50KU0NI've been doing clojure for 1 hour, my head is going to explode:P
07:50SagiCZ1KU0N: it sure is intimidating at first
07:50slipsethyPiRion: btw really liked your fizzbuzz implementation :)
07:51slipsethttps://www.refheap.com/92860
07:51hyPiRionslipset: haha, thanks
07:52hyPiRionQuicksort is also neat: https://www.refheap.com/284a0552a6b69c6037faa2db5
07:52KU0NMmh. (doto req #(map (.setRequestHeader %) headers) (headers being the key/val pairs) I know I'm doing something wrong.
07:53slipsethyPiRion: do you write this out manually, or do you have some secret clj-swj function?
07:53SagiCZ1KU0N: in interop you need to specify the object you are calling setRequestHeader on first.. and what parameters does the method have?
07:54KU0N.setRequestHeader name value
07:54slipsetKUON: also, I would guess that req.setRequestHeader takes a key and a value as param?
07:54thhellerKU0N: map is also lazy, so it won't execute since you don't consume the result
07:55slipset(map (fn [[k v]] (.setRequestHeader req k v)) header)
07:55KU0N(doto req (.setRequestHeader "Content-Type" "application/json")) this workds
07:55thheller(doseq [[key value] headers] (.setRequestHeader req key value))
07:55slipsetwould probably do the trick?
07:55slipsetor maybe even mapv, as map is lazy as thheller points out
07:56hyPiRionslipset: I'm doing it manually for now, but I go through the same steps every time. I guess it shouldn't be impossible to implement a clj->swj translator
07:56hyPiRionOnly thing I've done was automating number generation, but I don't know where that piece of code is
07:58thhellerdon't use map(v) if you don't need the result, building a collection you don't need is a waste of resources
07:58KU0NYeah I was looking to something like each
07:59thhellerthats what doseq is for basically
07:59KU0NYeah, it works. Thanks a lot.
07:59slipsetthheller: thanks
08:02mi6x3mcan I use a class generated through gen-class with import?
08:02mi6x3msomehow it's not getting found?
08:09mi6x3mI need hints as to how to compile a gen-class class only once :)
08:26slipsetcurious, the core.async docs say eg unique is deprecated, use transformer instead.
08:26slipsetshould that read "use transducer instead."?
08:26Bronsayeah
09:29slipsethmm, here's the answer to getting a message when a put! is dropped http://dev.clojure.org/jira/browse/ASYNC-55
09:30slipsetnot that I understood Ghadis answer though.
09:32bacon1989anyone know of a good resource on clojure destructors
09:32bacon1989like, a crap ton of examples
09:32slipsetJay Fields has a blog on it. Hang on...
09:33slipsethttp://blog.jayfields.com/2010/07/clojure-destructuring.html
09:33Bronsabacon1989: you mean destructuring, not like OOP destructors right?
09:33bacon1989oh yeah, destructuring
09:34bacon1989thank you, this should do nicely
09:34bacon1989I left my oreilly clojure book at home
09:54m1dnight_Is anyone here a beginner-isj clojure dev that would like to help me out with my clojure irc bot thing? Just for fun? I alwyas wanted to co-author something
09:54m1dnight_never really had the chance
09:54m1dnight_I dont work on it *that* much, just from time to time
09:55EmpperiI've already written on ircbot in clojure :P
09:55Empperione
09:55Empperijust for fun too
09:55m1dnight_Yeah, I know there are plenty of them out there but the goal of this tiny project is to build something that has very clean architecture
09:55m1dnight_some interaction would be nice
09:56m1dnight_did you write lazybot, Empperi ?
09:56Empperino
09:56Empperiit's my very own bot and no one else uses it
09:56m1dnight_github or something?
09:57Empperihttps://bitbucket.org/niklas_collin/masterbot
09:57Empperinothing too fancy or beautiful
09:58m1dnight_yay, dynamic loading. I want that too
09:58m1dnight_Atm I have a bot based on the PircBotX framework that used classloading for that purpose but it's not optimal yet
09:58m1dnight_And I want to replace it with a clojure implementation
09:59Empperim1dnight_: don't get too excited yet https://bitbucket.org/niklas_collin/masterbot/src/7070bbc8d0a26914fe8ad384b931234415905e5b/src/masterbot/core.clj?at=default#cl-10
09:59m1dnight_oh snap :p
09:59Empperishouldn't be too hard to implement
09:59Empperibut so far haven't needed it
10:00m1dnight_I havent found much when googling for hot swappable code though
10:00Empperianyway, all that is really needed to define a new command is that require
10:00m1dnight_Do you have an idea how to go about it?
10:00Empperisure, just evaluate all .clj files in certain directory
10:01Empperiand read them from there
10:01Empperihiiiighly insecure to do that way but works
10:01Empperi:)
10:01m1dnight_https://github.com/m1dnight/infogroep-bot/blob/master/be/christophedetroyer/Main.java#L192
10:01m1dnight_this is how I do it in java atm
10:01m1dnight_but I get your point
10:01m1dnight_might try it out
10:36slagyrAnyone datomic developers online?
10:37llasram~anyone
10:37Bronsaslagyr: there is a #datomic channel
10:37clojurebotanyone is anybody
10:37slagyrBronsa: I’m in #datomic too. It’s a bit slow.
10:38llasramslagyr: unless you're trying to get in touch with the developers of datomic, you're probably best off just asking your question
10:39slagyrRight. Will datomic behave well with a schema containing hundreds of thousands of attributes?
10:40slagyrI know it can support 2^20 attributes, but at what cost? Will it consume gobs of memory? Will queries slow to a crawl?
10:47dnolen_slagyr: probably better to ask your question on the Datomic ML
10:49slagyrdnolan_: ok thanks
11:03dagda1_why is korks often used as an argument name
11:07ivandagda1_: key or keys
11:07dagda1_ivan: now I know!
11:14visofi guys
11:14visofhi
11:14visofwhat is the best way to send anything to tcp with ip and port?
11:15llasramvisof: I usually use packets
11:16visofllasram: what is packets?
11:17llasramvisof: Sorry, just me failing to be funny
11:17llasramvisof: I'm actually just not sure what you're asking
11:18visofhow can you open tcp connection and send something to it?
11:18luxbockvisof: you could use Aleph: http://paulosuzart.github.io/blog/2012/07/09/tcp-server-with-clojure-aleph-and-gloss/
11:19visofi want to make tcp client
11:19llasramvisof: Just for fun, or to achieve some other goal?
11:19stuartsierravisof: java.net.Socket
11:19mfikesClojure Cookbook covers this topic: https://github.com/clojure-cookbook/clojure-cookbook/blob/master/05_network-io/5-09_tcp-client.asciidoc
11:22stuartsierraWatch out, folks!
11:22stuartsierrauser=> (.format (SimpleDateFormat. "yyyy-MM-dd") (Date.))
11:22stuartsierra"2014-12-30"
11:22stuartsierrauser=> (.format (SimpleDateFormat. "YYYY-MM-dd") (Date.))
11:22stuartsierra"2015-12-30"
11:22Bronsawoah wtf
11:22m1dnight_Right, I red about that bug
11:22m1dnight_read*
11:22stuartsierraI heard that broke Twitter a few days ago. :)
11:23m1dnight_I wonder where it stems from though
11:23m1dnight_can't find the url immediatly
11:23visofstuartsierra: what do you think about this https://github.com/gerritjvv/clj-tcp?
11:23stuartsierraIt's a legitimate use case: "YYYY" gives you the year for the current *week*
11:23visofstuartsierra: what do you think about this https://github.com/gerritjvv/clj-tcp ?
11:24Bronsaso it's not a bug
11:24Bronsajust weird behaviour, neat
11:24m1dnight_http://stackoverflow.com/questions/18228284/java-simpledateformat-bug
11:24m1dnight_seems to be a fairly old bug?
11:24m1dnight_oh, nvm "bug" then :p
11:24tcrayford____jodatime doesn't support "year for the current week" ;)
11:24tcrayford____afaik
11:25stuartsierraIt's not a bug in Java SimpleDateFormat, but it's a common bug in code which uses it.
11:25stuartsierravisof: I have no basis on which to form an opinion of that link.
11:25mfikesPerhaps it is a bug for code to ascribe meaning to YYYY-MM-dd, while it is legit to simply use YYYY in other contexts.
11:26tcrayford____stuartsierra: a usability bug if anything. APIs should help prevent their users from fucking up
11:30visofi'm in situation which need side-effects, i try to process something, and when i finish i update the status to done in redis, so i need to track status at redis from my clojure code if it done or not
11:30visofin imperative language i'm using while loop and check status and status value till status get done
11:31visofwhat is the best practice should do this in clojure or in functional language in general ?
11:31visofmy think is atom
11:31visofand use the same as in imperative language
11:31visofbut i'm asking about the best and elegant solution for this
11:32justin_smithvisof: if it only gets done once, use a promise
11:32justin_smithor a future or delay, if there is a single expression that is known to deliver the value
11:33justin_smithrealized? will tell you if it is don (ready for reading) or not
11:33visofyeah i got it
11:48EvanR-workidiomatic way, while doing a for or map, to "abort" or short-circuit end the computation, resulting in a nil or something
11:48EvanR-work?
11:48EvanR-workexceptions?
11:48clojurebothttp://paste.lisp.org/display/74305
11:48justin_smithEvanR-work: for and map are lazy
11:48justin_smithjust stop taking more values
11:50llasramEvanR-work: You can codify justin_smith's suggestion with `for` using a `:while` condition, and for any lazy sequence by wrapping in a `take-while`
11:50justin_smithif you care about the side effects from extra values accidentally produced, you should be using a doseq for the side effects, and using for or map only for the stateless part of the calculation
11:50EvanR-workno side effects
11:50justin_smithcool
11:51EvanR-workok trying to grok this... so in the event of an error produce nil. then later something will check for an occurrence and return nil instead of the sequence
11:51EvanR-workat the first nil
11:54tcrayford____yeah, you can just use (take-while #(not (nil? %)) stuff) there
11:54tcrayford____as long as your seqs don't get chunked
11:54m1dnight_I think what they mean is just map your function over the list. This produces a lazy sequence. And where you want to abort you make your function return something (e.g., nil). Then you can take the produced part of your map result by using take-while.
11:54EvanR-workdoesnt that give me the initial part
11:55EvanR-worki dont want any of it if an error occurs in the middle
11:55justin_smithEvanR-work: wait, OK, that's different
11:55justin_smithEvanR-work: would the exception be thrown in producing the sequence, or just a state you don't accept?
11:56m1dnight_doall, check with some nil, and then return nil or the sequence?
11:56EvanR-workproducing. doall? why?
11:56m1dnight_oh wait no, indeed that would be wrong
11:56m1dnight_nvm that
11:56justin_smithEvanR-work: doall is needed because you need to decide before exiting scope what you are returning
11:56EvanR-worki cant just search for the first nil?
11:57justin_smithm1dnight_: no, it is perfectly correct, the only way to decide between a sequence and nil is to realize the full sequence
11:57EvanR-workthe point is im trying to avoid computing the whole thing if an error occurs
11:57EvanR-work(which might be pointless since it will chunk like 30 items and i have probably less than that items per run)
11:58justin_smith(if (some nil? s) nil s)
11:58justin_smiththat's all you need
11:58justin_smithsome stops at the first nil
11:59EvanR-workyeah
11:59EvanR-workshould work, im luckily not using nil for anything else ;)
11:59m1dnight_ooh right because S would be lazy
12:00m1dnight_you could use :error or something as well, EvanR-work
12:00justin_smithmore generally you can have (try (test-every s) s (catch Exception e nil)) for exception oriented programming
12:00EvanR-workyeah i will need to use [:error "msg"] to explain the problem
12:00EvanR-workyeah exceptions
12:01justin_smiththat sounds like you just want an exception then
12:01justin_smithonce you get messages too, along with short circuiting
12:01EvanR-workive been avoiding them in clojure because it seems i have to define a new module to get a new exception class
12:01m1dnight_just use ExceptionInfo
12:01m1dnight_you can piggyback on it to add data and a message
12:01EvanR-worki refuse to to catch all exceptions (unless theres something i dont know)
12:01EvanR-workExceptionInfo?
12:02m1dnight_http://stackoverflow.com/a/16159584/1225786
12:02m1dnight_EvanR-work: ^
12:02EvanR-workcool
12:02m1dnight_Then you can even check if the exception is the type you want, if not, rethrow it
12:03EvanR-work... lovely..
12:03EvanR-workyeah so i have to do extra checking to differentiate between different uses of this exception
12:04m1dnight_I'm afraid so. I'm not sure if ExceptionInfo is used anywhere in clojure though.
12:05EvanR-workthis would definitely be a control flow mechanism locally using exceptions
12:05EvanR-workannoying
12:05EvanR-workExceptionInfo looks good for when i really want to throw an exception, right now ive been doing asserts
12:06llasramEvanR-work: What's your higher-level goal here?
12:06EvanR-workits a parser
12:07EvanR-worktake trees of strings as input
12:07EvanR-workits turning out that i dont seem to be catching the parse failures anywhere inside the parser, so maybe i dont need to do it in a pure way
12:08EvanR-worki was cautiously thinking that some part of it needs to decide to backtrack if an error happens
12:09llasramAre the things you are parsing not arriving in a fashion which makes it convenient to use an off-the-shelf parser like instaparse?
12:13EvanR-worklooks like it
12:20EvanR-work(after looking at instaparse, the text-based parser language reminds me of rubyisms, where if your language was based on data structures or s expressions you could more easily build these programs with program)
12:21EvanR-work(rather)
12:22EvanR-workin ruby languages usually take the form of a string or a big mutable object where phrases are spoken by using missing method invocations
12:24llasramEvanR-work: instaparse also provides a combinator interface
12:25llasramEvanR-work: The idea (as I understand it, not being the author) is that it provides the same convenience regular expressions provide for regular grammars, just for context-free grammars
12:26EvanR-workthats cool
12:27EvanR-workthe patterns describing the top layer of my data are actually regular expressions, just not on streams of letters but streams of trees
12:31EvanR-work,(:Doc ex-info)
12:31clojurebotnil
12:31EvanR-workwhats the cause argument?
12:31stuartsierraEvanR-work: `cause` is another exception you're wrapping.
12:32stuartsierraJust like the standard java.util.Exception constructors.
12:32Bronsa&(doc ex-info)
12:32lazybot⇒ "([msg map] [msg map cause]); Create an instance of ExceptionInfo, a RuntimeException subclass that carries a map of additional data."
12:32stuartsierraerr, java.lang
12:49mi6x3many experts on gen class around?
12:51TimMcBest to just ask your question.
12:52TEttingerbut probably, yes, mi6x3m
12:52mi6x3mI have am preparing a small sample for you guys
12:52TEttinger(identity Bronsa)
12:52lazybotBronsa has karma 82.
12:53mi6x3mbasically my extra constructor argument is being seen in the init function
12:53mi6x3mbut the state is null in an overriden method
12:54BronsaTEttinger I have actually used gen-class only once in my life :P
12:54TEttingerheh, lucky
12:54Bronsa(in great pain and agony)
12:55mi6x3myes
12:55mi6x3mit is great pain and agony
12:55mi6x3mbut I will be greatful for any hint :)
12:55TEttingerI've never used the state stuff
12:55BronsaI have -- https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/impl/ExceptionInfo.clj
13:00mi6x3mok everyone, here goes nothing: http://pastebin.com/VnY1huEX
13:00mi6x3min the -init method, everything is fine and the factory is != nil
13:00mi6x3min the overriden method however, it is nil
13:01mi6x3mit's probably something with the vector I return in init
13:03nooniani've no experience with gen-class, but why are your funciton names prefixed with '-'? it seems weird because in the gen-class form you reference them without the '-'s
13:03Bronsanoonian: no, that's the default prefix for gen-class
13:03noonianah cool
13:05charlespwdShould lein ring uberwar take 15 minutes+?
13:05kenrestivoon a 1ghz atom maybe
13:05mi6x3mcharlespwd: depends on your internet connection and the number of dependencies
13:06[blake|Hey, all: If I have a web app packaged as a WAR, how would I handle uploads? To wit, if this is the sort of thing where I'd normally put files in (say) an "/upload" directory off the root?
13:06charlespwdmi6x3m: thanks.
13:07[blake|charlespwd: Every now and again, mine takes an inordinate amount of time. I can't really explain it, since everything should already be downloaded.
13:07TEttingerdecoratorFactory and decorator-factory shouldn't be... it seems like those are different symbols
13:07BronsaTEttinger I don't think that matters at all
13:07mi6x3mTEttinger: please explain?
13:07mi6x3mthe one is a java class field, the other a clojure arg
13:07kenrestivo[blake|: i usually use s3 in those cases
13:08TEttingerI just thought it might be a typo, I don't know how state works here
13:08Bronsami6x3m: are you sure you don't have stale classes in your classpath?
13:08TEttingerlein clean to the rescue
13:08mi6x3mBronsa: what do you mean?
13:08[blake|kenrestivo: OK, I think my WAR is actually going to be on S3.
13:10mi6x3mBronsa: i have a file extract-native.dependencies in my stale folder in target
13:11mi6x3mperhaps it's a garbage collection issue?
13:12TEttingermi6x3m, stale as in from an older compilation of your program
13:13TEttingerbut not cleaned by lein clean or something that calls lein clean, so your program still sees old non-working class files
13:13mi6x3mTEttinger: I am sure, deleted the whole target directory
13:13TEttingerok
13:15mi6x3mBronsa: there is one thing which bothers me
13:16mi6x3mthe superclass takes a variadic argument list
13:16mi6x3mthat "options"
13:16mi6x3mmight be breaking things
13:16TimMcAs long as you treat that as an array of the appropriate type, that should be fine.
13:16Bronsami6x3m: I don't think so, you provide an array type, that's how varargs are compiled to
13:17mi6x3mthan I am sure out of theories :/
13:17Bronsami6x3m: I'm more concerned about the exposes-method thing, are you sure that's correct?
13:17mi6x3mBronsa: well the method is invoked by the Java code
13:18mi6x3mso it must be correctly overriden I think
13:18TimMcWhat is evidence that your state is non-nil in init and nil in the method?
13:19mi6x3mTimMc: println
13:24mi6x3mwhere can one see the code of gen class?
13:25TimMcThe source for clojure.core/gen-class?
13:26aperiodicmi6x3m: I'd try to reproduce the behavior you're seeing in a minimal example w/out other dependencies
13:26aperiodicalso gen-class is implemented here: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L7218
13:26aperiodicgood luck
13:27aperiodicoh, no, it's not
13:29aperiodicthis is the meat of it, sorry: https://github.com/clojure/clojure/blob/ae5e679111b3b72e2a8e3d2ebb1439ff0ca695a7/src/clj/clojure/genclass.clj#L124
13:29aperiodicit's only 382 lines long
13:30mi6x3mjesus christ
13:30mi6x3mlongest let i've seen so far
13:34aperiodicanyways, if you have a minimal reproduction it will be easier for others to help you debug, and you may figure out the problem in the course of constructing the minimal reproduction
13:34aperiodicit will probably be more productive than trying to understand the implementation
13:35aduaperiodic: good ol' min.rep.
13:38TimMc~sscce
13:38clojurebotAn SSCCE is a Short, Self-Contained, Correct Example <http://sscce.org/&gt;
13:38TimMcaperiodic: I bet that would be the case here (discovering the bug while making an sscce).
13:39TimMcaperiodic: Sometimes I ponder making a code bisector that keeps halving your code until the bug is discovered.
13:39mi6x3m-altrunning the .class file through a decompiler I get: decorator_factory = null;tmp52_36[1] = decorator_factory;return RT.vector(tmp52_36);
13:40mi6x3m-altwhich is quite disturbing
13:40Yxven1How difficult is it to learn clojure if you know java and haskell?
13:41mi6x3m-altYxven1: not hard
13:41aperiodicTimMc: how do you remove code without changing the behavior in a way that might obscure the bug?
13:41TimMcDunno.
13:41Yxven1It took around 4 months to get proficient at haskell with no previous haskell experience. Would I be looking at the same for clojure mi6x3m-alt?
13:42TimMcIt would be a neat trick for sure.
13:42mi6x3m-altYxven1: I'd say 2 months here
13:42mi6x3m-altit's a lisp with a lot of JVM mojo
13:42andyfI'd say the familiarity with immutable data you got from Haskell will get you a lot of the way there.
13:43aperiodicYxven1: java -> haskell seems like a much bigger paradigm shift than haskell -> clojure. you're already familiary w/immutability & laziness. probably mostly syntax and familiarity with the standard library and idioms that you're missing.
13:44Yxven1Would SICP teach me how to write clojure or is scheme very different?
13:45rgiarIMO, SICP is great for the lisp aspects of clojure
13:45mi6x3m-altYxven1: well, I'd take one of the clojure specific books and work my way through the first 200 pages, clojure is not tht difficult really
13:45AimHereSICP will teach you programming.
13:45andyfScheme emphasizes lists, whereas typical Clojure code uses vectors, maps, sets, and lists, perhaps even with lists being in the minority.
13:45rgiarthe tricky parts of thinking in terms of immutability aren't covered
13:45AimHereSICP only teaches the basics of scheme anyways
13:46rgiarbasics of scheme but the deep parts of lisp
13:46andyfSICP is a great book, no question, but it won't necessarily make the same kinds of data structure choices that Clojure code would.
13:46AimHerergiar, well SICP teaches immutability by default. It takes about 160 pages before any variable's value is reassigned, and they make a big deal about it
13:46Bronsa(inc andyf) ;; thanks for the help on tanal-108
13:46lazybot⇒ 20
13:46andyf(inc Bronsa)
13:46lazybot⇒ 83
13:46rgiarhmm, i didn't notice it at the time -- they do say very bad things about setcar/setcdr so i guess you're right
13:47andyfThanks for fixing it :)
13:48Yxven1I appreciate the advice guys
13:49AimHereAnyways, read SICP, even if you can't do the translation and have to do it in scheme!
13:51TimMcmi6x3m-alt: A reduced test-case I made does not exhibit the behavior you see.
13:52mi6x3m-altTimMc: can you paste it?
13:53llasrammi6x3m-alt: A bit late, but IMHO if you are unable to use reify or even proxy, it is far far simpler to just write a small Java class which can be parameterized with an IFn than to use gen-class
13:53llasramJava (<8) may not be a great programming language, but it's a pretty decent DSL for defining Java classes
13:53nullptrha!
13:53TimMc(inc llasram)
13:53lazybot⇒ 44
13:54mi6x3m-alt(inc llasram)
13:54lazybot⇒ 45
13:54mi6x3m-alt(inc llasram)
13:54lazybot⇒ 46
13:54crash_epGO BLOCKS
13:54mi6x3m-altI don't know how I wasted a whole day without considering the obvious way
13:54TimMcmi6x3m-alt: https://www.refheap.com/95599 I had to strip out some things that might be relevant because they got in my way.
13:54justin_smithcrash_ep: do they interest you, or are you rooting for your favorite lego themed team?
13:54TimMcSo it's stripped too far, I guess.
13:55mi6x3m-altTimMc: Object doesn't have a ctor with variadic args :)
13:55crash_epjustin_smith: heh
13:55mi6x3m-altanyhow, llasram is fully right, this is non-sense, java is for writing java classes
14:13clojerDoes Clojurescript eliminate the need for tools such as gulp/grunt and AMD/CommonJS?
14:15nooniandefinitely for AMD/CommonJS since all the modules are loaded and built into a single file at compile time
14:15noonianand uses google closure
14:15noonian's module system
14:16clojernoonian: I'm just findig the whole JS build tools maze exhausting :(
14:18mi6x3m-altllasram: do you happen to know, my saviour, how to compile java code with lein?
14:18noonianclojer: well, with cljs you'll be swapping the js build tools for clojure's build tools; most likely leiningen and lein-cljsbuild
14:18mi6x3m-altI guess I have to modify the task
14:18craigglennieIs it okay stylistically to have a “for” in a let block?
14:19SagiCZ1how to add an element at the beginning of a vector?
14:19SagiCZ1,(into [1] [2 3])
14:19TimMccraigglennie: Sure, why not?
14:19clojurebot[1 2 3]
14:19noonianmi6x3m-alt: i think you just need to add a :java-source-paths entry to your project.clj
14:19craigglennieTimMc: I couldn’t think of any reason why not, just wondered if it was idiomatic… it certainly works :)
14:19SagiCZ1(apply vector 1 [2 3])
14:19SagiCZ1, (apply vector 1 [2 3])
14:19clojurebot[1 2 3]
14:19mi6x3m-altnoonian: I did, no effect
14:19TimMccraigglennie: Especially since a :let clause at the beginnning of a for expr is buggy and doesn't work. :-P
14:19justin_smithSagiCZ1: I think into is pretty much your best bet there
14:19craigglennieTimMc: It is?
14:19SagiCZ1justin_smith: okay thanks
14:20TimMcLast I saw.
14:20coventryDoes anyone have a link to that talk where a leading scala developer flips out about the technical debt in the scala source code?
14:20TimMc,(for [:let [a 5], i (range a)] i)
14:20clojurebot#<IllegalStateException java.lang.IllegalStateException: Can't pop empty vector>
14:21nooniancoventry: I think paul phillips is the guy your thinking of; shouldn't be too hard to find it (i think he has a few of them)
14:21TimMc,(for [i (range 5), :let [a i]] a)
14:21clojurebot(0 1 2 3 4)
14:22TimMccraigglennie: So if you need to bind something for the entire scope of the for expression, that's really your only option. (And yes, it's idiomatic too.)
14:22coventrynoonian: Thanks.
14:22coventry
14:22noonianeither "Scala Collections: Why Not?" or "We're Doing it All Wrong"
14:22craigglennieTimMc: Cool, thanks
14:25coventryYes, "we're doing it all wrong" is the one.
14:26godd2&(into [] (cons 4 [1 2]))
14:26lazybot⇒ [4 1 2]
14:26godd2SagiCZ1 is that what you wanted?
14:26justin_smithgodd2: that's bad
14:27godd2justin_smith bad how? slow? unidiomatic?
14:27justin_smithgodd2: that turns the whole vector into a list, and then turns it back into a vector again
14:27justin_smithwhich is silly
14:27tbaldridgecoventry: pretty much every talk by that same guy these days is him flipping out
14:27justin_smith(into [4] [1 2]) does a lot less needless work
14:28godd2justin_smith yea but the into isn't prepending 4 into [1 2]
14:28mi6x3m-altOK following situation
14:28mi6x3m-altusing java_source_paths works for compiling the file
14:28mi6x3m-altbut the file is not being seen by lein run
14:28Bronsa,(into [4] [1 2])
14:28clojurebot[4 1 2]
14:28justin_smithgodd2: right, because you cannot prepend vectors period, but it is the best workaround
14:28Bronsagodd2: yes it is
14:28mi6x3m-altI get a classnotfoundexception
14:28godd2Bronsa no, it's iteratively appending the elements of [1 2] into [4]
14:29Bronsagodd2: and the difference is?
14:30godd2[4] is not the same as 4
14:30justin_smithgodd2: Bronsa: SagiCZ1: the right answer is to use the data structure that can be extended simply and naturally in the direction you need. If you only add on the front use a list, if you need to put things onto both ends use some sort of deque
14:30tbaldridgegodd2: the point is, that (into [] (cons x [1 2])) is worse than (into [x] [1 2])
14:31tbaldridgethe cons is completely useless
14:31godd2tbaldridge it's doing a prepend which is what was asked for
14:31gfredericks~the cons is completely useless
14:31clojurebotYou don't have to tell me twice.
14:31Bronsagodd2: I really don't see your point. (defn foo [x y] (into [x] y)) and you can write (foo 4 [1 2]). who cares how it's implemented? your version does two useless conversions
14:32tbaldridgegodd2: nope, he said "how to add an element at the beginning of a vector?"
14:32godd2Bronsa I didn't say I had a point, you claimed they weren't different.
14:32SagiCZ1justin_smith: my vector represents an actual geometric vector and i need to at one place once prepend one to it to increase its dimension.. i dont think i should choose a different data structure just because of that
14:32Bronsawhatever.
14:32godd2tbaldridge and an element is not the same as a vector containing that element
14:33llasram,(= (into [4] [1 2]) (into [] (cons 4 [1 2])) [4 1 2])
14:33clojurebottrue
14:33tbaldridgetrue enough
14:33llasramThanks, clojurebot
14:33godd2,(= 4 [4])
14:33clojurebotfalse
14:33godd2oh no!
14:34tbaldridgeso all things considered, SagiCZ1, I would recommend (apply vector x [1 2]) That's most likely going to be the fastest option
14:34llasram*plonk*
14:34SagiCZ1tbaldridge: really?
14:34tbaldridgeeverything else is going to create extra garbage
14:34Bronsatbaldridge: I would expect into [] to be faster than apply vector TBH
14:35tbaldridgeInteresting....
14:35justin_smithlein do clean, check, eastwood, test
14:35SagiCZ1apply vector is almost 3 times faster than into []
14:35justin_smithI think I need an alias
14:35Bronsauh, really?
14:35llasrammi6x3m-alt: Oh, hey, missed earlier q -- there's a builtin `javac` task
14:35SagiCZ1,(time (dotimes [_ 5000000] (doall (into [5] [1 2]))))
14:35tbaldridgeWell (into [x] (cons x [1 2])) is completely out, as that both converts to a seq and allocates a cons cell
14:36mi6x3m-altllasram: yeah, the class is generated but I get a ClassNotFoundException
14:36clojureboteval service is offline
14:36justin_smithSagiCZ1: how would a clojure vector be more suited for a mathematical vector than a deque would be? just because of the name?
14:36llasrammi6x3m-alt: When doing the compile or when trying to load the compiled class?
14:36mi6x3m-altllasram: loading
14:36tbaldridgeBut apply would also convert to a seq, so you may be right Bronsa
14:37SagiCZ1justin_smith: havent thought about that honestly, all i know is that when using clojure vector in incanters mathematical matrix operation, it automatically converts it into matrix object correctly
14:37mi6x3m-altllasram: found it, it was a "-" vs "_" issue
14:37llasramah, cool
14:37Bronsatbaldridge: it looks like apply vector is faster for small vectors, but into is faster for bigger ones
14:37devnHmmm, anyone know if anyone has ever discussed passing an assertion message in a :pre or :post condition? Right now it just calls (fn* [c] `(assert ~c))
14:37devnI'm looking at you tbaldridge. You think I could sneak that into core? :D
14:37justin_smithSagiCZ1: interesting, I would hope that it is using the interfaces and not coding explicitly against the Class, which would mean a deque would work just as nicely
14:37justin_smithSagiCZ1: but I don't know incanter so I can't say whether it does
14:38Bronsatbaldridge: not sure if any of this will change with the work for 1.7 though.
14:38SagiCZ1list works the same
14:38SagiCZ1idk what deque is or how to make one
14:39justin_smithif both vector and list work, deque will. https://github.com/pjstadig/deque-clojure
14:40SagiCZ1,(conj '(4 5) 1)
14:40clojurebot(1 4 5)
14:40justin_smitha deque is a sequence where insertion and removal from both start and end are efficient
14:40SagiCZ1cant i use list?
14:40justin_smithI think I mentioned, if you only insert at the beginning, use list, if you only insert at end, use vector, and if you use both use deque
14:40godd2SagiCZ1 if you only use list, you cant append efficiently
14:41SagiCZ1ok thank you all.. list is sufficient then
14:41gfredericksjustin_smith: "use deque"?
14:42godd2SagiCZ1 it may be a good idea to reverse the meaning of the elements in your list to "convert" it into a vector for design purposes
14:42aperiodicthough lists are terrible for caches so they can be slower even if they're less work to update
14:42aperiodicprofile, profile, profile
14:42SagiCZ1godd2: i am definitely not reversing anything.. debugging nightmare
14:42aperiodicand don't prematurely optimize
14:43justin_smithgfredericks: I meant, if you insert or remove at both ends, use a deque
14:43gfredericksjustin_smith: where would I find one though?
14:43[blake|deque-clojure?
14:44justin_smithgfredericks: see my link above to deque-clojure, I think that's a good one
14:44justin_smithaperiodic: vectors are just as bad for caches as lists in Clojure, and any array that is not a primitive array is nearly as bad, if not as bad as a list
14:44justin_smith(on the jvm)
14:45justin_smithaperiodic: the jvm isn't very good at the whole "contiguous linear arrangement of data" thing in general
14:46aperiodicah, yeah, chasing pointers is pretty unavoidable on the JVM, ain't it
14:47stuartsierraUntil we get Value Objects in Java 9 or 10.
14:48justin_smithor you could use some wacky ztellman lib, everyone will think you are crazy but your code will be more cache-line friendly
14:48[blake|Wow, that Scala talk is =scathing=.
14:49justin_smith[blake|: I had to stop watching because I don't like indulging in schadenfreude and was never a scala fan.
14:49godd2[blake| link?
14:49justin_smith(what I was referring to as a "wacky ztellman lib" above: https://github.com/ztellman/vertigo )
14:50[blake|justin_smith: Heh. I have no strong feelings about Scala. Well, I didn't. Now I'm thinking it's the '71 Pinto.
14:50andyfjustin_smith: I don't understand why you would say that vectors are just as bad as lists. Lists require 2 sequential pointer dereferences for each element, whereas vectors cut it down to about (1+1/32) on average, yes?
14:50[blake|godd2: https://www.youtube.com/watch?v=TS1lpKBMkgg
14:50dnolen_justin_smith: vectors would be a lot slower if what you said was true
14:51justin_smithandyf: but they can't hold primitives, so you still need to chase down the actual Object. So yeah, closer to an array, but still not linear.
14:51godd2[blake| thank you
14:51justin_smithdnolen_: OK, I should have been a bit more careful in my wording, yes
14:51tbaldridge<rant> I found it funny that half the issues mentioned in that scala talk exist due to static typing </rant>
14:52tbaldridgeor improper mapping of common collection operations to static types
14:52justin_smithtbaldridge: can you elaborate on the latter?
14:53[blake|tbaldridge: Heh. Check out the TypeScript spec some time.
14:54tbaldridgeNot much to elaborate on, except that I don't think Haskell suffers from these same collection issues (I could be wrong, I don't know Haskell).
14:54andyftbaldridge: seems like the other half are about issues with mutability
14:55tbaldridgeyeah, that too
14:55tbaldridgeWho on earth unifies a mutable and immutable API?
14:55stuartsierraAs I recall, a big part of the problem is trying to capture both mutable and immutable collections in a common type hierarchy.
14:55[blake|andyf: Yeah, I'm struggling to understand how you combine immutability with object hierarchies.
14:57tbaldridgeI just remember seeing the "this is how map is defined" and thinking that it was quite ugly compared to the F# version: http://msdn.microsoft.com/en-us/library/vstudio/bb548891(v=vs.100).aspx?cs-save-lang=1&amp;cs-lang=fsharp#code-snippet-1
14:58romain_dnolen_: saw your message on twitter about clojurescript low-hanging fruit. Would you be willing to coach a newcomer on working on a CLJS issue, e.g. CLJS-931?
15:02dnolen_romain_: sure thing, that is fairly straightforward ticket. We just to need to extend the first comment line to include build options
15:03dnolen_romain_: so something like // Compiled by ClojureScript 0.0-2511 : #{:static-fns, :elide-asserts}
15:04dnolen_romain_: currently only emitting // Compiled by ClojureScript 0.0-2511
15:04romain_dnolen_: OK, actually I tried doing this on a second line
15:04dnolen_romain_: lets just keep it on the same line, then we need to helpers in cljs.util for extract this EDN set
15:04romain_The thing is, I don't know how to test my patch, I am a bit at a loss with the scripts dir.
15:05dnolen_romain_: there's a test directory with compiler and analyzer tests
15:05dnolen_romain_: you could make a test .cljs file, compile it, change the settings, compile it again and the modified time should be different
15:05dnolen_romain_: one test should not change the setting and the modified time should be the same
15:06dnolen_romain_: you can run all tests with `lein test`
15:06romain_dnolen_: also, should it output all build options or just the ones that may affect compilation results?
15:07dnolen_romain_: only the ones that affect, they are listed on the ticket, there's only 3 for now
15:07romain_dnolen_: OK, will try; then submit on JIRA?
15:08dnolen_romain_: yes attach a patch to JIRA, make sure to send in your CA
15:08dnolen_romain_: http://clojure.org/contributing
15:08romain_dnolen_: great
15:16[blake|Any pointers for deploying a Clojure WAR to Amazon? Blog post, book, video, whatever?
15:17justin_smith[blake|: by the time it's a war, it's just drop-in, identical to deploying a java war
15:17justin_smithit's really not even complicated enough to need a book or video
15:17justin_smithyou tell amazon to deploy your war, and if it's properly packaged, it just works
15:18[blake|justin_smith: Yeah, I figured. I'll go that route.
15:20justin_smith[blake|: that's a big part of why elasticbeanstalk is expensive, once you have a working war, it's pretty simple
15:23stuartsierraElastic Beanstalk only costs what the underlying compute/storage resources cost.
15:35justin_smithstuartsierra: oh? I had a lead claim he was switching from beanstalk to ec2 for a cost savings, but maybe there was another factor being left out
15:36stuartsierrahttp://aws.amazon.com/elasticbeanstalk/pricing/
15:36stuartsierraNot sure if that was always true.
15:36justin_smithoh wow, 100% identical
15:37justin_smithso either my lead was misinformed or this is new, clearly, thanks for the correction!
15:37llasramI believe you do end up paying for ELB, even for tiny/prototype applications where you don't need it
15:37stuartsierrajustin_smith: I vaguely recall that there was a small add-on charge for Elastic Beanstalk at some point in the past.
15:40joobusi recall beanstalk being more expensive than ec2 last time i looked into it also.
15:40[blake|I was also under that impression.
15:41justin_smithit's cool to find out it has ec2 pricing now
15:43romain_dnolen_: if I invoke "./scripts/repl" I should be able to (cljs.compiler/compile-file f) right? Right now I just get a NPE from "deref-future"...
15:47dnolen_romain_: yes because you need to establish a compiler environment
15:48visofhi guys
15:48visofis there anybody using aleph?
15:48ticking_visof: yeah
15:49visofhow can i send data to tcp connection?
15:49visof(aleph.http/tcp-client {:host "example.com", :port 10001})
15:49visofticking_: how can i send data to this connection
15:49romain_dnolen_: ah OK, thanks
15:50dnolen_romain_: look at the analyzer tests for examples
15:51ticking_visof: from the other side of a tcp connection
15:51ticking_visof: it'sbeen a while since I wrote the cod eusing aleph let me check a sec
15:51visofticking_: i'm waiting thanks
15:51TimMcnetcat? :-)
15:52ticking_visof: aleph does not work on its own you also need lamina which handels the channel manipulation
15:52atratus@dnolen im trying to setup node repl on windows, self-compile fails, unable to find main class clojure.main
15:52atratustried repl.bat too, same
15:52ticking_aleph is build on top of lamina which provides channels, and provides different network connections on top of that
15:53ticking_visof: you want lamina.core/enqueue
15:54visofticking_: i guess doing this using java.io.Socket is more simpler
15:54visofticking_: have you tried using java.io.Socket?
15:55ticking_visof: not nessecarily
15:56ticking_visof: yeah, but aleph really shines when using it together with gloss
15:56visofticking_: i just want to send data to socket even without waiting to recieve it
15:57visofso future + sending to socket are going to be fast enough
15:57ticking_ztellmans binary parsing dsl
15:57ticking_makes manipulating bytestreams as pleasant as in erlang
15:57ticking_visof: gloss can encode and decode
15:57ticking_visof: its not about speed but remaining sane when dealing with complex byte formats
15:57ticking_which a tcp connection almost always requires
15:57visof.getbytes is enough?
15:58ticking_hm?
15:58llasramvisof: This is just a for-fun project, messing around with sending data over TCP, yes?
15:58visofllasram: what do you mean?
15:58llasramOh, nm, you brought up aleph
15:58llasramI was trying to better-understand what you're trying to do
15:58visofclojure docs is down
15:59visofis there another way to check clojure docs
15:59visofi want to read about reader/writer
15:59llasramIf you're trying to learn how to do lower-level network programming (at least so far as the JVM allows), then aleph is not going to be helpful :-)
15:59visofwhy always clojuredocs is down
15:59andyfvisof: Try conj.io
16:00andyfbut clojuredocs.org is up
16:00romain_dnolen_: so something like (e/with-compiler-env (e/default-compiler-env) (c/compile-file "hello.cljs"))
16:01dnolen_romain_: yep
16:02visofandyf: https://clojuredocs.org/clojure.java.io/reader
16:02andyfvisof: That link works fine for me. You aren't getting anything?
16:03visofyeah
16:03visofandyf: what browser you are using?
16:03visofandyf: i got this http://sprunge.us/XBAG
16:04andyffirefox. Also tried Safari with no trouble.
16:04visofchrome complain
16:04visofguys can any chrome users test this?
16:04llasramworks fine for me
16:04tephrafine for me
16:04visofgod so what is the problem
16:04andyfweb proxy between you and there, maybe?
16:05visofandyf: every website works for me fine
16:05atratusError code: ERR_SSL_VERSION_OR_CIPHER_MISMATCH
16:06tephravisof: are you on XP?
16:06andyfperhaps Chrome is more strict in what versions of SSL it allows, to avoid a bug in an older SSL version?
16:08visoftephra: i'm using fedora
16:08visofandyf: maybe
16:08visofi'll try in firefox
16:08tephravisof: hmm me to, chrome 40.0
16:08andyffreshly installed Google Chrome on Mac OS X 10.9.5 works for that clojuredocs.org location
16:09visoffirefox complain with this http://sprunge.us/LUIS
16:10andyfwhat country are you in? :)
16:10visofandyf: Egypt
16:10andyfblocking/intercepting SSL?
16:10visofandyf: i don't know
16:12andyfvisof: Maybe some help here: http://forums.mozillazine.org/viewtopic.php?f=38&amp;t=2301041
16:13andyfI don't have detailed knowledge here -- just did a search on a keyword in the error message.
16:14EvanR-workis there an idiomatic "either" data type
16:14EvanR-work[:left 3] [:right 3]
16:14amalloyEvanR-work: not really
16:14ticking_weird when I use the chestnut browser repl to manually transact! on an om cursor, the render loop assertion "Cannot manipulate cursor outside of render phase" will fail, yet the transaction will succeed
16:19dnolen_ticking_: that stuff is gone from 0.8.0-betas
16:19dnolen_the checks
16:19ticking_dnolen_: ah thanks :)
16:20llasramEvanR-work: Using a vector like that is the closest you get. There was even a talk at the Conj this year advocating it :-)
16:20EvanR-workheh
16:20EvanR-worki decided against it
16:20llasramEvanR-work: Well, in case you change your mind https://www.youtube.com/watch?v=ZQkIWWTygio
16:21EvanR-worki did {:left foo} {:right bar} instead, so you cant accidentally ignore the tag
16:22ticking_dnolen_: btw, something I never quite got, literals passed to om/root will also be wrapped into a cursor right?
16:22dnolen_ticking_: no
16:23ticking_dnolen_: really? hm weird transact! seems to work even though I passed in a literal
16:23augustlthe function > seems to want to convert things to numbers, it doesn't use comparable. How do I compare two comparables in clojure?
16:23augustlI happen to be using Joda DateTime instances
16:24MosterdWhich ide to use if you are a vim refugee who doesn't understand emacs? Is there a nice editor such as Spyder or python-notebook which I both like to recommend to python users who don't understand vim?
16:24hyPiRionhrm, compare?
16:24hyPiRion,(compare [1 2] [1 3])
16:24clojurebot-1
16:24romain_dnolen_: the build options are passed as 'opts' to compile-file right? Or should I also look at the compiler environment...?
16:25llasram,(compare [1 2] [3])
16:25clojurebot1
16:25atratus_mosterd: light table integrates ipython pretty well
16:25atratus_dead simple
16:25llasramI do think at times that `compare<`, `compare>` etc would be nice
16:26dnolen_romain_: opts is the right thing
16:26augustlllasram: yeah that would have been nice :)
16:26scottjMosterd: cursive for intellij or gorilla repl maybe
16:26Mosterdatratus_, wait that's even written in clojure, that might be great
16:26hyPiRionllasram: me too, esp. when working with max-key and min-key
16:26kenrestivoso just confirming, async/go-loop will spin of a jvm thread on a jvm, correct?
16:26romain_dnolen_: great, so I have a patch but no tests yet. Any ideas or where to put those? And how to design them?
16:27stuartsierraMosterd: perhaps one of Cursive (IntelliJ), Nightcode, Light Table
16:27atratus_mosterd: clojurescript but yeah it handles clojure ootb
16:28atratus_it handles ipython just as it does the clojure 'instarepl', with inline graphs and all that
16:28llasramhyPiRion, augustl: Sounds like a job for a new tiny library!
16:29andyfaugustl: (< (compare a b) 0) instead of (< a b), for example. Use <=, >= , or > instead of < as desired.
16:29MosterdIt's a desktop program written in javascript?
16:29atratus_yep
16:30hyPiRionllasram: I'll delegate that work to you
16:30MosterdHmm, I must have lived under a rock for a while
16:30augustlas if date comparisons wasn't hard enough to read as it is :)
16:30hyPiRionAlthough to be fair, it seems to be very little work for rather nice functionality (when you need it).
16:31atratus_it uses node webkit & codemirror
16:31ticking_dnolen_: yeah they do :P (if (satisfies? IAtom value) value (atom value))
16:31atratus_scripted with cljs
16:32llasram,(let [comparize #(%1 (compare %2 %3) 0)] (map (partial comparize < [1 2]) [[1] [1 2] [1 2 3]]))
16:32clojurebot(false false true)
16:32dnolen_ticking_: that's root, values are not wrapped in cursorss
16:32dnolen_ticking_: yes we always wrap the root, but components can take regular values
16:32ticking_dnolen_: ah sorry miscommunication then
16:32dnolen_they don't need to be cursors
16:33ticking_dnolen_: what I meant was when they get wrapped into an atom anyways and thus turned into a cursor, why have atoms in the first place? Changes to the atom won't be send to tx-listen and cause global rerendering which means one should never manipulate the atom anyways
16:33dnolen_romain_: put them in tests - make a test dummy .cljs file you check in that the tests run against, the tests can write to a temp directory and check last modified
16:34dnolen_ticking_: there are reason to change the atom directly that don't have anything to do w/ components - history stuff etc.
16:35ticking_dnolen_: why not expose the cursor directly (def app-state (cursor foo)) this way it is accessible for transact! calls without having to pull it out of a component call
16:35justin_smithMosterd: vim refugee? if you want to still use vim, why not fireplace?
16:36dnolen_ticking_: because cursors aren't atoms - I continue to be skeptical
16:36dnolen_ticking_: anyways I would use Om on something non-trivial before thinking too much about how to do it differently
16:37dnolen_"skeptical that they should act and look like atoms, they hold atoms"
16:37ticking_dnolen_: I was just wondering for the reason, because I found myself never accessing the atom directly because it is so incompatible with many om features
16:38dnolen_ticking_: changing the app state globally
16:38ticking_dnolen_: it should fire a global tx-listen then though :D
16:39dnolen_ticking_: there's problems with :tx-listen, likely it will work differently in the future
16:39mi6x3m-altllasram: everything works perfectly, thanks for showing me the one true path =)
16:40llasrammi6x3m-alt: np! I keep meaning to write a blog post about it...
16:40llasramSo much time, so little to do
16:40mi6x3m-altwell it's so simple it's remarkable
16:40mi6x3m-altnever use gen-class :D
16:40llasramheh
16:40mi6x3m-altwhen you need a java class
16:40mi6x3m-altit will end up in one of these ancient chinese booklets of wisdom, I tell you
16:41mi6x3m-alt"best DSL for java code is java"
16:41llasramI did a short talk for the Atlanta Clojure meetup which included pretty much that -- bullet points of: "reify: when you need this", "proxy: when you need that", "gen-class: NEVAR"
16:41xemdetiawas that the whole talk?
16:41Mosterdjustin_smith, perhaps, but I don't know. For some reason I prefer the repl to be in a different window.
16:42xemdetiathen copious applause?
16:42gfredericksllasram: what about for a simple -main? use java instead?
16:42gfredericksor some plugin that does that
16:42mi6x3m-altwell gfredericks -main is really the only exception
16:42mi6x3m-altwhere this madness actually makes sense
16:42gfredericksoh so NEVAR-except
16:43llasramgfredericks: that might be the exception, but I've found it very rare that I can make do with just an executable JAR that I don't even use it for that myself
16:43mi6x3m-altwell my math prof. defined infinity as "all cases except for finitely many"
16:43ticking_dnolen_: I'm intrigued, yet a bit scared as a lot of code I just wrote depends on tx-listen ;)
16:43mi6x3m-altthis includes the exceptions
16:43llasrammi6x3m-alt: nice
16:43borkdudein clojure when I use a library that exposes a BufferedImage, do I need to import this class to be able to work with it?
16:43gfredericksmi6x3m-alt: I think that's "almost all"
16:44dnolen_ticking_: any changes will be delayed until till 0.9.0 and there will be some sort of upgrade path
16:44clojurebotexcusez-moi
16:44Mosterdjustin_smith, I have used tmux before but then I still miss features such as better autocompletion and identation and such, so that's why I'm looking at different editors
16:44mi6x3m-altgfredericks: well now, I do think we both understand what llasram is saying ;)
16:45llasramxemdetia: Well, there was a bit more :-) -- I actually still have the slides up http://static.platypope.org/interop/#/
16:45bacon1989tmux is an editor now?
16:46gfredericksmi6x3m-alt: yes but I'm physically incapable of not being pendantic about infinity
16:46bacon1989man, it's gotten featureful
16:46llasramOops meant http://static.platypope.org/interop/#/17 in particular
16:46mi6x3m-altgfredericks: professional condition? :)
16:47xemdetiathat is a very pretty slide deck
16:47llasramxemdetia: It's just a default theme of <digging for link> I can take 0 credit
16:48Mosterdbacon1989, nope, but there is a vim plugin that can send code that has been selected in vim to tmux which works if you manually started a lein repl in that tmux session
16:49llasramxemdetia: Ah, Reveal.js: http://lab.hakim.se/reveal-js/#/
16:49xemdetiav. cool regardless :)
16:51borkdudeI get an exception Unable to resolve classname: BufferedImage, compiling:(recipes/controllers.clj:14:41) on this line: resized (imagez/resize img (min (.getWidth img) 1024)), imagez is the core namespace from this library https://github.com/mikera/imagez/blob/develop/src/main/clojure/mikera/image/core.clj
16:51borkdudeadding (:import [java.awt.image.BufferedImage]) to my ns decl doesn't help
16:52borkdudebrb
16:52devnAsked this earlier, but I'd be curious to know if anyone knows anything before I look into it any further
16:52devnhas anyone discussed passing an assertion message in a :pre or :post condition? Right now it just calls (fn* [c] `(assert ~c))
16:53devnborkdude: that sounds familiar actually
16:56tephravisof: did you resolve the issue?
16:56stuartsierradevn: I know it's been discussed somewhere, maybe on a mailing list.
16:56devnstuartsierra: any idea whether it's out of the question, or if it's worth making a patch for it?
16:56stuartsierradevn: I don't know.
16:57justin_smithdevn: I would use :pre much more if it allowed custom messages
16:57devnstuartsierra: fair enough. thanks for the reply either way. i'll try and hunt it down.
16:57EvanR-workllasram: well that was refreshing and convinced me to go with my original idea, and somehow to ignore my original worry that someone will just do let [[_ x] foo] and bypass the safety
16:58EvanR-work(mainly me)
17:01andyfdevn: Maybe this discussion: https://groups.google.com/forum/#!searchin/clojure-dev/precondition/clojure-dev/i7pijgFaa0I/MPVOCgeRO4YJ
17:02SagiCZ1hi, i need to achieve something like this
17:02SagiCZ1,(let [data [:a :b :c]] (for [e data] [e (remove #{e} data)]))
17:02SagiCZ1but... not using set
17:02clojurebot([:a (:b :c)] [:b (:a :c)] [:c (:a :b)])
17:03EvanR-workapply dissoc?
17:03SagiCZ1EvanR-work: i would rather just use the index
17:03SagiCZ1because set operations need to compare the things but the elements could be very expensive to compare
17:04devnandyf: ah, yes
17:04devnthat's better than what i found. thank you!
17:04andyfTh-inc nothing of it :)
17:05devnseems like this has been brought up on several occasions
17:05devnall of the right people were on these ML discussions
17:05devnjust looks like nothing ever happened with it
17:07devnhttps://groups.google.com/forum/#!msg/clojure-dev/eNK9UZ5HklI/BDa6CDHenWkJ
17:07andyfPreconditions are easy to replace with assert's and custom messages on your own. Postconditions not so much.
17:07devn*nod*, which I've done
17:07devnbut it felt kind of odd to me
17:07devnim *not* complaining about error messages, to be clear :D
17:08devnit would be nice to give myself a nice message in pre/post though
17:08andyfA modification of Shantanu's approach looks straightforward to achieve that?
17:08devnthey feel like a natural place for it, but maybe im overloading them
17:09devnagreed, but it also doesn't seem like it'd be that much trouble to work it into fn
17:09devni may be underestimating the work involved, but... it looks like a fair number of people have been interested in this
17:09borkdudedevn I'm back
17:10devnborkdude: i spoke too soon, im not remembering what it was, but did you try (:import (java.awt.image BufferedImage))?
17:10andyfBackwards compatibility would be important, I assume. Agreed that coding up a change shouldn't be a lot of work. Go for a ticket, if you feel so moved.
17:11devnandyf: yeah of course
17:11devnit's smack dab in the middle of fn
17:11borkdudedevn that was it... syntax
17:12borkdudebut still I don't get why I need this import
17:15borkdudeanyway, thanks :)
17:18devnyw
17:22ticking_SagiCZ1: not pretty but it's what you described plus indexes
17:22ticking_,(let [data [:a :b :c] indexed-data (map vector data (range))] (for [[e i] indexed-data] [e (map first (remove (comp #{i} second) indexed-data))]))
17:22clojurebot([:a (:b :c)] [:b (:a :c)] [:c (:a :b)])
17:23ticking_vectors don't have efficient dissoc afaik so this is a lot harder
17:23SagiCZ1i did this in the end
17:23SagiCZ1(let [data [:a :b :c]]
17:23SagiCZ1 (for [[e i] (map list data (range (count data)))]
17:23SagiCZ1 [e (remove-elem data i)]))
17:24SagiCZ1where remove-elem removes the element at index i in vector data
17:24justin_smithticking_: there is no dissoc for vectors
17:24gagangowda10I am really new to clojure
17:24amalloySagiCZ1: that sounds pretty expensive. you are iterating over the list a lot of times
17:25SagiCZ1amalloy: over the data list? how so?
17:25gagangowda10in fact I was going through the website and found this line
17:25gagangowda10reactive Agent system that ensure clean, correct, multithreaded designs
17:25ticking_justin_smith: yeah, pitty, but I suppose the trie thing doesn't really lend itself to it
17:25amalloyi mean, remove-elem walks over the entire list of N elements, and you call it N times
17:25justin_smithticking_: finger-trees do it nicely though
17:25gagangowda10I understand the concept of reactive agents, but how is it implemented in clojure, any insight about this?
17:26SagiCZ1amalloy: remove-elem concatenates two subvectors .. before and after the remove element
17:26gagangowda10like conceptual information on how clojure uses this
17:26justin_smithSagiCZ1: this is something that exists?
17:26SagiCZ1no
17:26SagiCZ1its something that.. hellofunk wrote for me the other day i think
17:27SagiCZ1(fn [v i] (vec (concat (subvec v 0 i) (subvec v (inc i)))))
17:28gagangowda10nvm got it
17:28justin_smithyeah, that walks the whole vector - a finger tree would handle that much better
17:28justin_smithgagangowda10: what was the answer?
17:29justin_smith"Clojure's Agents are reactive, not autonomous - there is no imperative message loop and no blocking receive. The state of an Agent should be itself immutable (preferably an instance of one of Clojure's persistent collections), and the state of an Agent is always immediately available for reading by any thread (using the deref function or reader macro @) without any messages, i.e. observation does not require cooperation or coordination."
17:29justin_smithhttp://clojure.org/agents
17:29SagiCZ1never heard of finger tree.. anyways.. although clojure is very data oriented.. i feel like its very hard to manipulate data in it in some ways i needed lately.. so strange
17:30justin_smithSagiCZ1: the function specified above works, it's just that as amalloy notes it is doing more work than would be optimal.
17:31SagiCZ1i understand that and i am not going to optimize it, because it works on a very small number of elements.. (dozens at most)
17:31SagiCZ1maybe the feeling i have is because i naturally started to avoid manipulating indexes, but sometimes it feels like there is no other way.. for example the thing i needed couple minutes ago
17:33ticking_SagiCZ1: whats the data that you have so little of it, yet a comparison operation is too expensive, if I may ask :)?
17:34SagiCZ1ticking_: clusters of points.. so i have lets say five clusters.. each with hundreds of thousands points
17:35ticking_SagiCZ1: ah yeah point clouds suck
17:36arohnerI remember someone proposing adding :let [foo bar] to the inside of a cond clause a while back. Did that macro ever get written in a public place?
17:37jcromartieerror in process sentinel: Could not start nREPL server: /bin/bash: lein: command not found
17:37jcromartiebut it definitely should be found
17:37arohneraha: http://clj-me.cgrand.net/2011/06/17/a-flatter-cond/
17:38ticking_jcromartie: needs more input
17:38jcromartieI just updated to Yosemite, and cider-jack-in fails with that error
17:38jcromartieI've set my exec-path
17:38ticking_jcromartie: have you tried reinstalling leiningen?
17:38jcromartieto include /usr/local/bin, where lein lives
17:39jcromartieI can run lein from the terminal
17:39jcromartieno problem
17:39ticking_brew install lein
17:39arohnerjcromartie: are you starting Emacs from the dock?
17:39nullptryeah, your PATH is probably messed up -- they change the way that works every release, seemingly
17:39nullptrit's infuriating
17:40arohnerjcromartie: Emac's path is goofy, because the OSX 'window manager' doesn't use .bashrc, .profile, etc stuff
17:40nullptri've given up and start Emacs exclusively from terminal now
17:40jcromartieyeah, I understand that
17:40ticking_reinstalling command line utils after os x upgrades can also sometimes do the trick
17:40jcromartiebut I've explicitly put /usr/local/bin on the Emacs PATH and exec-path
17:40jcromartiebut yeah
17:41jcromartieprobably some weird OSXism
17:41jcromartieyeah
17:41jcromartieI'm reainstalling homebrew right now to start with
17:41jcromartie(somewhat unrelated... BTW I had not removed /usr/local/bin before trying cider-jack-in)
17:47justin_smithjcromartie: how have you explicitly put those in the Emacs PATH?
17:48jcromartie(add-to-list 'exec-path "/usr/local/bin")
17:48jcromartie(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))
17:49jcromartiederp
17:49jcromartiejust added that ":" to the (setenv "PATH" ...) and that was it
17:49justin_smiththat fixed it?
17:49jcromartieit wasn't there before
17:49jcromartieyeah
17:49justin_smithhah, there you go
17:50jcromartieI hadn't used (setenv "PATH" ...) at all before Yosemite
17:50justin_smithI had never heard of this "exec-path" var, I always used setenv
17:50jcromartiebut yeah
17:51jcromartieevery time OS X is updated, the PATH setting method changes :P
17:51justin_smithahh, exec-path is just for subprocesses, I don't know if cider uses the proper "subprocess" infrastructure or not...
17:51nullptri don't believe so -- setting exec-path has not been sufficient in the past
17:52justin_smithyet another weird thing about cider I guess
17:53[blake|I've got this uuencoded PNG passed back from the front end of my app and I'd like to save it as a PNG on the server. I was trying to use clojure.data.code.base64, but it wants a byte-array.
17:56nullptr(inc jcromartie)
17:56lazybot⇒ 8
17:56justin_smith[blake|: and you have what, a string?
17:56justin_smith,(.getBytes "hello")
17:56clojurebot#<byte[] [B@20b2d772>
17:56amalloyuuencoded? i didn't know uuencode was still much used
17:56[blake|justin_smith: Yeah. I can map it to a byte array but...I'm concerned I'm doing something fundamentally wrong.
17:57[blake|amalloy: HTML5's canvas.toDataURL() returns a base64 uuencoded PNG. (I think.)
17:57justin_smith[blake|: .getBytes is O(1) afaik, it is a data cast not a transform iirc
17:57EvanR-worki usually use md5 for encoding
17:57FrozenlockInteresting... I wasn't aware there were plans to 'replace' cljx https://groups.google.com/forum/#!topic/clojure-dev/6pnIeXFRwnI
17:57justin_smith[blake|: that is not the same as uuencoding
17:57amalloy[blake|: base64 uuencoded sounds bizarre
17:57amalloyit's like an english spanish sentence
17:57justin_smithyeah, I suspect it is just base64
17:58amalloyjustin_smith: i would be quite surprised if getBytes were O(1)
17:58justin_smithoh? doesn't it just return the underlying bytes of the string?
17:59amalloyno. even if you call it with the same character encoding as the string actually uses internally, it copies
17:59[blake|OK, so there's the first problem. I added UUEncode. =P
17:59justin_smithaha
17:59amalloybecause strings are immutable
17:59amalloyand you can't just hand out pointers to their internals like candy
17:59justin_smithright, and it returns something mutable, of course
17:59stuartsierraAnd Java Strings are UTF-16.
18:00justin_smiththe world of mutability is so strange to me when I get lost in clojure land...
18:00stuartsierraish
18:00amalloyand anyway strings actually store a char[], not a byte[]
18:00justin_smithright
18:00amalloy[blake|: yeah, step 1 is to not involve uuencode at all
18:01justin_smith[blake|: you may be able to circumvent your handler and get the bytes from the incoming data directly, but there is always .getBytes as a fallback I guess
18:01[blake|amalloy: OK, since I was using clojure.data.codec.base64, I probably didn't actually put any UUEncode in my code.
18:02[blake|I could write out the file as a text and use base64...but that seems cheesy. Might not work on Amazon, either, come to think of it.
18:06justin_smiththere is no reason to write it to disk before generating the png
18:07[blake|justin_smith: It's not my preference.
18:10justin_smithwhatever drawbacks there are to .getBytes on a String (rather than using the bytes you just got over the network), putting the string in a file in order to get the bytes is worse
18:11[blake|I assume I'll be able to work it out without doing that.
18:12amalloyit's kinda lame that data.codec requires a byte[]
18:12jcromartie[blake| decoding-transfer
18:12jcromartieclojure.data.codec.base64/decoding-transfer
18:13amalloyjcromartie: he doesn't have streams either
18:13jcromartieoh
18:13jcromartieit's a request param?
18:13[blake|Yeah. It's coming back from the client side.
18:13justin_smithyeah, which is why I suggested getting the jump on the default handler in order to get that raw body stream
18:14justin_smiththat should be possible with a middleware in the right place in the stack
18:14justin_smithor did I articulate that? I meant to
18:14[blake|justin_smith: You did, and I missed it.
18:15jcromartieis there a memory issue or something?
18:15[blake|justin_smith: But I'm not sure how it helps.
18:15jcromartiebecause .getBytes should be fine
18:15justin_smith[blake|: it gets the body stream, which will directly give you the bytes
18:16justin_smiththat's a good point too, jcromartie, but I think if what you want is bytes, and that is the initial form coming in, it is silly to let the double conversion happen
18:16[blake|justin_smith: Which...oh, okay, so you're saying something on the server side is turning this into a string from bytes?
18:16jcromartieif the body of the request is the base64-encoded string, then sure
18:17jcromartie[blake|: how is the base64-encoded image being passed to the server?
18:17jcromartiePOST?
18:17jcromartieas a form encoded param?
18:17jcromartieor as the entire request body?
18:19[blake|As part of the "data" in a JQuery ajax POST.
18:20jcromartieas a part of it, or as the whole thing?
18:20jcromartiebecause you can send an object or a strign
18:20jcromartiestring
18:21jcromartiein the former case the JS obj will be sent as form encoded params
18:21[blake|It's not the only part, no. There are two parts. So it's &field1=whatever&field2=whatever...&screencap=toDataUrl()
18:21jcromartiein the latter it will be the literal POST body
18:21jcromartieah ha
18:21jcromartiethen I would skip worrying about intercepting the raw request body stream and just decode the (.getBytes (:screencap params))
18:21jcromartiewell
18:22jcromartiethe part after "base64,"
18:22[blake|jcromartie: Thanks. I'll give that a try.
18:22justin_smithjcromartie: yeah, that's actually right, I forgot other stuff would likely be in the body
18:22justin_smith(inc jcromartie)
18:22lazybot⇒ 9
18:22[blake|I may try later different configurations.
18:22[blake|(inc jcromartie)
18:22lazybot⇒ 10
18:22jcromartieyou'll need to pull apart the dataURL scheme
18:23jcromartieor you can do that in JS
18:35SagiCZ1how can i find out if a predicate is true for exactly one element
18:35amalloyfilter the list with the pred, and check that its count is one via (and (seq xs) (not (next xs)))
18:36SagiCZ1amalloy: cool, thanks
18:37jcromartieamalloy: nice, works for lazy seqs :)
18:37amalloyjcromartie: yes, calling count is a sin
18:37SagiCZ1amalloy: wait and what if i dont to return that one elment
18:37SagiCZ1thsi would return true/false
18:38amalloySagiCZ1: who cares? wrap it in boolean if that really matters
18:38SagiCZ1*what if i WANT to return that one elment
18:38amalloySagiCZ1: you probably don't
18:38SagiCZ1[:a :a :b :a :a :a :a] -- > there is only one :b so return :b
18:38amalloywhat if the thing for which the predicate passes is falsey?
18:39SagiCZ1then idk.. gosh this is hard :(
18:39amalloyeg, (one-matches? nil? [1 2 3 nil])
18:39amalloywill return nil, just like (one-matches? nil? [1 2 3])
18:39SagiCZ1ok then let it return nil.. thats cool
18:40TEttingerbut nil is the "value not found" there
18:40TEttingerit can't also be "value found" and still be usable
18:40TEttinger(for collections containing nil that you want to find nil in)
18:40SagiCZ1wait but how do i get to the element still?
18:40TEttingerfirst xs
18:41SagiCZ1i need to return the element if there is only one passing that predicate, otherwise return nil
18:42SagiCZ1,(filter pos? [5 5 6 -1 -2 6 5])
18:42clojurebot(5 5 6 6 5)
18:42TEttinger,(let [coll [1 2 3] pred #(= (mod % 2) 0) xs (filter pred coll)] (if (and (seq xs) (not (next xs))) xs))
18:43clojurebot(2)
18:43TEttinger,(let [coll [1 2 3] pred #(= (mod % 2) 0) xs (filter pred coll)] (if (and (seq xs) (not (next xs))) (first xs)))
18:43clojurebot2
18:43TEttinger,(let [coll [1 2 3] pred #(= (mod % 2) 1) xs (filter pred coll)] (if (and (seq xs) (not (next xs))) (first xs))) ;; if more than one matches the pred....
18:43clojurebotnil
18:44SagiCZ1,(let [coll [1 2 3] pred #(= (mod % 2) 1) xs (filter pred coll)] (if (and (seq xs) (not (next xs))) (first xs)))
18:44clojurebotnil
18:45SagiCZ1i think this works great
18:45SagiCZ1thank you very much both
18:45TEttinger(inc amalloy)
18:45lazybot⇒ 210
18:45SagiCZ1(inc TEttinger)
18:45lazybot⇒ 36
18:46TEttingerslowly improving that thar karma
18:52[blake|What makes "spit" only suitable for small amounts of data?
18:52tcrayford____it buffers all the data into a string at once (iirc)
18:53[blake|tcrayford____: So, if I had all the data in a string already, I'd have two copies?
18:53tcrayford____or potentially you could exhaust the memory of the system
18:53[blake|fair 'nuff
18:54tcrayford____and the JVM GC doesn't cope all that well with huge objects
18:54[blake|tcrayford____: Cool, thx.
18:54[blake|(inc tcrayford____)
18:54lazybot⇒ 1
18:56TEttinger(inc tcrayford)
18:56lazybot⇒ 1
18:57tcrayford____haha, I've only recently come back to this channel
18:57tcrayford____last time I was here heavily there wasn't a lazybot
19:00TEttingerlazybot's a good one. clojurebot has a better eval though, usually
19:00amalloytcrayford____: lazybot used to be called sexpbot until like...two or three years ago
19:00TEttinger,(def something (map * (range) (range)))
19:00clojurebot#'sandbox/something
19:00TEttinger,(take 10 something)
19:00clojurebot(0 1 4 9 16 ...)
19:01amalloy&(take 10 (map * (range) (range)))
19:01lazybot⇒ (0 1 4 9 16 25 36 49 64 81)
19:01amalloyi can see why you'd like clojurebot's better :P
19:01TEttingerhehe
19:21[blake|bytes are signed?
19:21gfredericksso signed
19:22justin_smith[blake|: in java, everything is signed
19:22mfikesExcept for char?
19:22augustl-127 is 0, yay
19:22justin_smithmfikes: char is not numeric
19:22hyPiRionexcept for the jars themselves
19:22justin_smithhaha
19:22gfredericks~badum
19:22clojurebotPardon?
19:22gfredericks~goards
19:22clojurebotHuh?
19:22justin_smithaugustl: surely you mean -128
19:23gfredericks~guards
19:23clojurebotSEIZE HIM!
19:23gfredericksoh thank goodness
19:23justin_smith~gourds
19:23clojurebotSQUEEZE HIM!
19:23gfredericksyeah speling
19:23augustljustin_smith: I must have problems with my cache invalidation and/or naming things
19:24justin_smithaugustl: the best version of that joke involves blurting "concurrency" in the middle of someone else telling the joke
19:24gfredericksthere are only fifteen hard problems in computer science: naming things.
19:25gfredericksthere are only 10 hard problems in THIS IS A JOKE ABOUT BINARY NUMBERS
19:26justin_smithgfredericks: aka bumbers
19:27[blake|Well, dammit. I was afraid of this. I get my data decoded and written to disk and I can't read the resultant PNG. =(
19:29gfredericks(inc bumbers)
19:29lazybot⇒ 1
19:31dbastondoes anyone know if I can cancel nREPL execution initiated from vim-fireplace? In my attempts to do elegant recursion I seem to be starting lots of infinite loops instead...
19:33justin_smithdbaston: https://github.com/tpope/vim-fireplace/commit/286a1f6c47fc0efe017e69c8e862e1433a4b6189 looks like it is supported as of this commit, dunno the keybinding though
19:40dbastonjustin_smith: Thanks, you're right, and Ctrl-C seems to do the trick. I swear it didn't before now!
19:44EvanR-workmake sure your elegant recursion includes evidence that it will either terminate or at least continue to produce useful results forever ;)
19:44EvanR-workelegant evidence* ;)
19:49dbastonmy mistake is accidentally executing an "iterate" form
19:49justin_smithyeah, you usually want to put that inside a take-while or nth
20:03[blake|Well, okay, looks like I've been going about this all wrong. I need to render a web-page to disk from the server. Is that a thing? Seems like it should be a thing.
20:08munderwoSo if I want to build a vector of maps where each element from another sequece is one of the values… how do I do that?
20:08munderwoI tried something like (map #({:foo %1}) list-of-values)
20:09tolstoy(map :foo list-of-hashmaps)?
20:09amalloymunderwo: try writing it with (fn ...) instead of the #() shorthand
20:09amalloyand then look at what the #() shorthand expands to, noticing the difference
20:09munderwoyeah… just worked that out. Its always hard working out when #() will work and when it wont
20:10amalloy,'#({:foo %})
20:10clojurebot(fn* [p1__25#] ({:foo p1__25#}))
20:10amalloysee how that's different from (fn [x] {:foo x})?
20:10munderwoso this does what I want
20:10munderwo(map (fn [x] {:value x}) lines)
20:10munderwoahh, because the map is in a list so it gets executed… I see
20:11munderwowhich doesnt make sense because you cant execute a map..
20:11justin_smithmunderwo: the easy way (I think) is to remember that #() always invokes its first arg, the first arg to #({}) is {}
20:11amalloy#() *always* has parens as the outermost thing
20:11SagiCZ1munderwo: you can do #(hash-map :foo %) but its not exactly the same as {:foo .. }
20:11munderwoyeah. that makes sense… Its just finding that out :)
20:11justin_smith,({:a 0} :a) ; munderwo
20:11amalloymunderwo: well, actually you can call a map as a function, but it doesn't do what you want
20:11clojurebot0
20:11munderwothanks!
20:12justin_smithsilly way to get {:foo %1}: #({:thing {:foo %1}} :thing)
20:15amalloyjustin_smith: #(do {:foo %})
20:15justin_smithamalloy: that's not nearly as silly
20:15amalloytrue
20:17hyPiRion"#() *always* has parens as the outermost thing" – ahem
20:17hyPiRion,((->> :ten #()))
20:17clojurebot:ten
20:18justin_smithhyPiRion: the parens that follow #
20:18hyPiRionah, alright then
20:19justin_smiththough I guess that macro displaces what eventually becomes its body...
21:38charlesgiiiIs there a common way that people connect to the browser repl? I'd like to use vim (+vim-fireplace) to live code like Light Table provides
21:42scottjcharlesgiii: austin https://cognitect.wufoo.com/reports/state-of-clojurescript-2014-results/
21:50charlesgiiiscottj, thanks!
22:07paomianI have a problem,when i use the core.async,how to get the length of items which in chan
22:07justin_smithpaomian: take them all and count while you are taking
22:10paomianjustin_smith: Ok,i means that i don't know the consumer is to many or producer
22:11justin_smithI don't understand what you just said
22:11amalloyyou can't inspect channels except by taking things from them
22:12paomianjustin_smith: my englist is poor
22:12paomianI means that i take the chan like a queue
22:13justin_smithright, and you can't read or count the values without removing them from the channel
22:14paomianjustin_smith: ok,i get it
22:14paomianthank you
22:45DanielWu
22:45DanielWu(def postgres-db "postgresql://postgres:oracle@localhost:5432/example")
22:45DanielWu(j/update! (j/db-find-connection postgres-db) :connector_files {:message_create 1} ["file_id = ?" 10])
22:45DanielWuIllegalArgumentException db-spec false is missing a required parameter clojure.java.jdbc/get-connection (jdbc.clj:289)
22:45DanielWuWhat is missing?
22:45DanielWuuse the same parameter I could run j/query function witout any issue, but if with update, then it failed.
23:06justin_smithDanielWu: so it works with no password?