#clojure logs

2015-02-22

00:00julianlevistonddellacosta: yeah, it’s just creating a copy with bits missing, effectively… so should be roughly that.
00:00justin_smithddellacosta: if you are removing n keys out of m, the into solution is N=(m-n), the select-keys solution is N=n
00:00ddellacostaI guess it's O(n) where n is the set of keys you are removing
00:00ddellacostaright
00:00justin_smithddellacosta: so the number of keys being removed, and the initial count, are going to affect things a lot
00:00julianlevistonnow I have my beautiful function thanks guys… you really do rock… (defn filter-on-keys [pred coll] (select-keys m (filter pred (keys m))))
00:00ddellacostaright, right
00:01julianlevistonhaha coll !- m
00:01julianlevistongood work justin_smith
00:01julianlevistonI mean good work julianleviston
00:01justin_smithheh
00:08tomjackIf I cared about performance I think I would write (fn [pred m] (reduce-kv (fn [m k v] (if (pred k) m (dissoc m k))) m m))
00:08tomjack,(time (let [m {:a "hey" :b "yes" "string-key" "should not include"} pred #(keyword? %)] (reduce-kv (fn [m k v] (if (pred k) m (dissoc m k))) m m)))
00:08clojurebot"Elapsed time: 1.471779 msecs"\n{:b "yes", :a "hey"}
00:09justin_smithten times faster than the select-keys
00:09tomjack(for no good reason besides superstition)
00:09justin_smith*slower
00:09ddellacostaI'm not sure we can determine much from testing on such a small set of values
00:09tomjackright :)
00:09justin_smiththat's true
00:10tomjackI guess the point of the reduce-kv is that you're seq-free
00:10justin_smithyou've still got a seq on the last arg
00:10tomjackno
00:10justin_smithno?
00:10clojurebotno is tufflax: there was a question somewhere in there, the answer
00:10ddellacostaI would think the main thing is to reduce (ha) the number of linear scans over the same set of data
00:11tomjackwell, I thought not
00:11tomjackbut maybe you're right
00:12justin_smithtomjack: this seems relevant https://github.com/clojure/clojure/blob/96e8596cfdd29a2bb245d958683ee5fc1353b87a/src/clj/clojure/core/protocols.clj#L180
00:12tomjackPHM and PAM's kvreduce are seq-free
00:12ddellacostawhat does having a seq vs. not do for you? Doesn't it still end up being the same amortized time?
00:12tomjackeh, not really
00:12tomjackI mean, not really seq-free I guess
00:12tomjackddellacosta: oh, yeah, absolutely
00:12julianlevistonis there a reject-keys? or should I just comp not my pred?
00:13justin_smithddellacosta: the difference is you have lower constant cost
00:13julianlevistoncomplement*
00:13tomjackbut if that's all we cared about, we wouldn't have PHM at all, would we?
00:13ddellacostajustin_smith: sorry, can you explain? I'm not getting it
00:13tomjack:)
00:13justin_smithddellacosta: same rationale as transducers - same time complexity, less time spent generating garbage
00:13julianlevistonerm.. that was a silly question… is there a reject keys?
00:13ddellacostajustin_smith: dissoc ?
00:13ddellacostaer, sorry, that was for julianleviston
00:13ddellacostasee tomjack reduce above
00:14ddellacostatomjack's *
00:14julianlevistonddellacosta: oh yeah, apply dissoc…stupid me!
00:14tomjackjustin_smith: it looks like kvreduce for PHM ends up going through a NodeSeq in PersistentHashMap.java
00:14ddellacostajustin_smith: still not quite getting it
00:14justin_smithright, you need a linear view of the keys no matter what
00:14tomjackbut looks to be less overhead than a normal seq, I think
00:14julianlevistonapply makes me somewhat anxious...
00:14tomjack(anyway I think it hardly ever matters :))
00:14ddellacostajustin_smith: so it's about space considerations?
00:15justin_smithddellacosta: two ops with the same time complexity can take a different amount of time due to overheads that are linear
00:15justin_smithit's about time constraints
00:16tomjackddellacosta: binary trees often can get O(log_2(n)) operations. We get O(log_32(n)) stuff for our 32-ary trees. But O(log_2(n)) and O(log_32(n)) are the same -- O(log(n)) -- because log_2(n) = 5 * log_32(n)
00:16justin_smithreductio ad absurdum: consider an operations that takes 1 ms per element and is O(n) vs. an op that takes 1 year per input and is O(n)
00:16justin_smithddellacosta: ^
00:16tomjackyet, for some reason, we still care about the difference
00:16ddellacostatomjack, justin_smith, okay, I think it's getting through my thick skull now--thanks
00:17justgregI was walking through this tutorial: http://clojure-doc.org/articles/tutorials/vim_fireplace.html and I can't get cpr to run properly even though I have classpath.vim in my pathogen .vim/bundle/ folder.
00:17ddellacostajustin_smith: did you mean constant above vs. linear though? "two ops with the same time complexity can take a different amount of time due to overheads that are linear"
00:17justin_smithddellacosta: linear as in their cost is multiplied by the side of the input
00:18justin_smithrather than being constant for the algo regardless of input size
00:18justgregI'm using vim in the terminal, executing from the correct path, with $lein repl running in a separate GNU screen terminal
00:18justin_smithjustgreg: are you sucessfully connected then?
00:18justgregjustin_smith, no, that's exactly the problem.
00:20justgregjustin_smith, it was working, then I removed a line related to autocomplete from my .vimrc -- because autocomplete wasn't working properly.
00:20justin_smithOK - I don't know enough about fireplace to help beyond that, sorry. Thought maybe it was an issue where my clojure knowledge would help.
00:21justin_smithhopefully someone else knows more about fireplace and can help you out
00:21justgregjustin_smith, thanks anyway. #vim sent me here.
00:21justin_smithI find it odd that the tutorial does not mention any explicit "connect to a repl" step
00:22justin_smithI would think such a command would exist
00:22justgregIt mentions the :connect command, but it also ought to connect automatically.
00:23justin_smithI would try figuring out how to run connect manually
00:24justgreg(nod) I'm just annoyed because it was working previously, and pathogen.vim appears to be working erratically.
00:24swarthyWhen I was using vim 'Vundle' was a much simpler package manager
00:24swarthyI had vim + fireplace working with that
00:25justgregswarthy, really? pathogen claims to just require putting everything in .vim/bundle
00:26swarthyVundle you just add the github repo as a line, plus two other lines to your vimrc
00:26swarthythen when you start vim
00:26swarthyit does it all automatically
00:26swarthyto connect though
00:27swarthyjust open two terms
00:27swarthyin one do $ lein repl
00:27swarthylook at the port number it shows
00:27swarthythen in the other term with vim
00:27swarthydo ':connect'
00:27swarthyfollow the prompts using default for everything
00:27swarthyexcept port
00:27swarthyenter that from before
00:27swarthyAlternatively, if everything is working you just open vim in the directory where there is a running repl
00:28swarthyand a subsequent
00:28swarthy'.nrepl-port' file
00:28swarthyNot to start a flame war, but I've found emacs + prelude + evil-mode a better experience.
00:28justgregrun :connect as a vim command or enter it in the file?
00:28swarthycommand
00:28swarthyit might be :Connect
00:28swarthyif that doesn't work
00:30justgregI'm starting to get fed up w/ vim and liking lisps more and more. I might just try to deal w/ my c-ish scripting langauges in emacs rather than lisps in vim.
00:32swarthyjustgreg: I had a hard time getting emacs going with evil mode on my own
00:32swarthyprelude makes it really easy to get up and running after being a vim user
00:32swarthyhttp://batsov.com/prelude/
00:32swarthyI recommend that, turning on evil mode is one line
00:32swarthya lot of vim stuff works
00:33swarthynot 100% but enough
00:33swarthyI used vim for several years, but I'm not die hard about it.
00:34swarthyhonestly I use vim for stuff still plenty, do the c stuff there. No reason to only use one thing, use whatever is best.
00:34justgregI never learned it especially well. I treat it more or less like a nano with syntax highlighting and indenting. I've also never genuinely tried emacs outside of learning sml in it, which was how I learned basic fp.
00:34julianlevistonprelude? haha I thought I was in the wrong channel there for a second :)
00:34swarthyoh like Prelude in haskell?
00:34swarthymight be where he got the name
00:35julianlevistonswarthy: yeah :)
00:35swarthyjustgreg: well prelude makes the barrier to entry basically 0. After two days I was flying around.
00:36justgregSweet. I was mostly looking for music-making in a language I could claim was making me a better programmer. There's a very good livecoding environment called Overtone.
00:36swarthyYeah, I've seen it & I tried their emacs thing a while back. It was a bit complicated and I gave up.
00:36swarthyMight be easier now.
00:36julianlevistonI really like stuff that bridges things. Clojure is very bridgy, obviously.
00:39julianlevistonSo I ended up with a “better” thing for selecting parts of a map… (defn select-filter [pred coll] (select-keys coll (keys (filter pred coll))))
00:39justgregI was *trying* to use a scheme dialect, but it's not very well-maintained.
00:40julianlevistonit makes things like this so much more readable: (let [expired-items (select-filter #(time-expired? (:timestamp %)) chan-maps)] …)
01:30wenshanI have two lists A: (1 2 3 4) and B (2 4 5 6), how do I do (- A B) to get (-1 -2 -1 -2)?
01:34kriyativewenshan: (map - '(1 2 3 4) '(2 4 5 6))
01:36tomjack(map - '(1 2 3 4) '(2 4 5 6) '(0 0 -1 0)) ? ;)
01:37kriyativeah, didn't see that ... I presume the second -1 was a typo?
01:48wenshankriyative: yes, that was a typo, (map - A B) works, thank you
01:51kriyativewenshan: as tomjack indicated, `map` extends to (map - A B C ...) etc.
01:53tomjack,(apply map vector [[1 2 3] [4 5 6] [7 8 9]])
01:53clojurebot([1 4 7] [2 5 8] [3 6 9])
01:54awwaiidQuestion for any overtone folks who might be here: (apply eval ['(piano)]) works, but (apply-at (+ (now) 1000) eval ['(piano)]) does not; it appears to have some issue that it is silently discarding. Any pointers?
01:54awwaiid(note that the eval is because the '(piano) is actually dynamically generated)
02:28wenshanhmm, I have a single file (not within a project) opened and started a REPL with cider-jack-in. Now how can I use the math functions (e.g. round)? Simply evaluating (use 'clojure.contrib.generic.math-functions) returns "java.lang.ClassNotFoundException: clojure.contrib.generic.math-functions"
02:30kriyativewenshan: try (Math/round 3.14)
02:30kriyativeI'm pretty sure clojure.contrib.generic.math-functions is deprecated
02:45wenshankriyative: thanks again, (Math/round 3.14) works, but (Math/round (/ 1 20)) does not work, I guess this is because (/ 1 20) is a ratio, not a number?
02:48TEttingerwenshan: to import a file without being in a project, you would still need some amount of lein usage. I think lein imports some of its dependencies into the REPL by default, one of which lets you download a dep in the repl
02:48TEttingerpomegranate maybe?
02:48TEttingeraether?
02:48TEttingerI can't remember
03:06rritochIs anyone here skilled with regular expressions?
03:06amalloy~anyone
03:06clojurebotanyone is anybody
03:09rritochI wrote a blog/tutorial on reverse engineering regular expressions, and was hoping someone could review it to see if there is anything I've missed, or if there are any technical errors.
03:16TEttingerrritoch, post away
03:16TEttingerI like em, I wouldn't say I'm that skilled with them
03:16rritoch--> http://www.ritoch.net/2015/02/22/the-exorcism-of-regular-expressions/
03:16TEttingerwasn't someone making a regex prover or something?
03:17rritochIt is a little themed to sorcery, but other than that it should be fairly easy to read.
03:17TEttingeror a type checker for regexes?
03:18rritochHmm, I don't know. I made some code to ungreedy a regular expression using clojure, but I'm not aware of the projects your mentioning. This is more a manual process for reverse engineering a regular expression, though much of it can be automated.
03:19rritochI'm also making the suggestion that programmers document their regular expressions, as if that would ever happen, lol
03:21TEttingernice article, rritoch
03:21TEttingerI scanned the second page, didn't read in depth, but it's sound advice
03:22rritochTEttinger: Thanks. I have to be honest, it took me 4 hours to write the blog and reverse engineer the example, but I think the end result is at least helpful.
03:22amalloyrritoch: are you really recommending documenting regexes by adding a commented-out verrsion with newlines and indentations, rather tahn recommending use of the /x flag?
03:23rritochamalloy: No, that is just a middle step of the reverse engineering process
03:24rritochamalloy: The final result is in the last code block.
03:24TEttingerambrosebs might have been?
03:25rritochamalloy: The final result is an approximation of BNF
03:27TEttingerrritoch: since such a big part of programming is giving names to things, the fact that regexes don't have much in the way of naming by default makes them hard to understand when they get large
03:27TEttingerI like your named component parser-style approach
03:33rritochTEttinger: Well, the idea came to me while manually translating a BNF language definition into Java code. After translating enough entries it occured to me that the process was somewhat reversable, so this is what I came up with to extract the functionality of a complex regular expression.
04:29the-kennyHm. Why is creating leiningen templates so painful? Copying all files over & then creating entries manually is cumbersome
04:33rritochthe-kenny: Leiningen is open source and can be extended with plugins. If your finding the process repetative you could probably make a plugin to automate the process. You would probably end up with a lot of users of the plugin.
04:44the-kennyrritoch: I know I know :/
05:09julianlevistonthe-kenny: or you could use that new thing instead of lein
05:09the-kennyjulianleviston: doing that right now. It's still pretty cumbersome
05:09julianlevistonthe-kenny: what’s it called again?
05:09the-kennynewnew
05:09julianlevistonthe-kenny: why’s it cumbersome?
05:09the-kennyoh no, wait
05:10the-kennyit's [lein-create-template "0.1.1"]
05:10the-kennyjulianleviston: still many manual steps. Cleaning up, etc. It creates a flat folder structure in resources/leiningen/new/ which is confusing in some situations.
05:10julianlevistonthe-kenny: I was talking about Boot
05:10the-kennyoh
05:11julianlevistonthe-kenny: sozzy :)
05:11the-kennyactually I'd like to be able to just specify a "normal" leiningen project as source and rename the namespaces. Like forking a git repository
05:12julianlevistonthe-kenny: make it so, captain :)
05:12the-kennyhaha :)
05:43wenshanb
08:48AeroNotixCan anyone recommend a websocket library for ClojureScript? The one that appears the most is Sente, but my god is it bloody complex
08:49dnolenAeroNotix: Google Closure Library has some stuff you can use if you want something more minimal.
08:50AeroNotixdnolen: all I really need is something that returns perhaps channel and has no huge opinions on what the message format should be
08:50AeroNotixhttps://github.com/james-henderson/chord seems reasonable at first glance.
08:51AeroNotixdnolen: if I were to use the google library, I wonder how easily I can map the JS docs into Cljs. Is that something you think is a barrier?
08:52AeroNotix(or perhaps some enterprisin' individual has converted the docs, I wouldn't be surprised)
08:52dnolenAeroNotix: the docs haven't been converted but there's really no need, CLJS interop is pretty simple after all.
08:53AeroNotixdnolen: I'm not really familiar with javascript at all tbh
08:53dnolenAeroNotix: it will be difficult to be as productive as possible with ClojureScript if you don't know JavaScript basic.
08:53dnolens/basic/basics
08:53AeroNotixI know the basics-ish
08:53AeroNotixlets say
08:54dnolenAeroNotix: then you probably won't have a problem
08:54AeroNotixcool, I'll persevere
08:54justin_smithAeroNotix: dude wrote the lang in a week, you shouldn't take long to get up to speed
08:55AeroNotixlol
08:55AeroNotixhttps://github.com/swannodette/om-async-tut oh this is nice
10:32sol__what does it mean if i have ^bytes in the signature? (defn foo [x ^bytes payload])?
10:33sol__oh, java type hints :)
10:36frznoskarth: is breakfast running live anywhere? Couldn't see it running in http://breakfast.clojurecup.com/
10:40AeroNotixfrzn: what the hell is that webpage haha :)
10:41frznAeroNotix: no idea! haha. But the oskarth project looks nice. I'm planning to use it, if I can get it to work.
11:10gfrederickshappy 10:10am to everybody in my time zone
11:12devllit is 10:00 pm here,but Happy to you too.
11:12gfredericksmust be one of those weird off-by-ten-minutes time zones
11:13devlllol. 10:12
11:13devllAny recommendations for scheduling libraries?
11:14gfredericks~this one weird time zone |will destroy| your faith in humanity; programmers hate it!
11:14clojurebotc'est bon!
11:14devllquartzite , at-at
11:15devllI am not sure which to pick.
11:17frznAeroNotix: #clojurecup-breakfast
11:17frznnow is running nice :)
11:17frzn(local)
11:17frznoskarth: nice job.
11:59irctc__I don't know if it's okay to ask here but quick question guys: why does (for [a (range 4), b (range a)] [a b]) give the same result as (for [a (range 1 4), b (range a)] [a b]) even though `a` should be starting from 0? It's giving me ([1 0] [2 0] [2 1] [3 0] [3 1] [3 2]) as the result. And I'm expecting it to start from [0 0].
12:01aroemersdevll: Depends on your usecase. I find at-at nice and simple. Quartzite has more features.
12:05vas_,(for [a (range 1 4)] [a])
12:05clojurebot([1] [2] [3])
12:06vas_,(for [a (range 4)] [a])
12:06clojurebot([0] [1] [2] [3])
12:06subhashgoirctc__ : (range 0) -> ()
12:07irctc__,(for [a (range 4) b (range a)] [a b])
12:07clojurebot([1 0] [2 0] [2 1] [3 0] [3 1] ...)
12:08irctc__oh
12:08irctc__subhashgo: ok thanks, it just hit me.
12:08subhashgoNo worries
12:08irctc__:)
12:13vas_irctc_: i think this is an appropriate place to ask that stuff, by the way, as it always helps me out when i try and provide an answer, so everyone wins :]
12:17irctc__vas_: that's good to know :) thanks for helping out too
12:38krasHi, why is this code hanging http://pastebin.com/yru9TzKx
12:38krasI am just trying out a basic loop recur
12:39krasAny hints will really help
12:41hyPiRion,(next '(1))
12:41clojurebotnil
12:41raekkras: use 'empty?' instead of 'nil?', and use 'conj' instead of 'concat'
12:42raekor, instead of changin the 'nil?', you could change the let to [e (seq v), res []]
12:43hyPiRionkras: what does (next v) return? :)
12:44kras,(next [1 2 3 4 5
12:44clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
12:45kras,(next [1 2 3 4 5])
12:45clojurebot(2 3 4 5)
12:45hyPiRionkras: Eventually, a better hint: What's the difference between (next v) and (next e)?
12:45raekkras: the propblem using 'concat' here is that it expects to sequences, but you are giving it a vector and an element
12:45kras:-|
12:45krasGot it thanks hyPiRion
12:46hyPiRionnp, was confused for a bit too
12:46krasI should be using the binded e inside the loop
12:46krasraek: thanks for the suggestions
12:50krasraek: concat works on two colls, whereas I am giving it one coll and one Long, so had to change it to conj
12:55kraswhat is an idiomatic way of checking an element's presence in a collection? Equivalent of "in" operator in python
12:57kras,(some #{2] [1 2 3 4])
12:57clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
12:57kras,(some #{2} [1 2 3 4])
12:57clojurebot2
12:57krasthis seems like an overkill
13:00the-kennykras: yes, that's the idiomatic way
13:00the-kennyIf your collection is a set, you can use contains?
13:07oskarthfrzn: thanks! It's currently not running live (the free server clojurecup offered expired afaik)
13:07oskarthfrzn: curious, how did you find it?
13:08frznoskarth: I found one project from clojurecup in hackernews, looked for others and found yours.
13:08oskarthoh cool
13:09oskarthhope it's useful!
13:09oskarthmeant to extend it and clean it up, but never happened :p
13:09frznI'm planning to create a integrated chat with IRC to put in a sidebar in my webapp.
13:09frznoskarth: I now how it is! haha
13:09frznbut it will be useful, for sure.
13:10oskarthawesome :)
13:10imanc_what's the best way to write gui apps in clojure?
13:32justin_smith imanc_ seesaw makes it pretty easy, people like the way javafx looks though
14:15vas_what's a good approach for caching database results between queries?
14:19justin_smithvas_: I've used a wrapper where an atom maps from queries to results, and insertions remove keys from the hash (so you don't get stale results)
14:20justin_smithvas_: also, eg. datomic is cached for you automatically
14:24gfredericksanybody know why clojure seems to name its functions one package level up?
14:25gfrederickse.g. (ns foo.bar) (defn baz []) creates the class foo.bar$baz
14:25vas_justin_smith: well i have not used atoms before, so i will have some researching to do ... I was trying to naievely just memoize the function that connects to the DB, but I can't invoke "nth" on the result set .. dunno why
14:25justin_smithvas_: atoms are pretty straightforward, it's worth taking a few hours to figure them out
14:26justin_smith,(let [a (atom {}] (swap! a assoc :a 0) (swap! a assoc :b 1))
14:26clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
14:26justin_smither
14:26justin_smith,(let [a (atom {})] (swap! a assoc :a 0) (swap! a assoc :b 1))
14:26clojurebot{:b 1, :a 0}
14:28vas_justin_smith: cool. arigato
14:30vas_by the way, some things just clicked for me the other day with enlive. was able to clean up my code immensely
14:30justin_smithvas_: for what you want atom / swap! (with assoc or dissoc) / @ should be all you need
14:30justin_smithcool
14:30vas_@?
14:30clojurebot@ is like the macro version of apply
14:30vas_lol thank you clojurebot! =D
14:31justin_smith,(let [a (atom "hello")] [a @a])
14:31clojurebot[#<Atom@267038a5: "hello"> "hello"]
14:31justin_smithnotice the difference between the two elements of that vector
14:31justin_smiththat's what @ does
14:31justin_smithit's a reader shortcut for deref
14:49gfredericksoh clojurebot was trying to talk about ~@
14:50justin_smithoh, that makes much more sense, yeah
14:50justin_smith~@?
14:50clojurebot@ is forget @
14:50justin_smithhahaha
14:52justin_smith~~@?
14:52clojurebot~@ is splicing unquote
14:52justin_smiththere we go
14:53kaplan_justin_smith, what is difference between unquote and splicing unquote?
14:53justin_smith,`(a b ~(+ 1 2 3))
14:53clojurebot(sandbox/a sandbox/b 6)
14:54justin_smith,`(a b ~@(+ 1 2 3))
14:54clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
14:54justin_smitherr
14:54justin_smith,`(a b ~@[1 2 3])
14:54clojurebot(sandbox/a sandbox/b 1 2 3)
14:54justin_smith,`(a b ~[1 2 3])
14:54clojurebot(sandbox/a sandbox/b [1 2 3])
14:54justin_smithit splices
14:55kaplan_justin_smith, that went over my head
14:57justin_smith~ unquotes
14:57clojurebotPardon?
14:57justin_smith~@ inserts a collection, unquoted
14:57clojurebotCool story bro.
14:58justin_smithI think I have a clearer way to show it
14:58justin_smith,(def a 42)
14:58clojurebot#'sandbox/a
14:58justin_smith,`(a ~a)
14:58clojurebot(sandbox/a 42)
14:58justin_smithsee how ~ made it unquote?
14:59justin_smith,`(a ~[a a a])
14:59clojurebot(sandbox/a [42 42 42])
14:59kaplan_justin_smith, ah, I see
14:59justin_smith,`(a ~@[a a a])
14:59clojurebot(sandbox/a 42 42 42)
14:59justin_smithnotice the differencebetween what ~[] did and what ~@[] did
14:59kaplan_yep
14:59kaplan_no vector around ~@
14:59justin_smithright, it gets spliced in to the parent
15:00kaplan_justin_smith, can you give a practical example of a macro?
15:01justin_smith,(defmacro spy [form] `[~'form ~form])
15:01clojurebot#'sandbox/spy
15:01justin_smith,(spy a)
15:01clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: form in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:01justin_smithhrm
15:02justin_smithright
15:02justin_smith,(defmacro spy [form] `['~form ~form])
15:02clojurebot#'sandbox/spy
15:02justin_smith,(spy a)
15:02clojurebot[a 42]
15:02justin_smith,(spy (+ 1 2))
15:02clojurebot[(+ 1 2) 3]
15:03justin_smiththe macro returns a vector containing the original input quoted, and what it evaluates to
15:03kaplan_justin_smith, ah, I see
15:04justin_smiththe general idea with a macro, is you return the form that should be evaluated
15:04kaplan_justin_smith, but I still can't think of anything where I might find this useful
15:04justin_smithdef is a macro
15:04benmossis there a decent way to access the version number of a lib from within the lib itself
15:04justin_smiththat's why you can just give the name you are defining, and don't have to quote it or anything
15:04kaplan_justin_smith, ah, I see
15:05justin_smithkaplan_: in general, you should rarely need to write macros. But they are very useful when you need them.
15:05justin_smiththey are for when you need to change the evaluation rules, or introduce a new syntax
15:07justin_smith"the first rule of macro club, is don't write macros"
15:07kaplan_justin_smith, are all of clojure's built in keywords like def built with macros?
15:07justin_smithkaplan_: there are a lot of macros in the language
15:07justin_smithactually, it's possible to build a list
15:08justin_smith,(filter (comp :macro meta) (vals (ns-publics 'clojure.core)))
15:08clojurebot(#'clojure.core/when-first #'clojure.core/cond->> #'clojure.core/gen-class #'clojure.core/while #'clojure.core/import ...)
15:08justin_smithin your repl, that will list all the things in clojure.core that are macros
15:08justin_smith&(filter (comp :macro meta) (vals (ns-publics 'clojure.core)))
15:08lazybotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
15:09justin_smithblergh
15:18crazydiamondHi. In CIDER, when *cider-error* buffer displayed, can I automatically jump to line/char where error happened?
16:05devllHi,in mf Compojure appindex.htm is a valid url. I want to trim "index.htm/".
16:05devll*my
16:07devllbut Compujure treats "index.htm" and "index.htm/" the same way
16:07devllIt never reaches my wrapper function.
16:09devllI can manage to trim urls like "/music/" to "/music",but not the "htm" files.
16:09devllHow can I trim this?
16:12justin_smithwhy is it not reaching your wrapper?
16:15devllnone of the static resources reach wrappers.
16:16devllI think "index.htm/" is treated as static.
16:16justin_smithoh, because your middleware is shortcircuiting the request
16:17justin_smithyeah, having a route that should be the same as a static resource is a bad idea, you should move one of the two
16:18justin_smithwhy does the file "index.htm" need to be in the static resources folder?
16:18devllit is in the public folder.
16:18justin_smithwhy?
16:18clojurebothttp://clojure.org/rationale
16:19AeroNotix~why
16:19clojurebothttp://clojure.org/rationale
16:19AeroNotix,why
16:19clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: why in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:19AeroNotixTHERE IS NO WHY
16:19AeroNotix:)
16:19justin_smithdevll: if you want something to be a route with a handler etc. then it shouldn't be a static resource, and visa versa
16:19devllI am just serving the file.
16:19justin_smithbecause one of the two is not going to work if you try to use both
16:20devll"index.htm" is not a route
16:20AeroNotixso you have a static file handler/middleware?
16:20AeroNotixand you have a 'chop-off-the-trailing-slash-middleware'
16:20AeroNotix?
16:20AeroNotixshow your routing code.
16:20devllI dont have static file mw
16:21justin_smithdevll: sorry, I misunderstood. In this case you need to switch the ordering of the static wrapping mw and the drop-slashes one
16:21AeroNotixjustin_smith: yeah^ Was thinking this was the case.
16:21justin_smithdevll: if the file is getting served, you do, it is likely hidden in the default ring middleware
16:21devll(route/resources "/")
16:21devll (ANY "*" []
16:21devll "404"))
16:22devlland I have many route like "/music"...
16:22devllOK
16:23justin_smithOK, so you explicitly serve resources
16:23justin_smithand you want to remove trailing slashes before that gets hit?
16:23devllyes.
16:24justin_smithdo you have a middleware that does this already?
16:24devllI have one chops trailing slashes
16:24devllIt does the jobs for "/music/"
16:25justin_smithbut you still get a 404 for /index.htm/
16:26devllin my case ,it is a file download
16:26devllI guess I should add a static mw and reorder it.
16:26devllam I right?
16:26justin_smiththat sounds right, yes
16:27devllOK. thanks. (inc justin_smith)
16:28devll(inc justin_smith)
16:28lazybot⇒ 192
18:42chr15mHello! I have been beating my head against the externs file requirement of Google's closure for days. I finally found this project, which fixed all of my problems by generating an externs file from my cljs code directly: https://github.com/ejlo/lein-externs - how come it only has two stars? Has everybody moved on from this? What do people use to handle the externs file situation?
20:06JavaDogCould anyone give me a quick hand? I'm doing this for a code gold thing:
20:06JavaDoggolf*
20:06JavaDog(drop iterator (remove #(.contains (take-nth (nth collection iterator) collection) %) collection)))
20:07JavaDogHowever, I get a "java.lang.IndexOutOfBoundsException: null" on this line. I think it's related to lazy sequences, and I've tried using (doall thatSeq), but I'm not sure whether I'm doing that right.
20:17irctc__is there an atom? equivalent in clojure
20:34gfredericksnope
20:34gfredericks,clojure.lang.IAtom
20:34clojurebotclojure.lang.IAtom
20:34gfrederickscan check against that
20:35gfredericksthere's a ticket somewhere about this I think
20:35gfredericks,atom?
20:35clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: atom? in this context, compiling:(NO_SOURCE_PATH:0:0)>
20:35cfleminggfredericks: Yeah, IIRC it might be for 1.7
20:39gfredericks,*clojure-version*
20:39clojurebot{:interim true, :major 1, :minor 7, :incremental 0, :qualifier "master"}
20:39crazydiamondHi. Is there ability to define functions like = for certain classes created with deftype?
20:42gfredericksI think overriding Object#equals will accomplish that
20:42gfredericksnot sure what other functions are "like =" that you're referring to
20:43amalloygfredericks: people who ask for an atom? equivalent usually mean it in the common lisp sense
20:44crazydiamondI'mhaving code like this: (deftype MyType [...] ...) (MyType. x [...]) (MyType. y [...]) (are_equal x y)
20:44crazydiamondand there I have almost everything in class definitions
20:44crazydiamondbut standalone function are_equal
20:45crazydiamondand I want it to be associated with types
20:45crazydiamondthough, everything works
20:45crazydiamondbut I still think it would be better to do association
20:47gfredericksamalloy: oh that sense of "equivalent"
20:58amalloygfredericks: i'm curious what other sense of equivalent you're thinking of
21:00TEttinger,atom?
21:00clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: atom? in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:00TEttinger,promise?
21:00clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: promise? in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:00TEttingerhm
21:00TEttinger,ref?
21:00clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ref? in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:00TEttingerare there any type checks for stuff like atoms?
21:01gfredericksamalloy: "equivalent to this thing from another language that actually exists" vs "equivalent to this imaginary clojure function"
21:01gfredericksTEttinger: what's a "type check"? you mean a function like the ones you're searching for?
21:01gfredericks,(->> (ns-publics 'clojure.core) keys (filter #(= \? (last (str %)))) shuffle)
21:01clojurebot[nil? fn? var? thread-bound? ifn? ...]
21:02TEttingerI guess, kinda like float? or something like it
21:02gfredericks,(->> (ns-publics 'clojure.core) keys (filter #(= \? (last (str %)))) shuffle)
21:02TEttinger,float?
21:02clojurebot#<core$float_QMARK_ clojure.core$float_QMARK_@3ee8c23e>
21:02clojurebot[future-done? odd? future? bound? zero? ...]
21:02gfredericks,(->> (ns-publics 'clojure.core) keys (filter #(= \? (last (str %)))) shuffle)
21:02clojurebot[pos? identical? every? future-cancelled? ifn? ...]
21:02TEttingerwhatcha doing gfredericks?
21:03TEttingerimaginary clojure, from the makers of invisible bike and high-performance INTERCAL
21:04TEttinger&(->> (ns-publics 'clojure.core) keys (filter #(= \? (last (str %)))))
21:04lazybotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
21:04TEttingerhaha
21:05TEttinger,(->> (ns-publics 'clojure.core) keys (filter #(= \? (last (str %)))) #(clojure.string/join " "))
21:05clojurebot#<sandbox$eval195$fn__196 sandbox$eval195$fn__196@5cdc4aaa>
21:05TEttinger,(->> (ns-publics 'clojure.core) keys (filter #(= \? (last (str %)))) (clojure.string/join " "))
21:05clojurebot"decimal? contains? every? satisfies? seq? fn? vector? thread-bound? isa? char? some? future-done? pos? sequential? neg? reduced? float? set? reversible? bound? map? volatile? var? empty? string? associative? keyword? even? extends? counted? future? zero? not-every? class? future-cancelled? sorted? nil? instance? record? identical? true? integer? special-symbol? ratio? delay? ifn? chunked-seq? dis...
21:05TEttingerso we have var?
21:06TEttingerand delay?
21:06TEttingervery odd
21:07gfredericksthere's a ticket for it
21:16gfredericks,(defmacro defmulti! [name & args] `(do (def ~name nil) (defmulti ~name ~@args)))
21:16clojurebot#'sandbox/defmulti!
21:20TEttingergfredericks, what... I'm slightly nervous to use that
21:22rhg135what is the point of this defmulti! i wonder
21:22gfredericksTEttinger: defmulti refuses to redefine things the second time you use it; defmulti! tricks it into doing so
21:22rhg135ah i see
21:23TEttingerthat's... devious
21:23gfredericksalso racey since the function is temporarily nil
21:24rhg135i don't think it's racey since do is guaranteed to run them in order
21:25gfredericksanother thread could call it while it's nil
21:26gfredericksI bet you could fix that by setting it to a proxy function instead
21:28rhg135oh I see
21:30gfredericksamalloy: oh I just figured out how to throw that dynamic var exceptoin
21:31gfredericksit looks like it is only possible with futures and agents
21:32amalloybinding conveyance? i sorta expected that to prevent it, not cause it, but okay
21:32gfredericksTIL that what futures and agents do is different from what bound-fn does
21:32gfrederickswhich is different from what starting a raw thread does, which was your original suggestion
21:33gfredericksdynamic vars what are you gonna do.
21:35crazydiamondHi. Is there a way to clean session in REPL? I'm using fireplace.vim and doing series of updates followed by %Eval. So, next time I hit eval, old things that I might deleted are still alive. Is there a way to start clean, each time I'm doing %Eval? (This effect makes Clojure sooo stateful for me).
21:43justin_smithcrazydiamond: clojure.tools.namespace has a namespace recet
21:43justin_smith*reset
21:43crazydiamondjustin_smith, thanks
21:44crazydiamond(clojure.tools.namespace.repl/refresh) works for me now
21:44TEttinger(inc justin_smith)
21:44lazybot⇒ 193
21:44TEttingeralmost to 200
21:44justin_smiththere is also stuartsierra's component for doing modular restarting of state
21:44justin_smithgetting close
21:48gfredericksis tonight the night that justin_smith gets to 200?
21:48gfredericksjustin_smith: quick start telling jokes
21:49justin_smithI've been lambda lifting all night, and boy are my arms tired!
21:49rhg135*crickets*
21:50gfrederickstonight is not going to be the night
21:53justin_smithMy wife, lemme tell ya folks, I try to explain to her, Liskov's substitution principle says I could just trade her in for a mentally disabled donkey...
21:56gfredericksa mentally disabled monkey is a subtype of your wife?
21:56justin_smithit's quite unfortunate
21:57justin_smith(not even dating not to mention married)
21:57rhg135ok...
21:57justin_smithsorry, I will stop making intentionally cringeworthy CS themed jokes
21:58justin_smithit was my "best" interpretation of henny youngman groaners
21:58justin_smithhttps://www.youtube.com/watch?v=i7gg8GGP79w
22:05gfredericksI listened to that entire thing and now I'm older
22:06justin_smithhehe
22:07chr15mdoes anyone else find this passive aggressive:
22:07chr15m$ git rebase --continue
22:07chr15mNo rebase in progress?
22:08chr15mmaybe i just need more sleep