#clojure logs

2014-09-06

00:03weiis it a good idea to bind request map to *request* (lib-noir style), so it can be accessed from any function?
00:05danneuwei: i remember doing that when i was more of a beginner with compojure. can't remember why. these days id just pass the request through as an argument
00:07danneuthough i do still bind *current-user*, but it's out of habit. i should prob just assoc it to the request
00:22joobusWoohoo! "You have achieved clojure enlightenment. Namaste."
00:22joobusI defeated the clojure koans!
00:34alexbaranosky_I have to say el-get is amazing. At work a few of us religiously try to get others using it.
00:37technomancyalexbaranosky_: I'd say it's less that el-get is amazing and more that everything else is just dismal
00:40alexbaranosky_technomancy: yes. i just need to be able to specify versions of packages... before el-get I couldn't easily tell people which actual package versions I was using
00:51abaranoskyI'm here canvasing for upvotes on my Clojure patch :) http://dev.clojure.org/jira/browse/CLJ-1519
04:31kryftI'm trying to make a stand-alone jar, but `lein jar' seems to run forever (I'm assuming it doesn't take hours for 100 lines of code)
04:33dimasanggakryft: do you run any function in your namespaces top level?
04:33TEttingerkryft, yeah, what dimasangga said
04:34kryftdimasangga: No -- well, not as far as I know. I don't know what compojure's defroutes macro does.
04:34TEttingeras in a function being run inside a (def ...) or just like (some-db-call ...) not wrapped in a defn
04:35dimasanggaor your jetty run-server?
04:35kryftBut I even tried wrapping every single top-level definition inside a function, but still no luck.
04:35TEttingerthose things will get run by lein as part of the compile process
04:35TEttingercould also be fetching deps if you have many large ones
04:36TEttingerI waited about 4 hours one time for RoboVM to download off maven central when it was having a bad day
04:37kryftOh, I assumed it had fetched deps already for lein repl
04:37dimasanggakryft: try `lein deps` first, then `lein clean` before doing `lein jar`
04:40kryftHere's core.clj and project.clj, in case I'm missing something obvious: https://gist.github.com/kryft/9303dfdfa730cac346ea
04:42kryftdimasangga: Tried that; I got two lines with "Compiling abhimata_backend.core" and now it's been running for 3.5 minutes with full CPU usage
04:55kryftTEttinger: Is there any way to see what's causing lein to hang? For example, how did you know you were waiting for RoboVM?
04:56TEttingerthat was actually using another tool (that also used maven central for some deps), but I think if it is fetching a dep it would say so
04:59dimasanggakryft: i put put :gen-class before :import on ns declaration like this
04:59dimasanggakryft: (ns(ns abhimata-backend.core
04:59dimasangga (:gen-class)
05:00dimasanggaand it was compiled under 10 secs
05:00justin_smithkryft: you can use jstack to find out what a jvm is doing on each running thread
05:01dimasanggakryft: i will post my version of your project.clj and core.clj in gist shortly
05:02kryftdimasangga: Ok, thanks :)
05:03dimasanggakryft: https://gist.github.com/dimas-angga/280b06871831fa95850a
05:19kryftdimasangga: Thanks! If I copy those intoa new directory, I can make a jar, but in the original directory lein jar still hangs (with your project.clj and core.clj)
05:23kryftdimasangga: So apparently there's something wrong with something outside those two files
05:24kryftStrange
05:27dimasanggakryft: i don't get what you mean with new directory, did you make a new project or something?
05:28kryftdimasangga: Well I just copied project.clj to tmp_dir, copied core.clj to tmp_dir/src/abhimata_backend, and then ran 'lein jar' in tmp_dir
05:30kryftdimasangga: Hmm, actually it seems that 'lein jar' *does* work in the sense that the jar file gets created, but for some reason lein jar keeps running at 100% CPU anyway.
05:31kryftOh well, at least the jar file gets created,
05:37kryftdimasangga: Anyway, thanks for your help; now I know that there's something wrong with the project directory, not the source files (since jar creation works if I copy the files into a new project)
05:54dimasanggakryft: You're welcome :)
07:49dagda1_how do I move 1 s-expression inside another using paredit in emacs?
07:57hyPiRion~paredit
07:57clojurebotparedit is not for everyone, but what you need to understand ís how to become the kind of person that paredit ís for.
07:57hyPiRiondagda1_: http://www.emacswiki.org/emacs/PareditCheatsheet
08:11dagda1_can anybody explain why this https://gist.github.com/dagda1/94c2823d47645f26f7aa goes into an infinite loop when I thought I was returning a lazy-seq
08:12dagda1_or is it because I am running it in the repl?
08:13dagda1_no, I just think it is wrong :).
08:45hyPiRiondagda1_: reduce is eager
08:45hyPiRionit will run until it hits the end of the list
08:45dagda1_hyPiRion: I thought lazy-seq would stop this
08:46hyPiRionlazy-seq will defer the evaluation of a reduce
08:46hyPiRionbut once reduce has been called, it will happily run until the sequence is empty
08:47dagda1_hyPiRion: what could I do instead?
08:48hyPiRionYou could either do the loop itself recursively, where each cons call is wrapped in a lazy-seq
08:48hyPiRionor, in this case, you could just do (reductions + (range))
08:48hyPiRion,(reductions + (range))
08:48clojurebot(0 1 3 6 10 ...)
08:49hyPiRionYou can usually use existing functions to get the functionality you want with laziness, without using lazy-seq itself.
08:51dagda1_hyPiRion: i'm trying to recreate reductions just to increase my clojure knowledge
08:51hyPiRionaha
08:52dagda1_hyPiRion: I think I have an idea what tod o
08:53hyPiRiondagda1_: reductions use the technique I mentined earlier - it loops recursively (without recur)
08:53dagda1_hyPiRion: got it, thanks
08:53dagda1_hyPiRion: without recur?
08:54hyPiRiondagda1_: (defn reductions [...] ... (reductions ...)) instead of (defn reductions [...] ... (recur ...))
08:54dagda1_hyPiRion: and that is not tail recursive
08:55hyPiRionyeah, true
08:58dagda1_hyPiRion: I thnk it should work with recur
08:59hyPiRiondagda1_: it could work if you want it to be eager. But then you won't be able to use reductions on infinite lists
09:00gfrederickshey hey alpha2 has clojure.core/update
09:00gfrederickshooo ray
09:07cfleminggfredericks: Yeah, I was waiting for that one - nice
09:07gfredericks,update
09:07clojurebot#<core$update clojure.core$update@1eee7b7>
09:09samfloresgfredericks, what's the diff from update-in?
09:09gfrederickssamflores: just for one level
09:09samflores(update-in {:k 1} [:k] inc)
09:09nkozoI want to create a service using core async, it receives request from a channel and must return a response. My first approach is to send the response to a reply-channel included in the request, so my make-request fn will allocate a reply-chan each time is called. Is this a good idiom? Or is the (chan) allocation call to costly to do each time?
09:09gfredericks,(-> {:foo 12 :bar 14} (assoc :baz 8) (update :bar * 3))
09:09clojurebot{:baz 8, :bar 42, :foo 12}
09:09samfloresisn't that bad :p
09:10gfrederickssamflores: I get tired of it after the 57th time
09:10gfrederickssamflores: why don't we get rid of assoc as well?
09:16samfloresI don't get it
09:16samflores,(-> {:foo 12 :bar 14} (assoc :baz 8) (update-in [:bar] * 3))
09:16clojurebot{:baz 8, :bar 42, :foo 12}
09:20gfrederickssamflores: I assume you're arguing that we don't need update because you can do the same thing with update-in
09:21gfredericksin which case we also don't need assoc since we can do the same thing with assoc-in
09:23samfloresI'm not arguing. just trying to really understand the value of having update and update-in
09:26samfloresassoc can't receive a fn, so I can't *easily* update the value based on it's current value. I believe that's the diff of assoc and update-in that justify having both
09:26gfredericksyes I mean we don't need assoc because assoc-in can work
09:26gfredericks,(-> {:foo 12 :bar 14} (assoc-in [:baz] 8) (update-in [:bar] * 3))
09:26clojurebot{:baz 8, :bar 42, :foo 12}
09:27gfredericksupdate is to update-in as assoc is to assoc-in
09:27samfloresoh. now I got your point :D
09:27gfredericksalso I use it all the time so I was tired of requiring it
11:10nkozowhen you use <!! inside a core.async go block, it will park correctly as by using <!?
11:31bacon1989Hi, I was wondering, how would one typically design a system involving several instances of mutable objects?
11:32justin_smithbacon1989: what invariants need to be preserved as they mutate?
11:32bacon1989in this situation, would I use a deftype, over a defrecord, to store mutable state?
11:33bacon1989justin_smith: the Viewer is showing maps, so I started out with defrecord [maps], but the maps change, along with what maps might be showing
11:33justin_smithwhy do those maps need to change - can't you just view a different map?
11:34bacon1989but if i'm changing hte map that the viewer is showing, that would still require mutable state in the viewer, right?
11:35justin_smithnot neccessarily any exposed mutable state - of course registers in a CPU mutate, what we can change is where mutation exists in our high level execution model
11:35justin_smiththe general best practice in Clojure is to replace mutation with function arguments (such that the function mutates nothing, but does something different with different arguments provided)
11:36bacon1989justin_smith: I sort of see what you're getting at
11:36justin_smithshould be view even be accessing the data model? why can't it just receive a request or command and make a new display based on that?
11:37bacon1989justin_smith: hmm... good point, I could just mutate the previous viewer, and display it
11:37justin_smiththe mess we are avoiding here is the synchronization of layers - the brittle things that happen when changes could be coming from one end of the system or the other - the typical OO solution to this is to make one abstraction (the controller) that mutates the model, and reports the current state of the model to the viewer
11:39justin_smithwhen we have immutability, the data end can provide immutible data to the view end, and the view end can send requests to the data end (for the next version of the data) - none of these objects need to mutate
11:39justin_smithof course you can also use mutation if you really want to, but we like to avoid it in Clojure
11:40justin_smithif you want mutation, yeah, you can use deftype with mutable fields, then you probably want to create an imperative control layer to coordinate changes (the c in mvc)
11:40justin_smithand you will need to think about your invariants (as I first mentioned)
11:41justin_smithone nice thing about immutibility is that the set of invariants we actually need to think about / implement is much smaller (typically "this value cannot change" suffices on that count)
11:42justin_smithinvariants can be things like "the sum total of values in all accounts must remain consistent as transactions are processed" or "the fields in the UI must all reflect details of one target object, and reflect its most recent modification at all times"
11:46bacon1989justin_smith: thank for that, i'm going to have to re-think how I implement this
11:47justin_smithnp
11:49JaniczekAnybody using Figwheel here? I don't know how to re-render with an old state atom.
11:50JaniczekMaybe I can fake it with serializing into cookies or local storage, but maybe Figwheel has something under its sleeve?
11:51justin_smithbacon1989: that reminds me, on a more pragmatic note, you can try using an atom to hold coordinated state, where instead of mutating the datastructure, you use pure functions that are atomically applied to the state. The advantage here is no reader will be blocked, or see a partial update.
12:15awwaiidI'm trying to understand the sourcecode relationship between clojure and clojurescript. They appear to be completely independent git repos. Is there any automatic correlation between them, or are all changes hand-moved?
12:16justin_smithawwaiid: some libs are written such that they can be used from clj or cljs, but the languages (java / javascript) are different enough that they share little of the same core clojure implementation
12:17justin_smithawwaiid: as they like to say on ##java, java is to javascript as ham is to hamster
12:19awwaiidI noticed that CinC was split and moved into independent repos -- tools.analyzer, tools.analyzer.jvm, tools.emitter.jvm. I see there is tools.analyzer.js . Do these get sucked into the build process for the main clojure/clojurescript builds?
12:19awwaiidI will continue to read about this, just looking to see if there is a high-level overview that I'm missing
12:21justin_smithawwaiid: Bronsa puredanger and arrdem would be good people to ask about this stuff
12:21justin_smiththey work on or around those tools
12:22awwaiidI just noticed that there is a Cojure/West video about tools.analyzer for me to watch, might give a good intro
12:22awwaiidthanks
12:24Bronsaawwaiid: ATM none of the tools.* libraries (except for tools.reader) is being used for the official builds, they are separate entities
12:36awwaiidBronsa: is it a goal?
12:40Bronsaawwaiid: I'd like to see cljs switch to tools.analyzer.js as its analyzer at some point, but there's still work that needs to be done before I can start bothering dnolen_ about it
12:40awwaiidok cool
12:40Bronsaawwaiid: on the clojure side, that's less likely to happen
12:40awwaiidtoo complex, or momentum, or what?
12:41Bronsaawwaiid: a variety of reasons: bootstrapping issues, performance, stability just to name a few
12:41awwaiidah
12:42awwaiidseems like it would be awesome to have the same code-foundation. I was looking at the abandoned python and ruby backends and thinking that, at least
12:45justin_smithawwaiid: if Clojure was more ambitious about abstracting away from the runtime, it would be possible. But one of the main advantages of clojure is how closely it reveals the runtime (ie. how trivial interop is, the relatively low cost of its abstractions as compared to just using the underlying impl language)
12:49Bronsaawwaiid: btw if you're looking at tim's clojure/west talk, I have to warn you that since then things have changed a bit and some of what he shows might not be true anymore
12:50awwaiidI'm mainly learning about the big picture rather than the details at this point
12:50Bronsaawwaiid: ok, if you have any question feel free to ask me about it
12:54awwaiidBronsa: thanks
13:06whiloare there any attempts at a core.matrix cuda/opencl implementation yet?
13:06whiloi am using theano for cuda on python atm. and it would be nice to get something similar in idiomatic clojure
14:08justin_smithwhilo: OS level interop on the jvm is kind of a pain, I don't know of any Clojure projects that attempt jni off the top of my head. There are java cuda libs you could use via clojure.
14:09dbaschjustin_smith: there’s this https://github.com/Chouser/clojure-jna
14:09justin_smithdbasch: cool, I didn't know about that
14:10dbaschI hope I never have to use something like that though :P
14:17sorbo_anyone have experience using Enlive? https://github.com/cgrand/enlive
14:17sorbo_I'm trying to get src attributes for images
14:17sorbo_but it escapes the URLs
14:18sorbo_e.g. http:\/\/
14:18sorbo_I'm not sure how to prevent this
14:20justin_smithsorbo_: can you share a small paste on refheap that demonstrates what you are talking about?
14:21sorbo_justin_smith: sure, one second
14:28sorbo_justin_smith: https://www.refheap.com/89913
14:28sorbo_I haven’t run this paste, so there could be unbalanced parens or something like that
14:29sorbo_I’ve got the scraping working fine, I just can’t figure out how to properly un-escape the escaped link
14:30sorbo_yeah, there were unbalanced parens. fixed
14:34dbaschsorbo_: it works fine for me. What version of enlive are you using?
14:35sorbo_1.1.5
14:35justin_smithsorbo_: cannot reproduce https://www.refheap.com/89915
14:36sorbo_dbasch: which version are you using?
14:36dbaschsorbo_: 1.1.5
14:36sorbo_justin_smith: hm. it’s possible the escaping is happening after enlive is doing its job
14:36sorbo_I’ll tinker with it
14:36sorbo_thanks for having a look
14:36justin_smithit looks like the kind of escaping a templating lib would do
14:59PigDudehuh, what do you do when you need a record/type to refer to itself?
14:59PigDudeah nevermind
14:59PigDudeseparate extend-type/defrecord|type
15:12jpenacan someone help me understand the error i'm getting here? http://dpaste.com/2SJCTT5
15:13jpenai'm just trying to write a simple standard deviation function
15:13justin_smithjpena: (i - avg-numbers)
15:14justin_smithshould probably be (- i avg-numbers)
15:14jpenaah, damnit, im such a noob
15:14justin_smith"java.lang.Long cannot be cast to clojure.lang.IFn" gives a pretty good idea of what you are looking for
15:14justin_smith,(1 + 1)
15:14clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
15:15jpenayeah, i was having trouble understanding that, but it makes sense now that you mention it
15:15jpenathanks justin_smith
15:16justin_smithnp
15:16justin_smithfor a little more detail, most everything in clojure is based on protocols / interfaces rather than concrete classes / types
15:17justin_smithIFn is for things objects you can call (functions, maps, keywords, etc.)
15:20ToBeReplacedis there a string plus in CLJS? I want to do a literal "a + b" where a and b are strings without calling str
15:20justin_smithyou can use a StringBuffer
15:20justin_smithif you want to mutationally add chars to a string
15:20justin_smithbut on an implementation level, a+b just creates a new string just like str does, in java
15:21justin_smithsorry, s/StringBuffer/StringBuilder
15:23ToBeReplacedjustin_smith: anything lighter weight? i want the compiled javascript to read "a + b"... (js/+ a b) gives me _PLUS_(a, b), and i don't know if that's the same thing
15:24ToBeReplacedi'm experimenting with CLJS for kicks, but I can't bring in the facilities because they are too large... i'm trying out using it for macros, but then i can't have "str" in my cljs source, i need to perform raw concatenation
15:25justin_smithoh I am sorry
15:25justin_smithI missed the CLJS part, my bad
15:25ToBeReplacedand unfortunately i only know a and b at runtime so i can't do it at compile time
15:31justin_smithToBeReplaced: what about the concat method?
15:32justin_smithyou could have a temporary accumulator string for sanity's sake
15:33justin_smith(.concat "hello" "world") should just compile to a String.concat call, right?
15:33arrdemshould...
15:33justin_smithwell, I don't have a handy cljs setup to test that atm, but it sounds like he does :P
15:34amalloyToBeReplaced: you want to use cljs to emit javascript that doesn't depend on any of the cljs runtime?
15:36ToBeReplacedamalloy: yes
15:36amalloyi don't think you'll get far with that. almost everything needs the runtime; and if you just want to write "a + b", it's easier in javascript than in cljs
15:36ToBeReplacedexperimenting ;), also interesting to hook in to closure compiler that way
15:37ToBeReplacedyeah, all it's doing right now is calling macros that call native clj functions and expand to cljs forms
15:44adamtHello dear fellow people and droids. I have a problem with some java-interop, which I hope you might be able to help me with. ;-)
15:47justin_smith~ask
15:47clojurebotThe Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.
15:47arrdemjustin_smith: can I get a ~droids
15:47adamt(i am, just slow at typing :-( )
15:47adamtWhen trying to call a method, it seems like clojure can't find a method with a matching signature. I have a gist here https://gist.github.com/adamtulinius/76c11ec527a33a1bf698 with the exception thrown, and a link to the api of the java interface
15:48justin_smitharrdem: droids is ...
15:48allenj12so i need to go through a structure and each element i find falsey elem to a predicate, i need to to update a different vector and start going throught the prior structure all over again testing it again... what control structure/function do i want?
15:48adamt(please excuse my horrible clojure)
15:48justin_smithadamt: before looking, I am going to guess int or varargs
15:48adamtjustin_smith: yes, varargs
15:48adamtsignature is basically java.io.file and varargs on strings
15:49justin_smithadamt: (into-array ["all" "the" "strings"]) as the last arg
15:49justin_smithvarargs is an illusion, it's really just an array as the last arg
15:49Bronsaadamt: or (into-array String []) if you have no params
15:50justin_smithBronsa: excellent point, I missed that
15:50justin_smith(inc Bronsa)
15:50lazybot⇒ 47
15:50adamtjustin_smith + Bronsa: thanks, i'll try
15:55adamt(ing justin_smith)
15:55adamt(inc justin_smith)
15:55lazybot⇒ 73
15:55adamti fail horrible. Thanks both of joy, it worked great. Sorry for being slow at typing the silly question.
15:56adamtWow, I just can't spell today, better be quiet now before I insult somebody by accident!
16:01justin_smithadamt: not a big deal, regarding the ~ask thing
16:01justin_smithno need to feel bad about it at all
16:02justin_smiththe standards of what's "polite" on irc are different from other places, that's all
16:14adamtjustin_smith: to be honest, I mostly wanted to break it up into two message, because I know about the limited length of a single message on IRC, but got interrupted because I realised I made a mistake in my gist. :P
16:21amalloyallenj12: i don't really understand the problem. it sounds special-case enough that just using loop might be appropriate
16:22allenj12amalloy: yea it seems the loop is best doing that now. thank you!
16:35tadniSo, just finished giving my friend a very basic intro to programming in Clj. Lighttable is much easier to teach than Emacs.
16:36dbaschtadni: when it works :)
16:36tadnidbasch: I had no problems, but hey. :^P
16:37tadniI think that is more or less sticks with "traditional" key bindings helps too.
16:38justin_smithtadni: one of these days I am going to teach someone CLI, Linux, emacs, Clojure, database management, and git all at once - as they stab me to death and I gurgle my last words, those words will be "you are now a devop"
16:39tadnijustin_smith: Well the person I was giving the intro to, had very very little technical backgroud. Even scared of a CLI in-general.
16:40tadniHe picked up Lisp-like syntax pretty fast though, I was kinda shocked.
16:40tadniAny mistakes he made, I see was a failing for me to explain it simply.
16:40justin_smithit's easier if you haven't learned an algol syntax yet
16:41tadniI need to think of more simple examples though. We did a dice-roller and coin-flipper, and age-in-x programs. Rest was basic maths and hello world and the like.
16:42justin_smithtadni: extract some data from a simple json rest api using slurp and cheshire
16:42tadnijustin_smith: Yeah, I guess. At that point I assume it's more unlearning syntax.
16:43justin_smithI was thinking because it would give opportunities to use the many marvelous sequence and datastructure transforming tools clojure has
16:43justin_smithextracting the data you want, putting it in the right place, that kind of oragami
16:43justin_smiththe cheshire part would just be one call - cheshire.core/read-string
16:44justin_smiththe rest would be clojure.core sequence and map operations
16:44tadnijustin_smith: Maybe a few lessons down the line, right now he's still at very basic starter notions of programming.
16:44justin_smithcheck out the cheat sheet and see how many functions you can try out http://grimoire.arrdem.com/
16:45justin_smithOK
16:45justin_smithso maybe do some of the math he already knows, translate it to clojure code
16:45justin_smith(this will depend on their level of math education of course)
16:46tadnijustin_smith: He's just at intermediate alg, so I'm think there's not a lot to work with.
16:47tadniMaybe by Tuesday.
16:50justin_smithugh, cider - it wouldn't be so bad except setting it up is often one of the first things a new clojure user tries to do
16:50lpasteaa pasted “aa” at http://lpaste.net/110625
16:50justin_smithlpaste: you are in the wrong channel
16:51tadnijustin_smith: Yeah, I wasn't able to get it working my first try. nrepl couldn't find my install of clj.
16:51tadniI'm assuming Fedora might install it somewhere weird.
16:51justin_smithnrepl?
16:51clojurebotnrepl is a network REPL implementation: http://github.com/clojure/tools.nrepl
16:51justin_smithI thought you were installing cider
16:52tadnijustin_smith: Cider is based off nrepl, isn't it?
16:52justin_smithabsolutely not
16:52llasramtadni: Also you don't really install Clojure. You install Leiningen
16:52justin_smithwell, it replaces it
16:52llasramEr
16:52tadniMaybe it was just a regular repl -- but I couldn't connect to it.
16:52llasramCIDER replaces nrepl.el
16:52justin_smithOK, cider uses lein to open an nrepl instance when you jack in
16:52llasramnREPL is the Clojure network REPL protocol/implementation, which CIDER uses
16:52dmitrygusevwhat does "n" in nREPL stands for btw?
16:53llasramdmitrygusev: network(ed?)
16:53tadniNetworked?
16:53dmitrygusevhm
16:54ghadishaybanhiredman: is it more useful for reducible io wrappers to be one-shot or reusable?
16:55justin_smithtadni: yeah, lein is the right way to use clojure at dev time
16:55tadniPeace for now, peeps. o/
17:10LBRapidBased on this small app, https://gist.github.com/LBRapid/1f04682e944182fd8ce7 how would I complete my remove-player function? I'm having trouble figuring it out
17:15justin_smith LBRapid: (swap! players dissoc player-name) maybe?
17:16justin_smithLBRapid: but change players to #{} instead of ()
17:16justin_smiththat way you can only get one instance of each player, and you can do lookup / removal by value
17:16LBRapidjustin_smith: Right, so really a map makes more sense in this case?
17:16justin_smithif you need any data attached to the player, change the #{} to {}
17:17justin_smithwell, with what you have now a set #{} works, but yeah, you probably want a map if players have any associated data
17:18LBRapidOkay. I understand. Thanks! I'm still wrapping my head around things, working through some exercises in a concurrency book
17:18justin_smith,(disj #{:a :b :c} :b)
17:18clojurebot#{:c :a}
17:18dbaschif you want it to be a list for some reason, you’d need something like (swap! players (fn [s x] (remove #(= x %) s)) player-name)
17:18LBRapiddbasch: Ah thanks. I was trying to use remove but was having trouble getting it right
17:19justin_smithLBRapid: dbasch: I'd welcome any argument as to why a list would make more sense than a set or map here
17:19justin_smithbut I am not seeing any
17:19dbaschjustin_smith: I don’t think it should be a list either
17:19LBRapidjustin_smith: I don't think it does. That's just where the example was when I started the exercise, but makes sense to swap for a set to me
17:23lodinWhat's a proper use case for #=(...)?
17:25justin_smithlodin: I can find no documentation for #= http://clojure.org/reader
17:25lodinjustin_smith. Neither did I. :-)
17:26lodin,(read-string "#=(+ 1 2)")
17:26clojurebot#<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>
17:26lodin:-(
17:26justin_smithahh, right, I always forget about that
17:26justin_smithit's a terrible thing that should never have existed :P
17:27lodinjustin_smith: Which makes me curious to why it exists in the first place. I'm assuming there was a use case for it.
17:27justin_smithpeople do seem to like being able to insert arbitrary executed code into data
17:41dagda1_can anyone explain why I get a stack overflow with this function when I use an infinite list https://gist.github.com/dagda1/6b4fc1e0ee6412b78c90.
17:43amalloydagda1_: you're building up a result that looks like (lazy-seq (lazy-seq (lazy-seq ...)
17:43amalloy))
17:43dagda1_amalloy: ha, yes you are right
17:43amalloywhen it comes time to find the first element of that, you have to go through a zillion levels of nesting
17:43amalloyinstead, you should use cons to build a lazy seq
17:43amalloylike, what you've written here would be fine as a tail-recursive function
17:44dagda1_amalloy: so don't use letfn
17:45dagda1_amalloy: acutually I don't see how lazy-seq gets called multiple times if lazy-seq precedes letfn
17:45amalloydagda1_: your conclusion doesn't follow at all from the evidence
17:45dagda1_amally: my conclusion?
17:45amalloy"don't use letfn"
17:45dagda1_amalloy: I don't think I understand
17:46amalloydagda1_: your function returns successfully without causing a stackoverflow. the overflow comes only when attempting to seq it
17:46amalloy$google stackoverflow dbyrne prime sieve
17:46lazybot[recursion - Recursive function causing a stack overflow - Stack ...] http://stackoverflow.com/questions/2946764/recursive-function-causing-a-stack-overflow
17:48dagda1_but what if I want the function to work with infinite lists like (range) surely I need to use lazy-seq
17:48justin_smithdagda1_: right, use lazy seq with cons, as amalloy said
17:49dagda1_justin_smith: ok, so why is cons important
17:49justin_smithyou need to do some work for each element, cons takes the element you are adding, plus the realizable lazy seq for getting the rest (which is where the recursion happens)
17:49amalloydagda1_: never (or almost never?) use lazy-seq and an accumulator parameter for the same function. if you have a partial result to return, return it immediately with (cons x (keep-going ...)) instead of (keep-going (conj acc x))
17:50justin_smiththat's a much clearer explanation
17:50justin_smith(inc amalloy
17:50justin_smith(inc amalloy)
17:50lazybot⇒ 165
17:51dagda1_amalloy: great, thanks
17:58tadni_Back! :^)
17:59dagda1_so wrapping a function in a lazy-seq call does not make the seq lazy
17:59justin_smithit's lazy-seq is neccessary but not sufficient
18:02amalloydid you read the stackoverflow question i linked, dagda1_?
18:14tadni_justin_smith: Should I be using Lein 1 or 2?
18:14justin_smithdefinitely 2
18:15justin_smithbut don't use 2.4.3 for repls where you have no project.clj - for projectless stuff you should downgrade to 2.4.2
18:15justin_smithhopefully 2.4.4 comes out soon
18:15justin_smith(and fix that issue)
18:17tadni_Hrm, keep getting "(Could not transfer artifact clojure-complete:clojure-complete:pom:0.2.3 from/to central (https://repo1.maven.org/maven2/): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty)" when I try to run ./lein
18:17tadni_Then it warns "This could be due to a typo in :dependencies or network issues. If you are behind a proxy, try setting the 'http_proxy' environment variable."
18:18justin_smithhrm - do you have any already-created lein project on disk?
18:18justin_smithif not, maybe clone a simple clojure project from github, and run "lein deps" from inside that
18:18justin_smithI think this is related to the other "no project" bugs
18:19tadni_justin_smith: This is a brand new install of the distro Arch/Parabola, I'm going to use for teaching/learning clj specifically.
18:19justin_smithOK
18:20justin_smithtadni_: https://github.com/flatland/useful clone this distro and try running "lein deps" inside the top level directory
18:20tadni_justin_smith: Lein's not even installed, I'm trying to run to build script from it.
18:20justin_smithright
18:20justin_smithit installs intsefl
18:20justin_smith*itself
18:20justin_smithahh!
18:20justin_smithdon't run the build script
18:20justin_smithrun lein.sh (rename it to lein)
18:20justin_smithit is a dependency manager, it installs itself from that script
18:20justin_smithor runs if the deps are there
18:21tadni_justin_smith: What I installed is just "lein" and it told me to chmod it to a+x and ./lein.
18:21justin_smithso just put the lein script on your path and go
18:21tadni_What I downloaed*
18:21justin_smithahh, OK
18:21justin_smithso yeah, put it in a directory in your $PATH
18:21justin_smithand then run "lein deps" from inside that flatland repo
18:21johnwalkertadni_: are you really on parabola ?
18:21tadni_johnwalker: Yes?
18:21johnwalkerthats cool :)
18:22justin_smithtadni_: I was thrown off by you calling it a build script: it is a bootstrapping dependency manager, but the installation process does no building
18:22tadni_johnwalker: I was on the GNU Distro alpha for awhile on this box, but I didn't have the patience to package openjdk and related stuff, for Clj. :^P
18:23justin_smithtadni_: I find 2.4.3 issues that hit new users especially embarrasing - usually lein is one of the things about clojure I would be most proud of
18:28tadni_justin_smith: Well, "lein" script is now in /usr/local/bin ... which is in my path, but same error.
18:28justin_smithdid you run it from inside a project directory?
18:29tadni_justin_smith: Ah, nope. Should I just search for projects on github?
18:29justin_smithI gave you a link for a good one above
18:29justin_smithhttps://github.com/flatland/useful
18:29tadni_justin_smith: Ah, sorry.
18:29justin_smithit's code worth reading to learn clojure also :)
18:29justin_smithcontributions from many of our friends here on this channel
18:34tadni_justin_smith: Um... same error.
18:38tadni It's worked without fail on Fedora. Odd.
18:38tadniWell if I can't figure it out on Parabola, I guess I'll put Fedora on that box too.
18:39justin_smiththat's weird
18:39justin_smithwhat it should be doing as it starts running is downloading a bunch of jar files into ~/.m2/repository
18:43tadniWelp, lein depends aborts on my Fedora box when I try to grab depends for useful. http://paste.lisp.org/display/143639
18:44justin_smithweird
18:45justin_smithtechnomancy: hyPiRion: either of you care to see what is going on here? I tried to make some common sense suggestions, but this looks weird
18:45justin_smithtadni: those guys actually work on lein
18:45hyPiRiontadni: how did you install lein?
18:46prctadni there is a workaround posted here: https://bugzilla.redhat.com/show_bug.cgi?id=1063457 it worked for me
18:46tadnihyPiRion Via installation instructions on lein's site. Grab the raw github file, put it in ~/bin, chmod it and ./lein
18:50justin_smithprc: that issue mentions lein 1.x, the situation is the same for 2.x?
18:52hyPiRiontadni: could you try with the script at https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein ? Because I would be surprised if lein doesn't contain all its dependencies.
18:52tadniSo I deleted ~/.lein and moved the lein chmod'd script to /usr/bin/lein and ran self-install and it worked.
18:52tadnilein depends pulled for useful.
18:53tadnihyPiRion: That's the script I was using.
18:53justin_smithawesome - so the bad previous state may have left corrupted contents in ~/.lein maybe? I doubt putting it in /usr/bin made a big difference
18:54tadnijustin_smith: Yeah, that's the only thing I could reason.
18:54hyPiRionhrm, good it works now at least
18:56tadniSo working on my primary box, my dedicated teaching/learning box I still need to do... but I'm just going to do a minimal install of Fedora in lew of Arch/Parabola, because I know that Fedora should work.
18:58justin_smithtadni: well you could at least try setting aside .lein (don't delete, things in it may help discover what broke if moving it aside fixes the problem)
19:00tadnijustin_smith: True.
19:47gfredericksis there a canonical sequence of colors to use in a UI where you're trying to distinguish things by color?
19:48justin_smithgfredericks: I don't know about that, but I do know that there are guides to making color themes that are less ambiguous to people with r/g color blindness
19:48justin_smithhttp://dcp.ucla.edu/2011/04/tips-and-tools-for-creating-accessible-color-schemes/
19:49gfrederickscolors are impossible
19:52clj-learner2why cant i (peek (range (rand-int 20)))?
19:52gfredericks,(peek (range 5))
19:52clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IPersistentStack>
19:52gfredericks,(doc peek)
19:52clojurebot"([coll]); For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collection is empty, returns nil."
19:52gfredericks"list" is apparently the stricter definition here
19:54clj-learner2ok, so there's no way to peek a lazyseq
19:54gfrederickswell first would do the same thing, no?
19:55justin_smithit's slightly odd that it is implemented for list but not lazy-seq though
19:55gfredericksare there any other major differences?
19:55gfredericksbetween lists and lazy seqs
19:56gfredericksI feel like there might be but can't think of any
19:56justin_smithbesides the obvious one?
19:56justin_smithmaybe it has to do with conj
19:56gfredericksright
19:56gfredericksconj does the same thing
19:56gfredericks,(conj (range 3) 4)
19:56clojurebot(4 0 1 2)
19:56justin_smithyou can't make a lazy seq with conj, I don't think
19:56gfredericks,(conj '(0 1 2) 4)
19:56clojurebot(4 0 1 2)
19:56justin_smith,(type (conj (range 3) 4))
19:56clojurebotclojure.lang.Cons
19:56gfrederickslazy seq feels less like a proper data structure in some ways
19:57justin_smith,(type (rest (conj (range 3) 4)))
19:57clojurebotclojure.lang.ChunkedCons
19:57gfredericks,(pop (conj (range 3) 4))
19:57clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPersistentStack>
19:57justin_smithsee, not a lazy seq any more
19:57gfredericks,(first (conj (range) 4))
19:57clojurebot4
19:58justin_smithoh - so the lazy seq is hiding in there somewhere obviously
19:58nollidji've been out of the loop for clojure dev on emacs for a while. after updating packages, nrepl says it's version 20130919.757. has something supplanted it?
19:58gfrederickscider
19:58justin_smithnollidj: hypothetically, 0.7.0 is the stable cider version
19:59nollidjis that hypothetical because i should be running from HEAD?
19:59amalloygfredericks: lists are counted, is the main difference
19:59justin_smithit's hypothetical because I don't know how much about cider is actually stable
20:00nollidjso is this a case of, nrepl is old and may not work, cider is new and may not work?
20:00gfredericksamalloy: ah hah I knew there was something
20:00justin_smithnollidj: I wouldn't run cider from head, it breaks pretty frequently
20:00amalloyi guess, more general than counted, is that they are concrete and finite
20:00justin_smithnollidj: nrepl is old, but it still works
20:00gfredericksamalloy: any good reason for p{op,eek} to fail on seqs?
20:00justin_smithnollidj: hell, even slime (even older) still works
20:00amalloynothing brilliant that i'm aware of
20:00nollidjyeah, i used slime. nrepl-jack-in is nice, and i'm hoping that it will still work okay
20:01amalloyit means pop/peek can be fast, though, just going straight through IPersistentStack instead of having to seq
20:01justin_smithI still use nrepl
20:01amalloy(and you don't have to implement pop/peek for all sequences either)
20:01justin_smithls
20:01lazybotbin boot dev etc home root
20:01gfredericksoh the "guaranteed to be fast" aspect is interesting
20:01gfrederickssince it could be arbitrarily slow on a lazy seq of course
20:02justin_smithgfredericks: light bulb went off, I think that's it
20:02gfredericksclj-learner2: ^ in case you weren't following
20:02nollidji guess i'll stick with nrepl until something stops working, then
20:02nollidjthanks
20:03justin_smithin my experience nrepl works fine with 1.6, i haven't tried clojure 1.7 yet though
20:03clj-learner2gfredericks, thanks
20:07gfredericksconstruct a directed graph from vertices (range 2 n) where (a,b) is an edge if a divides b
20:08gfredericksfor what n is the graph planar?
20:12justin_smithgfredericks: there is a path addition method, and a vertex addition method
20:12justin_smithyou could probably iterate them in clj even
20:13justin_smith(said methods are for determining if a graph is planar - you could do a loop that keeps adding the edges and the appropriate vertexes until you are no longer planar)
20:13justin_smithmaybe drawing is simpler :)
20:13justin_smithunless we want to do general "iterate until no longer planar" problems
20:14gfredericksjustin_smith: "path addition" == "edge addition"?
20:15justin_smithit's from Hopcroft and Tarjan
20:15justin_smithhttp://en.wikipedia.org/wiki/Planarity_testing#Algorithms
20:15justin_smithhttp://dl.acm.org/citation.cfm?doid=321850.321852
20:16justin_smith"An ALGOL implementation of the algorithm succesfully tested graphs with as many as 900 vertices in less than 12 seconds." lol
20:20gfredericksI think I've got up to 16 by hand
20:20gfredericksoh 17 is free
20:24gfredericksso far: http://upload.gfredericks.com/tmp/divisors.png
20:25justin_smithyou can reposition 9 to make 18 work, I suspect
20:30gfredericksyeah I got 18
20:30gfredericks20 looks possible but so much dragging would have to happen...
20:33gfredericksoh nauty comes with a planarity test; I should just use that
20:43gfredericksyou can do up to 23; 24 breaks it
20:44gfrederickstoo many dang divisors
21:15clojerI have an Om/Weasel project open in Emacs Cider 0.7. The repl is connecting changes with the browser but nothing happens when I update the core.cljs file from which I launched cider-jack-in. I have `lein cljsbuild auto` running.
21:17nollidjwhat's the syntax now for instantiating a record? (MyRecord. fields)?
21:25joobusdo many here use clojurescript for brower side code?
21:25gfredericksjustin_smith: https://twitter.com/gfredericks_/status/508425098697912320
21:25Bronsanollidj: (MyRecord. field1 field2 ..) or (->MyRecord field1 field2 ..) or (map->MyRecord {:field1 field1 :field2 field2 ..})
21:25joobusmeant browser
21:26clojerjoobus: I'm trying to work with Om, ie. clojurescript for React
21:26nollidjbronsa: oh, new syntax ->MyRecord. thanks.
21:26nollidjwell, not syntax. but whatever.
21:27Bronsayeah it's just a regular function wrapping (new MyRecord ..)
21:29joobusclojer: I've written a static site generator in python that I'm now trying to port to clojure. One of the things it does is generate js from inline coffeescript. But clojurescript is different in that it requires the clojure core to compile. I was wondering if it would be worth it to try generating js from inline clojurescript in my content templates.
21:29clojerjoobus: Sorry, but you're way ahead of me :)
21:30joobusclojer: not by much :)
21:30clojerjoobus: Believe me :)
21:31clojerjoobus: I'm struggling to get Emacs and the browser to work together so early days for my Clourescript adventures.
21:31clojerjoobus: I have the repl half working but not recognition of file changes.
21:32joobusclojer: I'm a vimmer, so can't help you there :(
21:33clojerjoobus: Tried evil-mode in Emacs? Best of both worlds.
21:34joobusclojer: that just sounds painful
21:34clojerjoobus: My initial reaction but quite the opposite in practice.
21:35caternevil-mode++
21:57joobusdoes anyone here know how to select the meta name="description" in enlive?
21:57joobussomething like [:meta (attr? :name)], but i don't know how to ask for name="description".
22:01joobusfound it
22:17sorbo_justin_smith: thanks for your help earlier
22:17sorbo_you were right, it was a liberator thing
22:17sorbo_got it squared away
22:18sorbo_this might be more of a #ruby question, but anyone know if the rouge project is still alive? https://rubygems.org/gems/rouge-lang
22:23clojersorbo_: I looked into this about 6 months ago and it seemed to be dead
22:24sorbo_clojer: :(
22:24sorbo_yeah, I get the same feeling
22:24sorbo_GH page is gone
22:24clojersorbo_: Sad to see Python beat Ruby to it. Hy is thriving it seems.
22:25sorbo_clojer: yeah, for sure
22:25sorbo_I mean, I’m stoked for the Python folks
22:25sorbo_but my favorite Ruby bits are the ones it stole from Lisp
22:25sorbo_it’s a shame for a clojure + ruby project to not be reall taking off
22:25sorbo_s/reall/really/
22:25clojersorbo_: I was rooting for that too.
22:26clojersorbo_: Ruby seemed an ideal candidate given its Lips heritage
22:26clojersorbo_: Maybe it's easier with Python's AST, however.
22:27clojersorbo_: I dont thing Ruby has a compile to AST layer.
22:27clojersorbo_: ... though Ryan Davis's s-expressions gems seem to be pointing in that direction.
22:28sorbo_clojer: interesting, I’ll take a look at that
22:30clojersorbo_: Richard Verding did something similar with LFE (Lisp Flavoured Erlang), ie. manipulate Erlang's AST
22:33oubiwannclojer: Robert Virding ;-)
22:34clojeroubiwann: Thou art indeed correct ;-)
22:39boblarrickI feel like a complete idiot, I cannot figure out how to read a .wav file into a byte array, does anybody know of a simple example of reading a file into a byte array?
22:44xeqiboblarrick: https://github.com/clojure-cookbook/clojure-cookbook/blob/master/04_local-io/4-19_handle-binary-files.asciidoc
22:46boblarrickI read that, but it doesn't cover reading a file in, at least not one of a size greater than the 1024 buffer shown there
22:47boblarrickactually looks like http://crossclj.info/ns/overtone/latest/overtone.libs.binary-file-io.html works
22:51joobusWas just looking at the Hy docs. Hy (it seems to me) would still suffer from the mutability and side effects of python. Am I wrong?
22:51boblarrickor something close to it https://gist.github.com/deathbob/0a48901e00fd747cc098
22:51joobusOther than prefix notation and parens, I can't see what Hy offers.
22:52boblarrickfeels like an awful lot of work, is there no easier way?
22:53john2xhmm so calling `cider-eval-defun-at-point` in a `(ns ...)` form doesn't eval the `:require` forms in it?
22:54john2xI had to eval the :require form separately to be able to eval another form which uses the required namespace.. is this intended?
23:48oubiwannjoobus, catern: yeah, Hy still has Python's mutable data
23:48oubiwannPaul is working on possible solutions for immutable data in Hy, though
23:49oubiwannhe's a huge fan of Clojure and is deeply aware of the benefits of such