#clojure logs

2015-09-14

00:00Trioxinstrange, lein is working from command prompt now but not from in IDEA. it's in user path
00:01Trioxincould also add to system path
00:03Trioxinhah got it
00:04TrioxinLeiningen 2.5.2 on Java 1.8.0_60 Java HotSpot(TM) 64-Bit Server VM
00:05Trioxinthx for help guys
00:43TrioxinI did this last night correctly. what am I doing wrong now? http://screencast.com/t/PLkgkgDlUA
00:45TrioxinI right clicked "Run REPL for project4" so it connected, then switched to project4.core and tools -> REPL -> Switch REPL NS to current file
00:46Trioxinbut have no access to foo .. (defn foo [x] (println x "Hello, World!")) from the REPL window
00:47justin_smithTrioxin: do you need to tell it to load the namespace first?
00:47justin_smithbefore telling it to switch to it
00:48justin_smithin a normal repl, you would have the two steps separately
00:48Trioxinill try
00:54Trioxinokay I got it. I switched to the file (There was a button for switch to) then I ran load current file in REPL and then finally switched NS to current file
00:55Trioxinso when I finally go and build my project the end result will be a jar?
00:55justin_smithyeah, so that sounds like the right sequence
00:55justin_smithyes, it will make a jar you can run via java
00:56justin_smithso your deploy environment doesn't need to have clojure or any of your other libs or lein
00:56justin_smithjust java
00:56justin_smithor, with some plugins you can make a package that can be loaded in a container (eg. uberwar for running inside tomcat on beanstalk)
00:56Trioxinok and then from there I can go about packaging, making executables, packaging the JRE if I want to or whatever
00:57Trioxinif it's some software I'm selling I mean
00:57justin_smithwell "packaging" is mostly done by the uberjar process. I guess you can ship a jre if you want, but it will run on any reasonably modern jre so someone could just use their own
00:58justin_smiththe key thing is that the uberjar puts everything needed to run your code into one file, except the jvm itself
00:59Trioxinis that part of the IDEA/cursive build process?
01:00justin_smithit's something lein does (though cursive should make lein do it if you go to build the project)
01:00TEttingerit's a lein command. I believe cursive doesn't produce an uberjar for every build?
01:00cflemingNo, Cursive doesn't do anything like that
01:00TEttingerfor me, uberjars take a while to make but cursive runs the program quickly
01:02Trioxin"We recommend against using uber-JARs. They introduce many problems for downstream consumers. "
01:02Trioxinoh that was on the fii site
01:03justin_smithwho's
01:03justin_smith?
01:03Trioxinhttp://fiji.sc/Uber-JAR
01:04Trioxinwas just looking for how to do it
01:04Trioxinand that came up in the results
01:04justin_smithTrioxin: uberjars should be used for apps, not for libs
01:04Trioxinapps are what I'm trying to make
01:05justin_smithyeah, I would agree with the fiji folks that uberjars are annoying with libs, but when I am deploying apps uberjars have always worked for me
01:05justin_smiththough I am deploying to my own servers, not to clients...
01:06Trioxinhttps://github.com/technomancy/leiningen/blob/master/src/leiningen/uberjar.clj
01:06raspasovsame here, no problems with uberjars for apps, they work great
01:07justin_smithTrioxin: oh man I submitted a silly thing to that namespace
01:07Trioxinso lein can make my uberjar?
01:08Trioxinyeah: lein uberjar
01:09Trioxin"For this to work you'll need to specify a namespace as your :main in project.clj and ensure it's also AOT (Ahead Of Time) compiled by adding it to :aot."
01:09justin_smitheh, I break those rules all the time :P
01:10justin_smithjava -cp my-uber.jar clojure.main -m my.ns
01:10rem500Hi I have a question. (seq? [1,2,3]) returns false because only lists are sequences. But rseq can only be used on vectors or sorted maps, things that AREN'T seqs. Can someone explain?
01:10justin_smithet. voila, no aot needed
01:10justin_smithrem500: rseq generates a seq from things that are not seqs
01:11justin_smith,(seq? (range))
01:11Trioxinic
01:11clojurebottrue
01:11justin_smithrem500: note that (range) does not return a list, but it is a seq
01:11justin_smith,(list? (range))
01:11clojurebotfalse
01:11justin_smithrem500: at risk of being totally unhelpful, seq? returns true for things that are seqs :P
01:12rem500Ok and rseq is the most efficient way to reverse anything?
01:12justin_smithrem500: most efficient way to reverse the things it can reverse
01:12justin_smithseqs are not structured in such a way that rseq can reverse them
01:13justin_smiththis is because vectors and sorted maps provide fast access to their last element
01:13justin_smithseqs do not
01:13rem500why is it called rseq though
01:13justin_smithit gives you a reversed seq from your input
01:14rem500is it worth changing a list into a vector just to use rseq?
01:14justin_smithrem500: clojure does weird things with return types sometimes, but if you check the return types those should be predictable at least, and there's usually a very good reason (though its counterintuitive)
01:15justin_smithrem500: oh, I don't think so no
01:15justin_smithbecause creating a vector is O(1), and so is reversing a list
01:15rem500ok so just rseq on vectors and sorted maps and reverse on lists, sounds easy enough
01:15Trioxinwhat about GUIs? I enjoy creating webkit GUIs and if I could do that then I could use clojurescript in my GUI alongside my other javascript and html/css. I could just use node-webkit and call my .jar file from the command line or maybe load it into the webkit app as an applet?
01:16justin_smithrem500: yeah, though don't call reverse on things that are unbounded for obvious reasons
01:16Trioxindon' really want to use like GTK+
01:16rem500unbounded like (range)
01:16justin_smithTrioxin: with clojurescript you can ship the js output
01:16justin_smithrem500: exactly
01:17justin_smithTrioxin: the tooling can be a bit complex, but I have found clojure server, plus figwheel, plus clojurescript and react on the frontend, is a very slick way to develop a browser based app with a backend
01:17justin_smithI haven't tried standalone cljs though I imagine that would work pretty slick too
01:22Trioxinjustin_smith, are you talking about for a web site or for a desktop app?
01:23Trioxintrying to make some sense of this at the moment https://github.com/bhauman/lein-figwheel/wiki/Quick-Start
01:23justin_smithTrioxin: reagent / figwheel / cljs should work for either, but what I'm doing is a web app
01:23rem500What is a sequence? I know lists are linked lists and vectors are contiguous arrays does that play into it or is it something else
01:24justin_smithvectors are not contiguous
01:24justin_smithvectors are actually a type of tree
01:24justin_smithrem500: http://hypirion.com/musings/understanding-persistent-vector-pt-1 awesome series of blog posts on how our vectors work
01:25justin_smithrem500: everything in clojure that is a seq is some kind of linked list (even if not strictly a list)
01:25rem500ok cool thanks i will read that
01:25justin_smithrem500: thinks seqs share is that it is easy to get the next item, but not easy to do random access, and there is no way to find out the total size without walking all the way to the end
01:26justin_smith*things
01:26justin_smithbasically the constrants of a linked list, there
01:28muhukrem500: sequence is an abstraction on top of lists, vectors, maps & sets
01:28muhuk,(= (seq [1 2 3]) '())
01:28clojurebotfalse
01:29justin_smithmuhuk: more than that actually - you can get a seq from a string, a List, an array...
01:29justin_smithan iterator even
01:31TrioxinI wonder if I could just run a clojure uberjar in node-webkit as an applet
01:32Trioxini know I could execute it behind the scenes by just running the process
01:32justin_smithTrioxin: like I said, for cljs you export js
01:32justin_smithjs does not run uberjars
01:32justin_smithif you are using node you shouldn't also be running java
01:33Trioxinit's a browser
01:33justin_smithand if you are using that you should be using clojurescript, what does it gain you if the backend is clojure?
01:34Trioxinbecause even with having node available it borks up sometimes when trying to do computationally intense things like I tried to monitor the filesystem (The windows dir) and it hung up
01:35Trioxinplus the advantage of just having the JVM along with my webkit app
01:35Trioxini wouldn't have to rely on node
01:35Trioxinand I could use clojurescript and clojure
01:35justin_smithOK, I guess you could do that, it still seems like it would be simpler to ship js if you want node-webkit to run the app
01:35justin_smithbut yeah, that's all doable
01:36Trioxini just like that part of it for the ease of making the GUI
01:36Trioxinand I know applets can talk to JS and the other way around
01:36justin_smithapplets too?
01:36justin_smithwhy applets?
01:37Trioxinbecause they can talk to JS and therefore clojure easily, not that I would have to take that route
01:37Trioxini could use sqlite or something
01:38justin_smithI don't understand what applets would do for you, if you already are running a clojure process plus cljs in the browser talking to it
01:38justin_smithand I don't have any concept of how sqlite would be an alternative to an applet...
01:39Trioxinbecause then I could have nw just run the applet and communicate with nw/the gui through sqlite
01:39Trioxinnot the applet I mean the jar
01:39Trioxinthe clojure process
01:40justin_smithwe have websockets
01:40justin_smithOK
01:40Trioxinthere's that too
01:40justin_smithso when you said applet you meant the clojure jar
01:40justin_smithright, that makes sense
01:40justin_smithsente makes it very easy to use websockets between clojure and clojurescript
01:40Trioxinwell no at first I meant embedding the jar as an applet because it and javascript can communicate easily
01:41Trioxini don't think sockets are necessary when doing that
01:41Trioxini think it's done in the browser
01:41justin_smithI think you'll find a regular clojure process (not in an applet) can communicate with clojurescript in a browser very fluently
01:42Trioxinok. what I was mainly getting at is apart from nw, how do people using closure usually go about a desktop GUI? Just want to compare to what I would normally do with a webkit
01:43justin_smithif I were doing it I would compile a clojurescript app to js, and just run that js
01:43justin_smithbut someone else might have more actual experience to share
01:43Trioxinrun it in webkit you mean?
01:43justin_smiththere's also seesaw, which is a frontend to swing
01:43justin_smithTrioxin: yes
01:44justin_smithalso, there's javafx, for another native java option
01:46Trioxinok I'll just stick with nw because it's portable and easy to use and I can obviously compile clojurescript to run in it. as for clojure doing heavy lifting on the backend there's the option to do that in a few different ways
01:46justin_smithyeah, that sounds smart to me
01:46Trioxinyeah I've seen some good looking javafx stuff too
01:47Trioxinbut I'm guessing it would be much more tedious
01:47justin_smithTrioxin: using javafx looks pretty easy actually... https://coderwall.com/p/4yjy1a/getting-started-with-javafx-in-clojure
01:47justin_smithI have not tried it though
01:48justin_smithand you might want to spend more time getting good at the language before you get into weird tooling and optional libs and such
01:50Trioxini paid someone a while ago to make this awesome app in java/javafx and loaded as an applet. it was for streaming torrents and was much better than popcorn time. One thing I want to do is rewrite that project
01:50justin_smithinteresting, I have not heard anything good about applets myself...
01:50Trioxinusually no but in this case it was awesome
01:52Trioxini mean I could have made it a desktop app but I wanted people to be able to just come to the site and run it and back then I didn't know about webkit desktop apps
01:54Trioxini should bring it back online
01:54Trioxinand kickstart the rest
01:55justin_smithI bet it would be a nice exercise to take the app as is and port as much of the functionality as possible to clojure
01:55Trioxinyeah
01:55Trioxinthe GUI is great. it's metro style in javafx
01:55justin_smiththough clojure might run into RAM usage limits in an applet
01:56Trioxinpopcorn time is cool but they've made some mistakes that I didn't
01:56mungojellywhat can i say to poke at the ram usage of things
01:57justin_smithmuhuk: you can connect visualvm to your clojure process and see a log of its usage of memory
01:57justin_smitherr
01:57justin_smithmungojelly: ^
01:57Trioxinmaybe there's a webkit I can run in clojure
01:57Trioxinwebkit lib for java
01:58Trioxini see this for nw seesaw
01:58Trioxinoops
01:58Trioxinhttps://github.com/wilkerlucio/lein-node-webkit-build
01:59mungojellywow yay, leveraging generic jvm tooling
01:59justin_smithI hear yourkit works even better with clojure
02:07Trioxinhttps://github.com/solicode/clj-thrust
02:08justin_smithinteresting, I had not heard of that one
02:14Trioxinok so back to reality. (+ 2 3) evaluates to 5 but why can't i do like (+ 2 3 * 2)
02:14justin_smithTrioxin: because a paren treats the first thing after it as a thing to call
02:14justin_smithTrioxin: and without a paren, you are just referring to the function, not calling it
02:15justin_smith,(+ 1 2 3)
02:15clojurebot6
02:15justin_smith,[1 2 + 3 4 * 5]
02:15clojurebot[1 2 #object[clojure.core$_PLUS_ 0x66b73e82 "clojure.core$_PLUS_@66b73e82"] 3 4 ...]
02:15mungojelly,(+ 2 (* 3 2))
02:15clojurebot8
02:16justin_smithyes, that's likely what Trioxin wants there
02:16Trioxinah i see
02:16justin_smithit takes a little while before flipping math expressions like that makes intuitive sense
02:16justin_smithhere's a cool one we can do in clojure:
02:16justin_smith,(< 0 1 2 3)
02:16clojurebottrue
02:17Trioxinheh
02:17justin_smith,(< 0 1 2 3 -1)
02:17clojurebotfalse
02:17mungojellyit's a compromise, you have to learn an unusual order for some verbs, but in exchange the syntax is deadly regular and thus the computer can help more with writing the code
02:17justin_smith< effectively asks if all the args are sorted
02:17Trioxinoh
02:17justin_smithmungojelly: indeed, and we can do cool things by stacking up the args that wouldn't work with binary predicates
02:17justin_smith,(+)
02:17clojurebot0
02:18justin_smith,(*)
02:18clojurebot1
02:18justin_smith,(/ 2)
02:18clojurebot1/2
02:18justin_smith,(/ 8.0)
02:18clojurebot0.125
02:18mungojelly,(/)
02:18clojurebot#error {\n :cause "Wrong number of args (0) passed to: core//"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (0) passed to: core//"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.RestFn invoke "RestFn.java" 399]\n [sandbox$eval241 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval241...
02:18justin_smithmungojelly: no base case for /
02:18mungojelly,(/ (/ 2) (/ 2))
02:18clojurebot1N
02:18Trioxin,(< 1 50000000000000000000000000000000000000000000000000000000000000000000000)
02:18clojurebottrue
02:18justin_smith,(/ 1 2 3)
02:18clojurebot1/6
02:19mungojellyit should have an extra truth case TRUE!!! for when something is really super obviously true
02:19Trioxinit spits out fractions like that?
02:19mungojellyyeah it has real ratios
02:19Trioxinholy crap
02:19justin_smithTrioxin: it uses fractions when possible instead of truncating, yeah
02:19mungojelly,(/ 22 7)
02:19clojurebot22/7
02:19justin_smithTrioxin: old lisp tradition, that one
02:20Trioxinwhat about factoring?
02:20justin_smithTrioxin: this can be a performance issue, so when number crunching is a bottleneck you often want to explicitly force floating point or integral math
02:20justin_smithhmm, I think the vm has some stuff for factoring, but I may not know what you mean exactly
02:20justin_smithdo you mean like primality testing?
02:21Trioxinwas just thinking of performance since that can be computationally expensive
02:23justin_smithwith clojure 1.7 and newer we have an option to have the compiler warn about math boxing, which is a superset of that perf issue (since rationals are always boxed)
02:25Trioxin,(defin factoring [n] (filter #(zero? (rem n%)) (range 1 (inc n)))) (print (factoring 45))
02:25clojurebot#error {\n :cause "Unable to resolve symbol: defin in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: defin in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: defin in this...
02:25Trioxin,(defn factoring [n] (filter #(zero? (rem n%)) (range 1 (inc n)))) (print (factoring 45))
02:25clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/rem--inliner--4336"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "clojure.lang.ArityException: Wrong number of args (1) passed to: core/rem--inliner--4336, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type clojure.lang.ArityException\n :message "Wrong numb...
02:26justin_smithTrioxin: n% is treated as if it were one thing
02:26Trioxin,(defn factoring [n] (filter #(zero? (rem n %)) (range 1 (inc n)))) (print (factoring 45))
02:26clojurebot#'sandbox/factoring
02:26Trioxinlol
02:26justin_smithTrioxin: also, that call to factoring won't be called, unless you wrap the whole thing in a do
02:26mungojellywhat should i say when i want to remember something
02:26justin_smithnow you can just do the call to factoring on its own of course
02:26justin_smithmungojelly: ?
02:27justin_smithlike store a value for later?
02:27mungojellywell i don't want to hard code a database call obviously
02:27justin_smith,(factoring 45)
02:27clojurebot(1 3 5 9 15 ...)
02:27mungojellyi could wrap in my own save-this thingy, but is there a better idiom for putting a database hook
02:27Trioxinhow would I rename factoring to factor?
02:27justin_smithTrioxin: you don't need to call print at the top level - every expression returns a value to the repl, and that value is always preinted
02:27Trioxincan that be doe?
02:27justin_smiththis is the P in rePl
02:28justin_smith,(def factor factoring)
02:28clojurebot#'sandbox/factor
02:28justin_smith,(factor 45)
02:28clojurebot(1 3 5 9 15 ...)
02:28Trioxinnice
02:28Trioxin,(factor 3255)
02:28clojurebot(1 3 5 7 15 ...)
02:28Trioxinoh it won't keep going
02:28justin_smithmungojelly: for simple stuff I like to put a hash map inside an atom
02:28mungojellyis that a seq it's making?
02:29mungojelly,(type (factor 3255))
02:29clojurebotclojure.lang.LazySeq
02:29justin_smithTrioxin: clojurebot has a limit on how long its printed output can be
02:29mungojelly,(take 20 (factor 3255))
02:29clojurebot(1 3 5 7 15 ...)
02:29mungojellystill won't give me more :)
02:29justin_smith,(def db (atom {}))
02:29clojurebot#'sandbox/db
02:29justin_smith,(swap! db assoc :a 42)
02:29clojurebot{:a 42}
02:30justin_smith,(swap! db update :a inc)
02:30clojurebot{:a 43}
02:30Trioxinlooks like we're not cracking an encryption with clojurebot :P
02:30justin_smith,(swap! db assoc :b "OK")
02:30clojurebot{:a 43, :b "OK"}
02:30justin_smithmungojelly: so that's the basic idea if yuo don't need persistence beyond runtime
02:30justin_smithalso useful for debugging
02:30sm0kehow do i change the default ns in boot again?
02:31justin_smithsm0ke: changing :main will suffice in lein / nrepl
02:31Trioxinso def will rename it and I'm guessing anything else
02:31mungojellyjustin_smith: that just taught me "swap!" so thanks but persisting to disk is what i'm thinking about
02:31justin_smithTrioxin: not rename, it gives the thing another name
02:32Trioxinoh right because we're immutable
02:32sm0kehurmm
02:32justin_smithmungojelly: OK, yeah, you'll want a db for that
02:32sm0kedoesnt work
02:32mungojellyjustin_smith: as well as multiple algorithms can {} be a hook for a database :) or what hook should i put
02:32Trioxinor at least we want to be
02:32justin_smithTrioxin: you can also destroy the original var with ns-unmap if you want
02:32Trioxin(ns-unmap factoring)
02:32Trioxin,(ns-unmap factoring)
02:32clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/ns-unmap"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/ns-unmap"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval332 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$...
02:32sm0kei can use `boot repl -e '(in-ns...)', but looks overkill
02:33Trioxin,(ns-unmap factor)
02:33clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/ns-unmap"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/ns-unmap"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval356 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$...
02:33justin_smithTrioxin: look at the docs before trying again
02:33Trioxink
02:33justin_smith(doc ns-unmap)
02:33clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
02:33justin_smithnote that it has an ns arg, and a symbol arg
02:33mungojellyhow can that error not say what number of args would be right :/
02:33justin_smithI think both need to be symbols, not the values
02:34justin_smithmungojelly: because clojure has very little work put into making errors sensible or friendly
02:34mungojelly(something 1) no! one is the wrong number of arguments! (something 1 2) no! two is also the wrong number! (something 1 2 3)? pls? y u make me guess, error
02:34justin_smithmungojelly: yeah, or you could look at the source or the doc string via the repl
02:34Trioxinyeah I've noticed that playing with repl
02:35justin_smithbut yes, clojure has terrible UX around errors
02:35mungojellythat's what it seems like is an admonishment: you have used this incorrectly, you should look at the docs before even thinking of trying to use it again :)
02:35mungojelly,(doc ns-unmap)
02:35clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
02:36Trioxin,(ns-unmap sym factor)
02:36clojurebot#error {\n :cause "Unable to resolve symbol: sym in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: sym in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: sym in this conte...
02:36mungojelly,(ns-unmap sandbox factor)
02:36clojurebot#error {\n :cause "Unable to resolve symbol: sandbox in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: sandbox in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: sandbox i...
02:36justin_smithmungojelly: both those values should be quoted
02:36justin_smith,(ns-unmap 'sandbox 'factor)
02:36clojurebotnil
02:37justin_smith,(ns-publics 'sandbox)
02:37clojurebot{}
02:37justin_smithno defs!
02:37Trioxinmy fault I'm a bit off my tutorial doing this right now
02:37mungojelly"nil" is a funny way to say "i have happily completed that operation," does that "nil" have metadata saying what it means
02:37justin_smithno, it's just the thing usually returned if there is nothing interesting to return
02:37Trioxinnil == null?
02:38justin_smithyou can't put metadata on nil
02:38justin_smithright
02:39mungojellyi just thought it makes sense with that metadata pattern, you're returning "nil" so things can test on whether the result, but also that doesn't necessarily mean you have nothing at all to say to your caller, you could also report to them on how the operation went if they wanted details
02:40mungojellyinstead when i want details of executions i'm putting :verbose flags and such apparently so :)
02:41Trioxin,(ns irc (:import (java.net Socket) (java.io PrintWriter InputStreamReader BufferedReader)))
02:41clojurebotnil
02:42justin_smith,*ns*
02:42clojurebot#object[clojure.lang.Namespace 0x39b70af3 "sandbox"]
02:42justin_smithfoiled!
02:43Trioxinwhat happened?
02:43justin_smithyou tried to change the namespace, and it didn't stick
02:43Trioxinoh
02:43Trioxin(:import (java.net Socket) (java.io PrintWriter InputStreamReader BufferedReader))
02:43justin_smithevery call to clojurebot starts a new repl
02:43justin_smithimport doesn't work that way at the top level
02:44justin_smith,(:import 'this-arg-ignored 'this-arg-returned) ; nothing was imported here
02:44clojurebotthis-arg-returned
02:45Trioxin,(:import (java.net Socket) (java.io PrintWriter InputStreamReader BufferedReader)) (def freenode {:name "irc.freenode.net" :port 6667}) (def user {:name "someguy" nick "someguy333")
02:45clojurebot#error {\n :cause "java.net"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: java.net, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.ClassNotFoundException\n :message "java.net"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLCl...
02:46Trioxinoops wrong part
02:46justin_smithTrioxin: :import only works inside ns, outside ns you need import
02:46Trioxinoh
02:46justin_smithanyway, I'm leaving my client logged in, but will be physically away from the computer for a while
02:47mungojellybye justin_smith
02:47Trioxinlater thx for the teaching
03:23mungojellyi'm still wondering how makes sense to hook to databases, like if i'm making a piece of code that by its nature wants to write out a stream of data, but it doesn't care how it's recorded-- wait ok i should just have it emit a stream of data, then, i guess, and handle it from the other side!?
03:32mungojellyif my thingy gives off streams with various sorts of information then in context you can persist those or forget them or w/e. ok how do i have my thingy give off various streams of stuff?
03:39muhukmungojelly: you can start by defining "thingy" & "stuff"
03:39mungojellymuhuk: hello fellow "mu"! i'm thinking abstractly though
03:39mungojellyi just have any thing, it produces data, or does if you poke it, or w/e
03:40mungojellyi'm thinking the state should all be external, and also whether to persist that state or what parts of it, but maybe they should give hints what would be good to do with what output, hm
03:44muhukmungojelly: you're almost describing an agent system.
03:46mungojellyhow do you joint the connection between your programs and their databases
03:48mungojellyno joint at all: program writes to a particular database interface. ouch. minimal joint: program calls local "write to database" idea, which abstracts over a pluggable choice of databases. but i want to joint more than that?
03:49muhukmungojelly: have you ever written code that writes to a db?
03:50muhukif you did, chances are you have had the maximum amount of joint.
03:51mungojellyum sure i've written to dbs various ways. a couple weeks ago i wrote code in python that manually stitched together bits of SQL :/
03:52mungojellybut i'd like to abstract above "write to db", more like "this data could be interesting to write to disk" as a hint to something that takes that hint
04:02copycathi guys, i hope i can ask a rather frivolous question
04:02copycatwhat's the most fun thing you wrote in clojure?
04:04mungojellycopycat: i just started, so the most fun i've had so far is just playing around with parameters in ants.clj, probly not helpful to your survey sorry
04:05mungojellyi mean like, (run-with-logging (thingy :log-level :zillions) database-writing-function), so you can trap its log stream for testing or w/e-- no?
04:39nedvilesHi!
04:40Guest87768What's up?
04:41Guest87768sup?
04:41Guest87768hallo!
04:42Guest87768ping!
04:42Guest87768!staff
04:42oddcullyGuest87768: herro! we can see you!
04:43Guest87768I just tried some commands, haha!
04:43oddcullyin a public channel with a metric ton of users
04:43Guest87768On some other networks they have commands like "staff, ping, sup" etc.
04:52oOzzy` Hey there! I was just wondering on what the best practice is for runtime constants. I use `environ` to fetch environment variables for e.g. a database url that's different in dev, test and prod. It seems like when using `(def database-url (env :database-url))` the variables are fetched from the compilation environment though.
04:59muhukoOzzy`: well, of course. You can convert database-url to a no-args function.
05:00muhukoOzzy`: or make if a delay and then deref each time you use it.
05:00muhukoOzzy`: or change the var root during execution (but I wouldn't go that way)
05:01oOzzy`The no-arg function is what I'm doing at the moment. Is any of the first two preferable?
05:03muhukoOzzy`: matter of style I think. But delay version might be preferable to signify that the value doesn't change during runtime.
05:04schmiroOzzy`: are you sure that's the case? the (def database-url ...) is eval'ed when compiling, but I think it will also be eval'ed when running the compiled code
05:04raspasovschmir: I don't think it does
05:04raspasovalso, if you look inside environ.core, the env there is specified using defonce, so I'm not sure that get re-evaled either
05:05raspasovI dealt with this in the past, and that's what I ended up using, and it works for me
05:05raspasovhttps://gist.github.com/raspasov/6725d9aa2c6d0f628162
05:05oOzzy`I actually didn't try. I just noticed because I was getting an error at compilation time because that environment variable was null.
05:06raspasovI read my config from a config.clj file inside of -main and call (merge-with-env! ...) in -main
05:06oOzzy`cheers raspasov
05:06muhukraspasov: you know that environ also reads a config file, don't you?
05:07raspasovyea but does it do it dynamically every time?
05:07raspasovor only at compile time? I ran into problems when doing a uberjar
05:07raspasovnot 100% sure though
05:08muhukraspasov: every time, at the start of execution
05:09muhukraspasov: was the file part of the uberjar?
05:10raspasovmuhuk: Don't remember, but that's what ended up working for me https://gist.github.com/raspasov/6725d9aa2c6d0f628162 (just edited)
05:10muhukraspasov: I think it's worth trying again. It seems you are duplicating work here.
05:11raspasovmuhuk: it's possible
05:11raspasovhttps://github.com/weavejester/environ/blob/master/environ/src/environ/core.clj
05:11mavbozoraspasov, so you put your production configuration file in production server in /etc/.../config-....clj ?
05:12mavbozoraspasov, or is that a location in your dev machine?
05:12raspasovmavbozo: it's there in production as well
05:13muhukraspasov: AFAIU .lein-env shouldn't go inside the uberjar, but it should be placed in the same directory with it. Not 100% sure.
05:13raspasovmuhuk: I'm looking at https://github.com/weavejester/environ/blob/master/environ/src/environ/core.clj
05:13raspasovthat defonce at the bottom - does it get executed everytime a uberjar runs, or only once when it's compiled?
05:14raspasovthat's the question I am not sure about : )
05:14schmirit gets evaled when the uberjar runs
05:15muhukraspasov: yeah, as schmir says.
05:15raspasovok : )
05:15schmirthe (def database-url
05:15schmir (env :database-url)) also get's evaled when the uberjar runs
05:16schmir(and also when it's compiled)
05:16muhukactually it doesn't really get evaled twice
05:16muhukit gest evaled when the code is compiled (JVM bytecode) and then run.
05:17muhukif you just compile, it wouldn't get evaled.
05:17schmirmuhuk: if you compile a .clj file the top level forms with get evaled
05:18muhukschmir: clojure.core/compile?
05:19oOzzy`schmir: the problem was it didn't compile because I did something like this: `(def some-port (Integer/parseInt (env :some-port)))` and `SOME_PORT` wasn't set.
05:21schmirmuhuk: yes
05:23schmirif you couldn't change environment variables (or rather if it wouldn't have any effect on the program), the environ package wouldn't make much sense
05:24muhukschmir: you are right. I just checked.
05:52karlshttps://www.duedil.com/b2b-lead-generation
05:52karlssorry! wrong window.
05:55visofhi guys
05:56visofwhat is the best solution for this, if i have 3 variable of boolean values, and want to check whether combination of three are either true true true, or false false true or other combinations and do action for each combination
05:56visof?
05:57visofmy approach is to convert combination to strings like "110" or "111" and apply case for it
05:57visofis there a better ?
06:00muhukvisof: core.match
06:01schmirvisof: a map mapping a the vector of values to some action comes to mind...i.e. there's no need to convert to a string representation first
06:01schmirbut it probably doesn't matter much
06:01ceruleancityvisof: maybe a multimethod would work?
06:02schmirclojure.core/match may also help (https://github.com/clojure/core.match)
06:02ceruleancity(defmulti parse-bin (fn [input] input))
06:03ceruleancity(defmethod parse-bin “111” [input] true)
06:03ceruleancityetc etc
06:04muhukI wouldn't use a multimethod for this. There are only 8 possibilities.
06:06oddcullydoes this binary representation provide better readability? why not case with [true true false]?
06:07muhukoddcully: I was also thinking that. Reads better IMO.
06:07mavbozo(cond (= [true false true] [x y z]) "true false true" (= [false false true] [x y z]) "false false true"
06:08mavbozoi'll use cond first
06:08muhukmavbozo: why? It's repetitive.
06:09mavbozomuhuk, depends on combination i want to check
06:10muhukmavbozo: do you mean you'd use it in another situation and not the particular situation we're discussing here?
06:11mavbozomuhuk, i use cond for this 3 variable of boolean values situation
06:12muhukmavbozo: then you'd repeat (= ... [x y z]) 8 times for no good reason.
06:14mavbozomuhuk, i can wrap the cond in (let [v [x y z])... then (cond (= ... v)
06:14mungojelly,(let [x true y false z true] (if (= [x y z] [true false true]) "yes" "no"))
06:14clojurebot"yes"
06:15muhukmavbozo: then you'd repeat (= ... v) 8 times for no good reason.
06:15mungojellydo we have optional keyword arguments
06:15muhukmungojelly: sort of
06:15Trioxin,(defn foo [x y] (print x y) (if (< x9) (recur (inc x) (dec y)))) (foo 5 2)
06:15clojurebot#error {\n :cause "Unable to resolve symbol: x9 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: x9 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: x9 in this context"...
06:16Trioxin,(defn foo [x y] (print x y) (if (< x 9) (recur (inc x) (dec y)))) (foo 5 2)
06:16clojurebot#'sandbox/foo
06:16mungojellycan i give a keyword to an argument but also have it filled by a nameless first argument, like (fun :something :val) is the same as (fun :val)
06:16muhukmungojelly: someone will post a link about how they should be attempted in 3 .. 2 .. 1
06:16oddcullybut cond would allow to combine common cases (e.g. always blerp if z==true)
06:16muhukr/should/should not/
06:16muhukoddcully: good point.
06:16Trioxinwhy did the bot just say that?
06:17mungojellyyou defined a function so it returned it to you
06:17mavbozobut the v is not the important thing here, the [true false true], [false false true] pattern that i want to match is, at the expense of writing v many times
06:17Trioxini called the function too
06:17Trioxin,(foo 5 2)
06:17clojurebot5 26 17 08 -19 -2
06:18mavbozomuhuk, i'm open to better alternatives for this particular problem
06:18muhukmavbozo: write cond & case versions side by side to see what I mean.
06:18muhukmavbozo: oddcully raised a good point, but let's assume we want to check for all 8 cases and do something different.
06:19Trioxin,(def foo)
06:19clojurebot#'sandbox/foo
06:20mavbozomuhuk, agree, case leads to shorter codes, I change my mind
06:20Trioxin(def foo foo2)
06:20oddcullyTrioxin: the bot only deals with ,(...) and not with ,() () ()
06:20Trioxin,(def foo foo2)
06:20clojurebot#error {\n :cause "Unable to resolve symbol: foo2 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: foo2 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: foo2 in this co...
06:20Trioxino
06:20Trioxinwhat's the way to make an alias of a function again?
06:21oddcully,(def blerp inc)
06:21clojurebot#'sandbox/blerp
06:21oddcully,(blerp 1)
06:21clojurebot2
06:21ceruleancity,(= blerp true)
06:21clojurebotfalse
06:21ceruleancityjust wanted to join the blerp party
06:22oddcullyyou are only supposed to blerp if z is true
06:22Trioxin,(def blerp uppy)
06:22clojurebot#error {\n :cause "Unable to resolve symbol: uppy in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: uppy in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: uppy in this co...
06:22Trioxin,(def uppy blerp)
06:22clojurebot#'sandbox/uppy
06:23Trioxin(uppy 1)
06:23Trioxin,(uppy 1)
06:23clojurebot2
06:23Trioxin,(uppy 9999)
06:23clojurebot10000
06:23Trioxin,(uppy -1)
06:23clojurebot0
06:23mungojelly,(= uppy blerp)
06:23clojurebottrue
06:23oddcully,(= uppy blerp inc)
06:23clojurebottrue
06:24Trioxinand then to remove let's say uppy?
06:25Trioxin,(uppy 1/5)
06:25clojurebot#error {\n :cause "Unable to resolve symbol: uppy in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: uppy in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: uppy in this co...
06:26Trioxinthat made no sense what I just did anyway
06:26oddcully,(ns-unmap (find-ns 'user) 'uppy)
06:26clojurebotnil
06:26oddcully,(uppy)
06:26clojurebot#error {\n :cause "Unable to resolve symbol: uppy in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: uppy in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: uppy in this co...
06:27mungojellyis that better/different than (def uppy nil)
06:27Trioxinyou have to actually search for it?
06:27Trioxin,(def blerp nil)
06:27clojurebot#'sandbox/blerp
06:27Trioxin(blerp)
06:27Trioxin,(blerp)
06:27clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [sandbox$eval117 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval117 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval117 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6943]\n [clojure.lang.Compiler eval "Compiler.java" 6906]\n [clojure.core$eval invokeStatic "c...
06:27Trioxin,(blerp 1)
06:27clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [sandbox$eval141 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval141 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval141 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6943]\n [clojure.lang.Compiler eval "Compiler.java" 6906]\n [clojure.core$eval invokeStatic "c...
06:28Trioxinnil seems better?
06:28mungojellyyou killed blerp :(
06:28mungojelly,(def blerp inc)
06:28clojurebot#'sandbox/blerp
06:28mungojellynow i feel better
06:28Trioxinlol
06:28ceruleancityso is z false forever now?
06:28mungojelly,(blerp (blerp (blerp 1)))
06:28clojurebot4
06:29oddcullyTrioxin: yes i looked it up. i never had the urge to undef something before. if all is lost i restart the repl for my humble usecases
06:30mungojelly,(map blerp (take 10 (iterate blerp 0)))
06:30clojurebot(1 2 3 4 5 ...)
06:30ceruleancity,(doc blerb)
06:30clojurebotexcusez-moi
06:30mungojellyyeah, don't remove things, leave them, they are nice useful things
06:31mungojellysee what you did to poor blerb!? no need
06:31TrioxinBHWYYYYYYYYYYYYYYYYYYY? bluuuuuuuuuuurp
06:32Trioxinblerp
06:32ceruleancity,(doc blerp)
06:32clojurebot"; "
06:32ceruleancitynice
06:33mungojelly,(defn blerp "good for incrementing stuff, deserves to live" [n] (inc n))
06:33clojurebot#'sandbox/blerp
06:33mungojelly,(doc blerp)
06:33clojurebot"([n]); good for incrementing stuff, deserves to live"
06:33TrioxinI can create a language with clojure right?
06:33mungojellythat's sorta how you program lisps, it's a metalanguage
06:33mungojelly,(blerp (blerp (inc (blerp 2))))
06:33clojurebot6
06:34Trioxinwhat if I recreate PHP.. the right way
06:34mungojellyphp has no comprehensible standard :(
06:34Trioxinyet
06:35mungojellynor does java really, which is why clojure is such an amazing accomplishment, it actually engages all that crap
06:35TrioxinI'm still not even closed to used to coding like this
06:36ceruleancityyou’re not alone Trioxin
06:36winkmungojelly: that's not true anymore, the spec is coming along quite well
06:36mungojellywhen i get close to thinking lispily i honestly have a strange drifting hazy feeling like the world is dissolving, it's too much
06:36Trioxinyeah php isn't so bad. I've made good use of it over the years
06:37winkmungojelly: i.e. I think with PHP7 and HHVM it should be a lot better of a standard than many other languages
06:37Trioxinsure some things aren't in the order you'd expect. some arguments
06:38mungojellyi don't understand why any arguments are positional anywhere
06:38Trioxinprobably because you use lisp lol
06:38winksince when is stuff in lisp not positional?
06:39Trioxinidk it was guess. i'm a noob
06:39mungojellyit's terse is the only good thing i can think of for using positions, everything else says use names, much more comprehensible
06:39winkwell if the language has no named arguments..
06:39Trioxinphp documentation is awesome though
06:40winkI mean, python has both. that's probably the best tradeoff
06:40Trioxinso is error output and an IDE will tell you positions
06:40mungojellyroughly equivalent to keywords is to pass in one compound value describing your input
06:40winkthat's still a bad hack
06:40winkthe IDE one
06:41Trioxinyea
06:41Trioxini rarely forget an order though
06:41winkmungojelly: I find that to be verbose and a lot of boilerplate, even if it's just a litt {:foo 3}
06:41ceruleancityyea you can basically achieve what python does by providing your regular positional parameters, followed by an optional map at the end for named parameters
06:41mungojellythat's backwards, the clear version should be the text, and then the ide can help by hiding or emphasizing things, if things exist only in the ide then the text is empty
06:43TrioxinPHP has done some annoying things to me though like I run a CLI script and it seemed to run on just 1 core
06:44winkthat's expected behaviour
06:44winkunless you use pcntl it's singlethreaded. by design
06:45Trioxinmeh
06:46mungojellyi don't feel like i mostly want to be wonking around with the "parameters" to some little function and tuning it to do something, anyway, why is that my job, i'd like to just connect it to something that gives it the right values in the shape it wants
06:46mungojellyi'm always working for the functions, shouldn't they be working for me, do stuff for me functions
06:48Trioxinwould using more cores be pcntl_setpriority()?
06:48Trioxini don't see anything to set the affinity
06:48mungojellyso more concretely with my tile toybox thing i had thought of making something to let you put various stuff in some shape into a grid, but i think instead what i'm going to do is let you build up grids and combine grids, so then you can make a grid with the stuff you want to add and add the whole thing together
06:52TrioxinI'm not seeing how to work with curl in clojure
06:55mavbozoTrioxin, you want to use linux curl from clojure?
06:55mavbozoTrioxin, or you want some kind of http client?
06:55Trioxinwell, I used it a lot in PHP because it had built in curl functions that were nice
06:56Trioxinmade it easy to do like curl_mulithread
06:56Trioxinget and post and set proxies and user agents
06:56mavbozoTrioxin, well, you can use clj-http library
06:56Trioxino
06:56tdammersin my experience, using system libraries from clojure doesn't tend to be the most pleasant approach
06:57tdammersyou're better off using something written in clojure, or, failing that, some JVM lib
06:58noogaI have several functions exposed as methods on a static class for Java users to call them. Now I'd like Java users to be able to pass me a callback function which I could call at any moment.
06:58noogaand I'm stuck
07:00Trioxinclj-http looks pretty good.
07:01Trioxinthe mutlithread thing would have to be coded manually
07:01noncomTrioxin: also, if you want to use cli tools from clojure comfortably, like curl, look at the conch library
07:02noncomTrioxin: as per your last phrase - sort of. thanks clojure is oriented toward very easy multithreading
07:03ceruleancitydoes anyone have any resources on deploying clojure projects? I guess I would just use lein to build an uberjar and then distribute that, is that more or less standard or is there some literature on the topic that’s worth reading?
07:05noncomceruleancity: that's standard... also you can use all these java-exe-packers and other stuff
07:05noncomceruleancity: also, if you care about code obscurity, i guess you have to aot everything and remove sources from the distribution
07:06noncomceruleancity: the class files you get after aot can too be obfuscated by specialized tools
07:06ceruleancitynoncom: I’ve just got a little ring/cljs app that I want to deploy internally so at least for now I’m not too concerned with obfuscation etc. I guess I’ll go with uberjar for now. Thanks for the input
07:08noncomceruleancity: sounds appropriate! but if it is *that* local, you can also simply have it in the form of an uncompiled project to have the ability to easily modify it
07:08noncomceruleancity: just "lein run" inside the project and it'll start working
07:09mavbozoTrioxin, there's also connection-pool option for clj-http https://github.com/dakrone/clj-http#persistent-connections
07:10noncomnooga: let the java users extend the AFn class
07:11noncomnooga: and pass if to you. this will be just an ordinary clojure function. also they can extend IFn but that may seem tantalic, and AFn does some boring stuff for you
07:12noogasounds good
07:16sm0keany suggestion for a programmable template language in clojure?
07:16agarmanhiccup?
07:16clojurebothiccup is both https://github.com/weavejester/hiccup and http://tinyurl.com/426og7n
07:17sm0kehiccup is limited to html
07:17sm0kesomething generic
07:17agarmanclj-template?
07:17sm0keagain html
07:18agarmanhttp://www.clojure-toolbox.com
07:18agarmandig through the template languages there
07:18noogaI'd roll my own :D
07:19sm0kethanks agarman
07:20sm0kecomb is exactly what i want
07:21nooga... implemented in 62 lines
07:23noncomgit status
07:23noncomooops
07:26kramarOn branch master
07:26kramarYour branch is up-to-date with 'origin/master'.
07:26kramarnothing to commit, working directory clean
07:27sm0keclostache is good too
07:27sm0kesome nice extra things
07:28noncomkramar: :D
07:29noncomsm0ke: used it, liked it. also, selmer and stencil.
07:31sm0keI think i will go with comb, only two kind of syntax, and can be used to do anything other projects are doing
07:31noncomyep
07:33noncomthough i found {{this}} much easier on the eyes in big template
07:37sm0kei think you should be able to overwrite it
07:37sm0kelet me just try to overwrite the delimiters in comb's ns
07:39sm0keugh doesnt work
07:41sm0kewth noncom , you got me obsessed with the delimiters now
07:41noncom:)
07:42nooga_maybe because comb is evaling clojure
07:42nooga_and {{}} is like a map with map key and without value for that key
07:43noncomsm0ke: try intern, it allows redefining stuff in other ns, not a very popular practice, but if you really need it...
07:43noncomnooga_: true, i think that's the reason.
07:43sm0keactually redefining is just fine, problem is with the regex he is building with it
07:44sm0kethe (def parse-regex ...)
07:44noncombut OTOH, getting {{}} in the code is very unlikely... if this is in your code, the code is already broken, sooo... :)
07:44sm0keit is throwing error with deleimiters ["{{" "}}"]
07:44noncomit won't hurt much if we break it some more
07:44noncomsm0ke: probably because { and } are special for regex?
07:45noncomsm0ke: try \{\{ and \}\}
07:45sm0kethey are?
07:45noncomyes
07:45noncomhttp://www.fon.hum.uva.nl/praat/manual/Regular_expressions_1__Special_characters.html
07:46sm0keworked
07:46sm0ke(def delimiters ["\\{\\{" "\\}\\}"])
07:46sm0keheh pretty ugly huh
07:46noncomyeah, escaped them once more for the string
07:46noncombut you will not see this, it will just lay inside
07:47TEttinger,(re-find #"[{]{2}[}]{2}" "{{}}")
07:47clojurebot"{{}}"
07:47noncomTEttinger: so, a more radical approach! :)
07:47sm0keyeah i tested it
07:47TEttingerthe curliest of braces
07:47noncomhaha
07:48sm0kenot sure if the author would like it
07:48sm0kei guess i will keep it <% %> way
07:48sm0keas nooga_ also metioned {} could be a map
07:48noncomwell, it's opensource.. :) but yeah, that makes sense and what nooga_ said too
07:49noncombut you just had a little nice adventure
07:49sm0ke:D
07:51oddcullyalso good luck generating lua code with {{...}} ;)
07:52sm0kehurmm
07:53sm0keoddcully: spy much?
07:53sm0keah {{ }} is something in lua too?
07:55sm0kewell <% %> is something in jsp i guess
07:55oddcullyyes, {{1,2,3}} is [[1 2 3]]. and pseudo objects etc
07:55sm0keso yeah everything you pick will be something in some lang
07:55sm0keexcept if you picj #$%^%&#&^#%^#
07:55xtrntrhi, wondering if a newb can get some help
07:55sm0kei guess that would be something too in APL
07:55noncomxtrntr: sure, just ask
07:56xtrntri've done some tutorials in modern-cljs, would like to try running this code
07:56xtrntrhttps://gist.github.com/rm-hull/6857333
07:56noncomsm0ke: rofl
07:56xtrntrin my new project
07:56xtrntrbut i can't find the directory structure in github
07:56xtrntri'm also new to open source
07:57xtrntraside from these 4 scripts, what else do i need to do? find and add the required dependencies in project.clj?
07:57noncomxtrntr: oh, i see
07:57noncomxtrntr: technically, yes, you could do all this manually and more experienced folks here do
07:58noncomxtrntr: but why don't you check out http://www.luminusweb.net/
07:59xtrntrok, i'll try that
07:59noncomxtrntr: this will get you going quickly, jut be sure to add the +cljs flag to the template. and later you can dive in for more details
07:59xtrntryes, that's exactly the learning approach i feel like taking :)
07:59noncomyou can try this and learn, and later ask more specific questions on particular things
07:59noncomcool! :)
08:01oddcullyxtrntr: the files would go in your src/maze dir
08:01oddcullyxtrntr: this code is used from there: http://programming-enchiladas.destructuring-bind.org/rm-hull/6857333
08:03oddcullyxtrntr: from the includes i'd say you should try to get rid of the enchiladas and read that stuff just from your html; jayq and monet are libraries you have to add
08:10xtrntrget rid of the enchiladas and read that stuff from html
08:10xtrntrhmmmm
08:11oddcullyxtrntr: i have not used that. but my impression is, that enchiladas is the framework for that site i linked. so it would provide the canvas, canvas-size etc you see in the :require
08:13xtrntrahh.. it's the person
08:13xtrntrit's the person's custom created framework?
08:19oddcullyxtrntr: yes. your goal is to use these three files in your own project and render the mace on a html page, right?
08:20oddcullys/mace/maze/
08:20xtrntryeap
08:20xtrntri'm looking up the guy's github page right now
08:20xtrntrsome aggressive copying going on
08:20xtrntrHEHE
08:22oddcullyxtrntr: then my rough approach would be: lein new figwheel maze; add jayq and monet to the deps there. add a canvas element in the index.html; put all three files in your src/maze/ dir; remove/comment the :require for enchilada and provide your own def(n)s for them
08:23xtrntrok, i'll try that
08:29lodin_oddcully: Regarding re-frame that we talked about, I figured that the replayability you enable when using pure data (i.e. not event (constantly ...) as argument) is probably really really useful for testing.
08:31noncomafter i upgraged to lein 2.5.2 from 2.5.1 i am getting class not found exception for all my namespaces when I uberjar... how do i fix it, without adding gen-class to each of them?
08:31lodin_oddcully: s/event/even/
08:47visofhi
08:49noncomvisof: hi
08:50xtrntroddcully: this might be a silly question.. but where do i put my main
08:50visofi have a method which return record say it the method called mo and record V, and another map which apply function to this record called xmap, and another func which xmap take to apply on record called fo, i do this (xmap fo (mo v. :hello :world)), how can i use the result of xmap to another xmap and fo ?
08:50visofxmap return another V record
08:51visofi can use iterate
08:51visof?
08:52muhukvisof: have you tried?
08:52visof(iterate #(xmap fo (mo %)) (V. :hello :world)) should be something like this?
08:53muhukxtrntr: if you're using Leiningen, you should put -main in your :main ns defined in project.clj
08:54muhukvisof: yes, if you want to apply mo each time
08:55muhukvisof: this would return a lazyseq, so (nth i (iterate ...)) or something like that to get the result.
10:16TimMcIs there anything in the clojure standard libraries that handles scheduling repeated events, or should I use Executors directly?
10:20schmirTimMc: I don't think there's anything in the standard libraries. I like and use https://github.com/jarohen/chime
10:26TimMcThanks, I'll take a look.
10:34mdeboardWhere is it configured which function will be called when `java -jar /path/to/uberjar` is invoked?
10:34mdeboard(on a jarfile created with `lein uberjar`)
10:38TimMcmdeboard: The -main function of your :main ns.
10:39TimMcOr rather, you can change which ns by changing the :main in your project, and you can change which fn by changing the gen-class statement.
10:39katratxomdeboard: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L189-L196
10:41mdeboardthanks
11:00noncomTimMc: there's also the at-at library (very simple) and quartz (very advanced)
11:00mdeboardIs there someplace I should start looking if `java -jar whatever.jar` doesn't work like executing `(-main)` in the console?
11:01mdeboardbecause `(-main)` does get invoked
11:01noncomand what is it saying ?
11:01mdeboardWell -main invokes this function https://gist.github.com/mattdeboard/ecd0d033d1977bf6da78 which I expect to write data to output.txt
11:01mdeboardand it does, when invoked via the repl
11:02mdeboardit doesn't say anything noncom
11:02noncomhow do you know that main gets called? you get the file?
11:02noncomi mean output.txt
11:03mdeboardNo, I put a println in there
11:03noncomnoncom: okay, and you don't get the file or the console does not exit indefinitely?
11:03mdeboardI don't get output.txt at all
11:03mdeboardwat
11:03noncomyou've already answered
11:04mdeboardAlso the actual operation (moving data from one SQS queue to another) does not happen
11:05noncommdeboard: actually it looks like you have much async code in yout function
11:05noncomfrom your description it looks like it does not work
11:05noncomyou could put println after every like in your function
11:05mdeboardIt works
11:06mdeboardIn the repl, it works fine, so I know the logic is good
11:06noncomyes, but it does not work standalone..
11:06noncomwhy not put a println on every line and see where it actually stops...
11:07noncomwith core.async too much guessing can go into nowhere.. i got in so many strange situations with it..
11:08noncomin a let you can put println after each assignment too, like [_ (println something)]
11:08mdeboardOk that's helpful
11:11TimMcnoncom: I'm just going to go with j.u.Timer. :-P
11:12noncomTimMc: ahaha :)
11:21TimMcI only need one task at a fixed interval.
11:22sdegutisTimMc: what's the question?
11:23justin_smithmdeboard: regarding which function is run, there is also "java -cp my.uber.jar clojure.main -m any.ns"
11:23justin_smithmdeboard: as long as any.ns has a -main, it will run that
11:23justin_smiththe cool thing, is that does not even require gen-class or aot compilation, which eliminates about a dozen headaches
11:25noncomsdegutis: a scheduling lib
11:25justin_smithTimMc: at-at is a pretty thin wrapper on j.u.Timer
11:25mdeboardjustin_smith, I just wanna know under what circumstances running the uberjar would behave differently than executing the -main function from the repl
11:26justin_smithTimMc: (which depending on your criteria can mean a yes or no of course)
11:27noncomsdegutis: i too, long in a search for a clear, thin and versatile scheduling lib.... chime uses core.asyc, quartzine is too monstrous (it's a wrapper over monstrous quartz), and at-at has proved the most clojuric and thin, although it has some lack of something, i don't remember exactly...
11:29sdegutisSorry, what's a scheduling lib's purpose?
11:29sdegutisI don't quite know what this terminology is about.
11:30noncomsdegutis: to like make certain things run on certain time/date or for a certain period and stuff
11:30noncomsdegutis: like calendar for tasks
11:30justin_smithnoncom: someone should make the scheduling version of gfredericks 's seventy-two lib. It would be a scheduler and you hand it a function and it will call your function at 4:20 pm every day
11:30sdegutisSo like cron but specific to Clojure?
11:30gfredericksjustin_smith: it's called seventy-one dammit
11:30justin_smithtotally non-configurable, that would be the only thing it would do
11:30justin_smithgfredericks: oops
11:30sdegutisWe just use cron so I'm a bit confused why one might not want cron.
11:31justin_smithsdegutis: ever try running a task two minutes after the hour every hour with cron?
11:31justin_smithI mean I know it is possible but it's weird
11:31justin_smithalso we are talking scheduled tasks inside a long running vm here
11:31noncomwow! a genius lib!
11:32sdegutisjustin_smith: iirc that's one of the easier timings to express with cron?
11:32noncomi also found this: https://github.com/AdamClements/schejulure
11:32sdegutisOh, inside a VM.
11:32justin_smithsdegutis: I didn't think it was, but OK, once every 38 minutes and 17 seconds then
11:32noncomsdegutis: well, yes, the point is to run the schedule inside your app for various things
11:33sdegutisjustin_smith: hmm yeah we use Thread/sleep for that
11:33sdegutisjustin_smith: 38.17 is even easier iirc
11:34justin_smithsdegutis: the idea with a scheduling lib is you get the ability to look at your timed tasks, cancel them, change the timings if you need to, etc. - a lot more control than you get with a looping thread doing sleep calls
11:36sdegutisOh neat.
11:36sdegutisSounds like it could be useful in some cases.
11:36sdegutisI wonder how many cases I have where it would be useful but I haven't thought if it that way yet so I haven't connected the dots...
11:37Oberif I want to pretty print a stacktrace, what should I convert to line returns?
11:37justin_smithalso, " the sleep period can be terminated by interrupts, as we'll see in a later section. In any case, you cannot assume that invoking sleep will suspend the thread for precisely the time period specified" - a proper scheduling lib should have stronger guarantees than this
11:38justin_smithOber: you could check out aviso/pretty for an existing project that attempts to do this
11:38mdeboardI figured out the problem. It's that the jvm process terminates thus killing the threads I had going lol
11:38mdeboardcomputing is hard when you're dumb
11:40noncomchronno: o_O
11:40noncomooops
11:40noncomthat was for mdeboard :)
11:40mdeboardyeah I switched to >!!, alts!! etc. and it works fine.
11:43mungojellyso writer-m is a writer monad implementation, but we don't use it mostly? does that implementation suck, or is that an intentional style choice, or ar we too scared of the m-word?
11:44Oberjustin_smith: stuck doing this outside the jvm
11:44justin_smithmungojelly: I think the general perception (right or wrong), is that monads are a lot less useful without strong typing
11:45justin_smithOber: oh, and you are just getting raw unformatted stack traces?
11:45mungojellyjustin_smith: how does typing help? i mean especially, it seems to me like it just helps you not get your connecitons miswired like anywhere else
11:45justin_smithmungojelly: it's that monads help with keeping things typed
11:46justin_smithhaskell wants strong typing, monads help them achieve that
11:46mungojellyyes haskell forces you to. is it that nobody uses monads unless they're forced to? :D
11:47justin_smithmungojelly: there's that, and the clojure compiler is not a clever compiler like haskell's is, monads in clojure are slow
11:47mungojellyi just want to make things that log and write data and stuff but i don't want to just say "write data!" with no way to constrain the flow, what a mess.
11:48justin_smithmungojelly: I think a more idiomatic solution to that would be a core.async go block getting things to write from a channel, or a looping thread that gets things to write from a queue
11:48mungojellyis there a different way i should inject that dependency, like have my things ask to have a writer injected into them
11:49justin_smithbut maybe monads are the right way to do this, I just know they aren't very popular, I gave up on them pretty quickly when I was trying them
11:49lodin_justin_smith: With strong typing, do you mean purity?
11:49justin_smithlodin_: well, purity is part of strong typing, but a lot of haskells usage of monads has nothing to do with side effects
11:49mungojellywhatever, everything's monads whether anyone says that or not, it's just an explicit monad-monad has maybe more general algorithms you can use on it, but not really because no one writes monad algorithms because no one uses them so w/e
11:50lodin_justin_smith: I'm trying to understand what you meant with monads help with keeping things typed.
11:50justin_smithmonads are a convenient way to "lift" code to different datatypes without having to do a lot of boilerplate, but we can ignore that aspect in clojure because we are looser about types
11:51lodin_justin_smith: Not really. We run into problems when we want to write abstractions that make use of return/pure, because we don't know the type.
11:52lodin_Like sequence with haskell type [m a] -> m [a]. If the list is empty, how do you construct the return value? You must pass in info explicitly.
11:53mungojellyi vaguely feel like metadata could let you do monady things to data while letting naive functions participate without knowing what's happening
11:54justin_smithmungojelly: if functions were disciplined about returning values that preserved the metadata of their input, maybe
11:54justin_smithgood luck finding functions that do that
11:54mungojellychannels feels nice though, yeah that's looser in a clojurey way, wait um what's the jointing with channels, do they have names or you need specifically handles to them?
11:54mdeboardI think justin_smith 's point is that there are other idioms for transforming/processing data in Clojure, and that monads are a mismatch without strong typing.
11:54justin_smithmungojelly: they are values
11:54mungojellyjustin_smith: oh i thought if they didn't pay attention they'd just pass it through :(
11:56justin_smith,(meta (with-meta (range 10){:a 0}))
11:56clojurebot{:a 0}
11:57justin_smith,(meta (map inc (with-meta (range 10){:a 0})))
11:57clojurebotnil
11:57justin_smithmungojelly: sad but true
11:58lodin_Monoids suffer from the same issue, btw, due to the identity element.
12:02mungojellywith a monad i get an abstraction over the side effects, with channels i get spatially removed from them, whatever, i'm happy as long as i don't have to actually like make concrete decisions about things i don't care about :)
12:16luxbockhttps://groups.google.com/forum/#!topic/clojure/wccacRJIXvg
12:17luxbockthere's some discussion on why monads are not so much used in Clojure
12:21visofhi guys
12:21mdeboardluxbock, nice link
12:26noncomvisof: hi!
12:29visof'm trying to draw white and black boxes based on returned result, returned result is list of lists, each inner list has true or false values, what i do is simulate this using quil, each list represent new line, https://gist.github.com/aibrahim/1286ce58b1e7d085ff9e
12:30visofthat's my code, i need to change this line (q/rect 0 0 20 20) which contain 0 0 for x y positions, so i need updated values
12:30visofto not overwrite to this position
12:30visofhow can i achieve this
12:30visofres has lists of lists
12:30visoflist* of lists
12:31noncomi'd iterate over ranges
12:32visofnoncom: ah step by 20 for y as example and iterate over it
12:32noncomwait, i'll write an example
12:32visofok
12:33noncom(let [lst (get-list)]
12:33noncom (doseq [y (-> lst count range)]
12:33noncom (doseq [x (-> (nth lst y) count range)]
12:33noncom (let [value (get lst x y)]
12:33noncom ; bool-fill logic here
12:33noncom (q/rect (* x cell-size) (* y cell-size) cell-size cell-size)
12:33noncom ))))
12:33noncomsomething like this
12:33noncomyou have to stick to indexes to get coordinates
12:35noncomsorry, the [value (get lst x y)] should be [value (get-in lst [x y])]
12:37noncomooops. get-in does not work for lists that wy!
12:37noncombut that's a minor thing, use (nth) or produce the sequences as []s, not ()
12:38noncomvisof: ^
12:38noncom,(get-in '(1 (1 2) 3) [1 1])
12:38clojurebotnil
12:38noncomhmmm, now i wonder, why does it not work with lists? does anyone have an explanation?
12:38mungojellyi'm so sick of (* x cell-size) (* y cell-size) cell-size cell-size, that's just the boilerplate i want to write away with my tile toolbox, so i can play with tiled things without ever writing x*size y*size ever again phew
12:39noncommungojelly: right! i remember you were after saving us from this
12:39noncomi program quil and other tiling things too, i am so sick of this too
12:40mungojellyi don't understand why every one of those things doesn't come with a tile abstraction already, it's what everyone writes first when you start using them
12:40noncoma good excersize, maybe :D
12:40noncombut i am sure there are grid libraries for processing
12:40noncomor maybe not :/
12:40mungojellythere are things but they're so heavy
12:41mungojellylike i found something i thought might be useful in clojure but it was a whole thing intended for dealing with geospatial data, seeing whether basic little squares intersected was in there somewhere i think
12:42noncomhahah :) well, you well have the chance to create *the* tiling library
12:43mungojellyhere's something i don't understand yet, my format goes like {:grid {[0 0] :name-of-tile} :tiles {:name-of-tile {:attribute "stuff about tile"}}} and i realized that i was assuming the [0 0] would always be integers
12:44mungojelly(a) what do i say to ensure it's always integers there, is it that defrecord thing, or some guards or something? (b) do i have to? if i incrementally enforce that later will that be just as good
12:45noncommungojelly: imho (a) you can use the prismatic schema library for that (b) i would not restrict it to ints
12:46noncomfractional indexes could be interesting since in this implementation as i see, position of a tile is bound to its index, but what if i want to manipulate with tiles and place them on fractional positions?
12:47mungojellyyeah i'd also considered that, sure yeah why not leave it so you can do that if you want
12:47noncomlike, i want to begin my game with a whirld wind of tiles, which them settle to form my field
12:47noncomyeah
12:48noncomthe tile-data extracting functions, however, will take integer indexes and use (nth) to get the positions
12:48mungojellybut i guess what i'm thinking is i'd like to make more than one client implementing viewing the tiles, and i was just imagining implementing the simple case of non-overlapping even square tiles there
12:49noncomstill i don't see why restrict, or why a viewer could not handle it by itself...
12:49noncombut, sure it's up to you :)
12:50mungojellyi'll think about it, that's very helpful advice thanks :)
12:50noncomlike, modern monitors (viewers) take care of lighting up proper pixels, and the programmer does not think of this when he writes graphics - even if the resolution does not fit at all, for example
12:50noncom:)
12:53mungojellyhmm i think that's maybe another different problem we solve repeatedly because it's too simple to simplify: x y positioned sprites with bounding boxes or some other basic collision detection, for making bouncy rooms (:
12:54mungojellyso there's an obvious abstraction above both of them of generic "x y positioned thingies" i guess i should make just that
13:10mungojellya very nice algorithm just popped into my head but i'm not sure i could even pseudocode it, um, i imagined things that paint themselves and then making a collision box out of that and then ask which cells it would intersect in a square grid so you mark those as used by that shape, like if it's a tetris L block it blocks off those four squares, hmm and then you could take some shapes and ask what size g
13:11mungojellyrid would be most harmonious with them
13:11justin_smithmungojelly: something like this is done with quad-trees if I understand you correctly
13:11justin_smiththe more uniform your shapes (or the more rough your outline determining rules) the simpler this is
13:12mungojellycool quad-trees are new to me, yeah looks sorta like what i was thinking, yeah i was vaguely imagining some algorithm that'd shrink wrap the boundaries of something and that'd do :)
13:15winkmungojelly: http://www.gamasutra.com/blogs/AAdonaac/20150903/252889/Procedural_Dungeon_Generation_Algorithm.php interesting read maybe?
13:15winkmungojelly: sounded a bit like what you just described
13:16winkthere's also http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/ but that's a little different
13:17mungojellywink: ok yay thanks looks fun :)
13:23mungojellyugh i hate how x and y are ambiguous, is there any possible way i can give an interface to horizontal and vertical position that's not confusing
13:24mungojellyhow about if it's n-dimensional and you can name your dimensions yourself, bring your own dimension
13:24justin_smithmungojelly: that reminds me, I was going to write a js lib, one.js, which would specialize in rendering a line
13:25justin_smithfollowed up by zero.js, which would display a pixel
13:25mungojellyok good sounds useful
13:25justin_smith3.js and two.js worked out pretty well, so why not
13:27mungojellyi'm going to look at how they do x and y ing and zing and see if it helps me think about it
13:28mungojellyi just always feel like-- i don't care where. i want an orange circle. i want it located-- somewhere i can see it!? that is all. purple circle pls. shouldn't giving exact coordinates of things be optional. why are we always on the star trek bridge.
13:49ambrosebsBronsa: taj thinks this is reflective (fn [^Number x] (pos? x))
13:49ambrosebsany idea what's happening?
13:52ambrosebsBronsa: afaict validate isn't doing a subclassing test
13:52ambrosebspos? expects an Object, but we're giving it a Number
13:53ambrosebsclojure.lang.Numbers/isPos rather
13:57Bronsaambrosebs: I'm taking a look now
13:58BronsaI just had cider consume 12gb of ram starting up the clojure process btw :|
14:01Bronsaambrosebs: I don't get any reflection
14:01expezBronsa: I've never heard of such obscene resource usage. I'd appreciate it if you opened an issue if you see this again :/
14:02Bronsaexpez: no idea what happened, I managed to kill the process & restarted it and it's fine now
14:06abox0Hi how do I make a function that takes in a variable number of arguments and then prints them? I tried this but it didn't work:
14:06muhukAre there any good reasons to add infix ops to lisp, other than unfamiliarity of newcomers? (I can't think of any.)
14:06abox0(defn printargs [& args] (apply print '(args)))
14:07muhukabox0: try replacing '(args) with just args
14:07abox0neat thank you lol
14:08Bronsaambrosebs: clojure.tools.analyzer.jvm> (-> (analyze '(fn [^Number x] (pos? x))) :methods first :body :validated?) ;=> true
14:08Bronsa
14:12abox0clojure is so cool
14:14sotojuan^ true
14:14sotojuanI wanna make something with clojure but i cant think of anything :'( so just doing project euler and sicp
14:16mungojellywe should do some fun group project
14:17sobellearn how to interface to java so you can use it at work
14:17sobelnot just interop syntax but know it from the angle java-not-clojure devs will see it
14:19mungojellyi'm apparently like the only person in all of programming who likes to have any fun, i'd like to just make something fun and silly
14:19mungojellyi think it's confused how beginners always say they don't know how to make anything, they do know how to make things but no one's respecting and working with what they know how to make
14:19sobelmy sense is, do something moderately ambitious
14:21sobeli wish i had clojure when i was learning 20 years ago. :)
14:22mungojellyno one ever makes anything without a particular purpose in mind, can't we ever just make anything for fun? then it's easy. one person makes some random interesting sequences, the next person turns those into colors, the next person throws the colors up on the screen, now interesting beautiful things are happening, not everything needs to be planned
14:23blake_mungojelly: I've been too busy but I'd like to flesh out/revamp "The Caves of Clojure".
14:23sobeleh, it's programming, but there's still such a thing as planning
14:24sobeli mean, start something and accept a lot of pull requests?
14:24mungojellyi don't deny that in general planning is useful to accomplishing tasks. why is everything so absolute!? i just mean, ever, we could set that down and have fun, ever, for a moment.
14:24sobeli think the add-on concept you're getting at can be facilitated if you build the right foundation.
14:28mungojellyis there a standard for what to use for colors? oh do we just use some standard java colors?
14:29sobel...
14:29sobeljava didn't invent color
14:30sobeli recognize a lot of your questions from my own topic-bucket i call, "this project needs more domain expertise"
14:30mungojellywell as i understand it we just reuse java abstractions here unless they're too crappy to work with so as to maintain compatibility with the java layer
14:30sobeli like programming but there's also other topics
14:31sobelok, it depends on the value of reusing a java class
14:31sobelthere are pros and cons
14:31sobelsooooo...ahunno. you gonna build something for programmers?
14:31mungojellya "color" is just three bytes with an optional alpha byte basically, but there's a zillion interfaces to that
14:32sobelplease don't build a better Color class
14:33mungojelly,(partition 3 (take 30 (iterate inc-mod-256 73)))
14:33clojurebot#error {\n :cause "Unable to resolve symbol: inc-mod-256 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: inc-mod-256 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: i...
14:34mungojellyoh right i defined that sorry
14:34mungojelly,(partition 3 (take 30 (iterate #(mod (inc %) 256) 73)))
14:34clojurebot((73 74 75) (76 77 78) (79 80 81) (82 83 84) (85 86 87) ...)
14:35mungojellyhmm looks grey
14:37mungojellyit's not that that doesn't exist or that beginners can't make it it's just that a program that gets partway to making a stream of greys doesn't count to us somehow as a program at all and we make no space for it
14:41mungojellyi think rather than saying "good for you, maybe someday you'll make a real program" a better response would be to write the line that turns it into Color objects and go along from there playing with fun things
14:45mungojellyhow about functions from epoch time to rgb colors, you could easily mod the ticks to make stuff throb, or also you could program things for particular absolute times/patterns
14:45sobelok, but i'm not that interested in finishing someone else's code
14:45sobeli want to see a whole idea. that appeals to me.
14:46mungojelly"finishing" implies a goal, what if we just made something by adding part by part and seeing what emerges
14:54mungojellywow cool https://github.com/jolby/colors has some really awesome palette generators! usually you just get smudging from place to place, this is way better :)
15:10mungojellyit's always the same interface to colors and it's always a brighter and darker that brighten and darken a random hardcoded amount. it's both too concrete and too abstract. what would it hurt to have something that makes things a little darker and a little bluer, or a little brighter and a little pinker, you never get anything fun, but "brighter" is boring enough it gets in even though it's hella vague.
15:10xeno_what's the shortest way I can generate a list of readable symbols, like '(:a :b :c ... ?
15:10xeno_or stream or whatever
15:11snowellxeno_: From what?
15:11xeno_from nothing
15:11xeno_start at :a :b and then continue, and when reaching :z then maybe :aa :ab ...
15:11snowellYou'd probably write a function that generates strings in the format you want
15:12snowellAnd then apply keyword to its results
15:12noncomxeno_: you can cast a int into char and then (keyword "string") to get :string
15:12noncomxeno_: also there's clojure.core.generators
15:12snowellOh yeah, that works too
15:12noncomclojure.data.generators, sry
15:12J_ArcaneClojuTRE 2015 talks are all online on Youtube now! https://www.youtube.com/playlist?list=PLetHPRQvX4a_tA9hGP935-OyLOYaRKpnj
15:12snowell,(apply (comp keyword str) (range 5))
15:12clojurebot:01234
15:12snowellEr
15:13noncom,(apply (comp keyword char) (range 5))
15:13clojurebot#error {\n :cause "Wrong number of args (5) passed to: core/char"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (5) passed to: core/char"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 48]\n [clojure.lang.AFn applyToHelper "AFn.java" 171]\n [clojure.lang.AFn a...
15:13snowell,(map (comp keyword str) (range 5))
15:13clojurebot(:0 :1 :2 :3 :4)
15:13noncom,(map (comp keyword str) (map char (range 5)))
15:13clojurebot(:
15:13noncomwow!
15:13dbasch,(map (comp keyword str char) (range 97 102))
15:13clojurebot(:a :b :c :d :e)
15:14snowelldbasch getting all fancy on us :)
15:14noncom:D
15:14noncombut i can make clojurebot smile now!
15:14noncom,(map (comp keyword str) (map char (range 5)))
15:14clojurebot(:
15:14noncomit wokrs!
15:14mungojellyaw you found what makes it happy (:
15:15lumanull chars, apparently
15:15mungojellynull characters make me happy too clojurebot (:
15:15noncom,(print "i'm so happy :)")
15:15clojureboti'm so happy :)
15:16noncom,k
15:16clojurebot1
15:16noncom,*out*
15:16clojurebot#object[java.io.StringWriter 0x556a7dc1 ""]
15:17noncom,(def sw *out*)
15:17clojurebot#'sandbox/sw
15:20TimMc_Apropos of a conversation the other day, here's some code I just wrote that *does* make use of a mutable inside an atom.
15:20TimMc_https://gist.github.com/timmc/6df394983a24817ca3e3
15:25sobelnice
15:26justin_smithTimMc: interesting
15:26justin_smithTimMc: what happens when two start-timer calls are concurrent?
15:28justin_smitheg a -> start timer (1) b -> start timer (2) a -> retry, because there was a conucurrent call, cancelling (2) and starting (3)
15:29justin_smithend result, timers 1 and 3 are both running, right?
15:29amalloyjustin_smith: also possible: a timer is cancelled twice
15:29justin_smithdepending on the timer b might stop (1), but we can't count on it
15:30justin_smithamalloy: oh, yeah
15:30justin_smith*depending on the timing
15:30amalloyyou really have to swap a delay of the value, rather than the value itself, if you must avoid duplicate work and/or concurrent realization
15:30amalloybut then you're really just reimplementing a mutex, so...you can just use locking
15:32justin_smithamalloy: from the doc for TimerTask "This method may be called repeatedly; the second and subsequent calls have no effect." so the double cancel shouldn't be so bad (though it's sloppy)
15:32justin_smitherr, doc for the cancel method on TimerTask
15:35amalloyjustin_smith: well, it happens to correlate 100% with the cases where two competing timers are started
15:35amalloyor...i guess if there were a race the very first time you start a timer, there could be two starts without a double-stop. you win
15:36justin_smithamalloy: concurrency is weird and I am often wrong about it, it's not about winning, just figuring out how these things work
15:37amalloywell, of course. but adding a few more winners rarely disrupts a situation
15:37justin_smithheh
15:46TimMcOh yeah, could end up with a double start, hmm.
15:47justin_smithanother option is an agent, agents don't do that restart thing, they lock instead
15:48snowell,(for [i (range 10) :while (not= i 5)] i)
15:48clojurebot(0 1 2 3 4)
15:48snowellIs there a variant that would give me those results, but WITH the 5 included?
15:49snowellSo less of a :while, and more like… :until or something
15:49snowell:including-when :)
15:50oddcullyinc 5?
15:50justin_smiththat doesn't generalize though
15:50dbasch,(for [i (range 10) :while (<= i 5)] i)
15:50clojurebot(0 1 2 3 4 ...)
15:51snowellWell I'm using simple sets and functions for sake of ease
15:51snowellIn practice, I'm generating a sequence of Java objects :)
15:51justin_smithdbasch: my interpretation (right or wrong) was the general question of "get items until a condition is met, including the item matching the condition"
15:51snowelljustin_smith: Exactly
15:51snowellI'm porting over a Java for loop with a break in it
15:52justin_smithsnowell: my translation of a for with a break would always be a reduce / reduced
15:52snowellA for loop that (as a side effect) generates an object
15:53dbaschsnowell: just use a loop and an accumulator
15:53justin_smith,(reduce (fn [acc el] (if (= el 5) (reduced (conj acc el)) (conj acc el)) [] (range))
15:53clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:53justin_smith,(reduce (fn [acc el] (if (= el 5) (reduced (conj acc el)) (conj acc el))) [] (range))
15:53clojurebot[0 1 2 3 4 ...]
15:53justin_smithclojurebot, there was only one more item in that stupid vector :P
15:53clojurebotCool story bro.
15:54snowellHahaha maybe the most appropriate clojurebot response I've seen yet
15:55justin_smithsnowell: anyway, try it yourself, it stops at 5 and includes 5, generalizes to imperative cases where unexpected chunking would cause bugs if you were counting on laziness for side effects
15:56snowellI'll try that indeed. Did not know reduced
15:58amalloyjustin_smith: where chunking of the *output* would be an issue, this helps. if the seq you are reducing is already chunked you are too late
15:58justin_smithamalloy: oh, I was talking about side effects inside the reducing function - of course if your lazy source has side effects you count on then chunking is still an issue, yeah
15:59justin_smithbut in general lazy-seqs are like polka dots and plaid anyway
15:59justin_smitherr, lazy seqs and side effects
16:03Tagore_err- maybe coming in late here, but... how are lazy seqs like polka dots and plaid?
16:03Tagore_I mean, not as pretty as it is in Haskell, where that's just the normal thing and you do't have to think about it, but...
16:04Empperiwtf, polka dots?
16:04Tagore_Surely not eye-searingly ugly either, right?
16:04Empperilike this lol? http://i671.photobucket.com/albums/vv76/nicoledanielleadams/2012/christmas/meow026_zpsc3e1e05d.jpg
16:04mungojellythe way they don't match with side effects, he was saying
16:04snowellWorks like a champ, justin_smith
16:05snowell(inc justin_smith)
16:05snowellOr lazybot is dead again. You're inc'd in my heart
16:07Tagore_He'll be inc'd when necessary.
16:08snowellSounds like he's getting a tattoo
16:09arrdemdamn lazy bots always sleeping on the job
16:14snowellI feel like I still haven't had the AHA moment I need to with reduce
16:14snowellMy head still refuses to wrap itself around what it's doing
16:14snowellI feel like it'll be the same as when map/apply clicked
16:15mungojellyreduce is kinda infix
16:15mungojellyidk it feels to me like putting the operation inbetween what you feed it
16:16justin_smithsnowell: reduce is like a factory assembly line - the kind where sometimes you break something up into smaller pieces, and sometimes you combine pieces into a unit, but either way you are not limited to one output unit per input unit
16:17mungojellyit's like a little bot you set down at the first value and say, go along and do this over and over until you get to the end, and it tottles along bloop bloop until they're all done
16:17justin_smithmungojelly: that's general enough to describe map or iterate too
16:17mungojellyhow when do you break something up into pieces in a reduce
16:18justin_smith,(reduce into [] [[1 2 3] [4 5 6]]) ; mungojelly: trivial example
16:18clojurebot[1 2 3 4 5 ...]
16:19justin_smithit's still only returning exactly one thing, like everything in clojure always
16:19justin_smithbut the inner structure is broken up
16:19mungojellyoh so that's what "into" does. and a transducer may be supplied, i'm going to watch that transducers talk again and maybe that'll seem useful.
16:20justin_smithtransducers are a really cool generalization of reduce (or at least that's one way to approach them)
16:23justin_smithmungojelly: also I didn't need the initial coll with that one
16:23justin_smith,(reduce into [[1 2 3] [4 5 6]])
16:24clojurebot[1 2 3 4 5 ...]
16:30mungojelly,(reduce into [[1 2] [3 4 [5 6]]])
16:31clojurebot[1 2 3 4 [5 6]]
16:31mungojellyhow to squish it recursively then?
16:31justin_smithreduce might not be the best thing for that, once you want recursive operation
16:31mungojellyyes i see what you're saying, i don't have the vocab to make much go through it, but you can build things up, work with that, break it down, partition it differently, work with that for a while, etc
16:32justin_smithyeah - mainly this is in contrast to eg. map which is exactly one-for-one, or iterate, which is strictly result following result from a single initial value
16:32sobeli still mean to do more than hello-world with transducers. i have an application in mind but no time to refactor it.
16:32justin_smithunlike those, reduce has more power over the shape of its output
16:34mdeboardjustin_smith, You inadvertently gave the only explanation for what a monad is I've ever understood
16:34justin_smithhaha, when?
16:34mdeboard'monads are a convenient way to "lift" code to different datatypes without having to do a lot of boilerplate'
16:34mdeboardOr rather,
16:34justin_smithoh, yeah
16:34mdeboardyou gave a good explanation for when you'd use them
16:34mdeboardWhich is just as good.
16:34mdeboardMaybe better
16:34justin_smithmdeboard: I'll make a point of mentioning mexican food next time
16:35mdeboardSome kind of astronaut eating a burrito or something?
16:35mdeboardMonadsplanations are frustrating because it's like the Clojure doc for `alts!`: It only makes sense after you've blundered your way through to understanding what `alts!` is used for
16:36mdeboardSurely there's a term for "an explanation of a thing that requires an understanding of the thing sufficient to not need the explanation"
16:36justin_smithmdeboard: right, I'm a fan of Heinz Von Foerster (pioneer of cybernetics) who said that the meaning of a word is actually an action plan - it's the orientation to the thing you do with the named object
16:37justin_smithmdeboard: that insight leads me to making better definitions :)
16:37mdeboardyes!
16:37mdeboardExactly, wow that hits on something I have tried to articulate so many times
16:37justin_smithhe's a brilliant guy, invented a lot of things we use all the time
16:37justin_smithor at the very least, helped us understand them much better
16:38mdeboardAlso maybe at the heart of why I need to actually do a thing to understand it. Experiential versus didactic learning
16:39mdeboardjustin_smith, Is that quote on this page? https://en.wikiquote.org/wiki/Heinz_von_Foerster
16:39justin_smithmdeboard: I'll check, I forget the source and the exact words..
16:40mdeboardYeah I C-f'd for a few different words and came up dry, figured you've probably synthesized the actual quote into something else over the years :)
16:40justin_smithwell, the original was in German, and might have been from a subtitled video I watched or something...
16:40mdeboardgotcha
16:40mdeboardI'll just pass it off as your quote
16:41justin_smithhaha
16:41sobelpossession is 99% of the law
16:41mdeboard"'The meaning of a word is actually an action plan -- it's the orientation to the thing you do with the named object.' - Werner Herzog" - justin_smith
16:42justin_smithmdeboard: I think the Louis H. Kauffman one comes close- and now I am recalling a paper name "Objects as EigenBehaviors"
16:42justin_smithI actually met Kauffman, very smart man
16:43justin_smithmdeboard: http://www.univie.ac.at/constructivism/journal/special/second-order/material/kauffman-2003-eigenforms.pdf
16:44justin_smith"This essay is a discussion of Heinz von Foerster's concept of an eigenform, wherein an object is seen
16:44justin_smithto be a token for those behaviors that lend it (the object) its apparent stability in a changing world."
16:45sobeli was wondering how long it would take to hear a little Buddhism here
16:45sobel;)
16:46justin_smithTo anyone who thinks this is off topic - clearly this is espousing functional programming: "Forms are created from the concatenation of operations upon themselves and objects are not objects at all, but rather indications of processes."
16:46sobeli think it's absolutely on topic
16:49mavbozojustin_smith could make a clojure conj talk about functional programming and monads using Heinz von Foerster as the hero of the talk
16:49mdeboardThere's something to be said about documentation that explains "when would I use this" along with "what is this"
16:51justin_smithmavbozo: if only I had the initiative, I bet I could...
16:52mdeboardThere are wonderful drugs that will give you initiative
16:52mdeboardtemporarily, anyway.
16:52justin_smithheh
16:53sobelAnd still others that will make you want to dance
16:53sobeloh wait, wrong channel
16:53mdeboardI think I have to anchor an explanation of a thing in a use case
17:12sritchieoh man, just have to say it - Ambly and react native is a badass combo
17:13sritchieanyone here played with this stuff yet on a phone, vs just the simulator?
17:13sritchiewas curious about the white screen on startup, and if it matters, really, once you use advanced compilation
17:22dnolensritchie: isn't that something you fix by adding a loading screen?
17:22dnolensritchie: mfikes could probably answer your questions. There's seems to be a growing number of people using Ambly + React Native.
17:22sritchieafter the splash screen? yeah, I guess you add a view controller that transitions when the JS is done loading.
17:23sritchieI’m building up an app prototype, would love to use Clojurescript, but also thinking of just going straight react native for the first version to get a little variation in my diet
17:24dnolensritchie: wasn't aware that loading the JS took any significant amount of time, but that's probably a question for someone else to answer
17:25sritchiethere’s a short, intermediate white screen before ambly takes over from react: https://github.com/omcljs/ambly/wiki/ClojureScript-React-Native-Quick-Start#try-it-out
17:31dnolensritchie: yeah dunno, you're more likely to get answers in #clojurescript I suspect
17:44dumbintelHow can I make a vector of LazySeqs into a Vector of Maps? i.e. [({})({})] into [{}{}{}]?
17:58oddcully,(reduce (partial apply conj) [] [[{:A 1}{:B 2}][{:C 3}]])
17:59clojurebot[{:A 1} {:B 2} {:C 3}]
17:59dumbintelNeat!
17:59dumbintelThanks.
18:00oddcully,(mapcat identity [[{:A 1}{:B 2}][{:C 3}]])
18:00clojurebot({:A 1} {:B 2} {:C 3})
18:00oddcullydon't use it until one of the pros approve ;)
18:03dumbintel,(reduce (partial apply conj) [] [({:a 1}{:b 2})({:c 1})])
18:03clojurebot#error {\n :cause "Wrong number of args (0) passed to: PersistentArrayMap"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (0) passed to: PersistentArrayMap"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 28]\n [sandbox$eval73 invokeStatic "NO_SOURCE_FILE" 0]\n ...
18:03justin_smithdumbintel: you probably want to quote those lists (or maybe use vectors instead)
18:04amalloydnolen: (partial apply conj) is just a less-optimized into
18:04amalloyoh, not dnolen
18:05amalloywow, i can't read at all. oddcully
18:05justin_smithamalloy: except apply conj can take one arg
18:05amalloyerrr, i don't think i understand
18:05dbaschapply concat seems to be what dumbintel wants
18:06amalloydbasch: maybe. reduce into [] is good pretty often too
18:06justin_smith,(apply conj [[:a :b :c] :d :e :f]) ; amalloy
18:06clojurebot[:a :b :c :d :e ...]
18:06dbaschsure
18:06justin_smithamalloy: I guess that can be into, if you wrangle it a bit
18:07dumbinteljustin_smith: The problem is when I'm creating the vector I'm basically taking an xml file, reading each portion and trying to construct a map of the form [{:name {:item1 thing1 :item2 3} :name2 {:item1 cookie :item2 snack}}] for some reason i get nil's which I filter out and I end up with Lazy Seq's so they look like [ ({{}{}})({{}{}})]
18:08justin_smithdumbintel: right, but you can't just type in lazy-seqs like that, that's all I was saying
18:08justin_smiththe parens become function calls
18:08dumbintelahhhh
18:09amalloydumbintel: generally you can't take the output that a repl prints, and paste it back into the repl
18:09amalloyyou need to add a quote to it, to prevent evaluation
18:10dumbintelgotcha, didn't think that through when I tried using the bot.
18:11dumbinteleither way I have new ammo to try out. Thank you
18:35oddcullyamalloy: ah so true
21:22noncom|2in korma if i have an existing SQL table with fields, say "name", "address", "code", then do i have to specify them like (defentity users (entity-fields :name :address :code)) ?
21:40diminishedprimeAny tips/resources for good testing of macros?
21:47noncom|2diminishedprime: there are macroexpand and macroexpand-1 functions... some articles in the internet here and there... but only practice will give understanding
21:48diminishedprimeI'm decently familiar with macros in general, but I'm new to Clojure. I'm having problems in particular with testing a macro that throws an exception if not passed a symbol.
21:49diminishedprimeWe're wanting to enforce it there, because the macro is a definition of part of a dsl we're putting together for some business folk.
21:51noncom|2diminishedprime: so, you want to check exactly for what?
21:52noncom|2one of the arguments is a symbol?
21:53diminishedprimenoncom|2: I got the macro working, but the tests fail. I put macroexpand-1 and the macro inside of a try catch block, but it seems like the exception is being thrown during compile time.
21:53noncom|2diminishedprime: quite probably
21:53noncom|2can you show the code and tell me what you're expecting?
21:53diminishedprimeI sorta worked around it using read-string to put that off, but that seems like a hack.
21:54noncom|2btw, just today was reading on teh music theory tl;dr guide about the diminished chords :D i know that it is a joke about the prime, but what a coincidence!
21:55diminishedprimeI don't have the exact code with me (It's on the work computer), but I also don't have erc access at work. Nice catch-22 there. Let me see if I can get the general idea scratched out.
21:55noncom|2yes, try to make up an example
21:55diminishedprimenoncom|2: ahh exciting. I do love me some music theory. ALso you win an award for being the first to comment on the music joke.
21:55noncom|2cool :)
22:07noncom|2diminishedprime: how's it going?
22:10diminishedprimehaving some issues, but getting there. I got the macro re-written out, but I'm still a newbie at getting things required in correctly so I haven't been able to pull in thrown? from clojure.test
22:12noncom|2oh, you're using clojure.test?...
22:12noncom|2did not think that was necessary, but ok
22:12diminishedprimeYes. Is there a better framework to use?
22:13noncom|2well, there are "better" test frameworks, although many folks claim that they need only (assert) so what could be better...
22:13noncom|2i simply don't use any, so don't listen to me on this one :)
22:13diminishedprimeWell here's the macro. It works like expected, but issues arise when I'm trying to test it.
22:13diminishedprime(defmacro macro-with-symbol [symbol & forms] (if (not (instance? clojure.lang.Symbol symbol)) (throw (java.lang.Exception. "bad")) `forms))
22:14noncom|2so, and you want it to throw up on runtime instead of compile time?
22:14diminishedprimeWell, I want it to throw up when the macro is expanded.
22:15noncom|2(btw, for frameworks/libs: http://www.clojure-toolbox.com/ )
22:15noncom|2diminishedprime: so, that means you want to throw it on macro compile time
22:15diminishedprimeBecause that way the business folk can get a "nice" message from us on what they probably did wrong instead of a confusing message they wouldn't understand.
22:15noncom|2look: macro generates code. do you want it to throw up on the phase of code generation or on the phase of code execution?
22:15diminishedprimeYes, I think that's when I want it to happen.
22:16diminishedprimeOn the phase of code generation.
22:18noncom|2well, you've written it correctly. almost
22:18noncom|2here:
22:18noncom|2(defmacro macro-with-symbol [symbol & forms] (when-not (symbol? symbol) (throw (java.lang.Exception. "bad")) `(do ~@forms)))
22:18diminishedprimeThanks, let me try that out.
22:18noncom|2what is befor the backticked form will be executed on compule time
22:20diminishedprimenoncom|2: That did the trick. I'll switch it over to that tomorrow at work. The when makes more sense since for sure.
22:20noncom|2diminishedprime: sure. don't hesitate to ask here if you'll encounter more questions
22:21noncom|2diminishedprime: also, if you have lots of type checks, be sure to check out the prismatic schema library
22:21diminishedprimeThanks. I've really been enjoying Clojure. I come from a Java background, but I've been playing with some Lisps for the last few months and have really been loving it. Thanks for the library recommendation, I'll look into it.
22:21noncom|2:) cheers!
22:22arrubinIs anyone here an admin for the Clojurians Slack?
22:23noncom|2arrubin: i know that seancorfield may know something
22:24noncom|2:)
22:24noncom|2however, it looks like that most people on this channel are afk, probably asleep
22:24noncom|2or at work..
22:28Trioxinalright, fire up clojurebot, Trioxin is back!