#clojure logs

2011-03-23

00:21carlo_auhow do people use vim with clojure these days?
00:22carlo_authe site for vimclojure seems to be down/gone
00:46dakronecarlo_au: it's still being developed: https://bitbucket.org/kotarak/vimclojure
00:46dakronesomething must be wrong with the site
00:47carlo_audakrone: I cloned that bitbucket repo but it seems to be different to the vimclojure-x.x.x.zip bundle that people talk about installing
00:47carlo_auno README.txt, etc
00:50dakroneI'd post on the mailing list asking about it http://groups.google.com/group/vimclojure
01:17carlo_audakrone: will do
01:53Lulu58e2,(doc any)
01:53clojurebotPardon?
01:57pdktry some
02:05Lulu58e2Thanks
02:06Lulu58e2I keep thinking any when it's not-any
02:06Lulu58e2(but yeah, some is what I was looking for)
02:09Lulu58e2Is there a function to get all the values of a map for a list of keys?
02:13cemerick,(-> {:a 5 :b 6 :d 9} (select-keys [:b :d]) vals)
02:13clojurebot(9 6)
02:14cemerickLulu58e2: ^^
02:14Lulu58e2Wicked, thanks
02:14Lulu58e2I was only down to the "m"s in the API
02:14cemerickor…
02:15cemerick,((juxt :b :d) {:a 5 :b 6 :d 9})
02:15clojurebot[6 9]
02:18cemerickknowing what order the vals are coming out in is generally good
02:18Lulu58e2Okay, I don't have keyword keys, so the first will work
02:21Lulu58e2?
02:21Lulu58e2I'm not sure I follow you there.
02:24Lulu58e2Does one of those functions ensure order?
02:25Lulu58e2Oh, nevermind, juxt would
02:25Lulu58e2I see now
02:34Lulu58e2,(doall (map #((fn [] (print %))) (take 5 (range)))
02:34clojurebotEOF while reading
02:34Lulu58e2,(doall (map #((fn [] (print %))) (take 5 (range))))
02:34clojurebot01234
02:34clojurebot(nil nil nil nil nil)
02:37Lulu58e2Didn't need the extra parenthesis around fn
02:47Lulu58e2,(map (fn [f] (f)) (map #(fn [] (* % %)) (take 3 (range))))
02:47clojurebot(0 1 4)
02:48Lulu58e2Okay, that's what I was trying to get across. Is there a cleaner way to generate a function operates on each element of a list?
02:50Lulu58e2I need a list of curried functions (I'm not sure if the term applies here, exactly)
02:52Lulu58e2partial might be what I need
03:53raekLulu58e2_afk: also consider using 'for' ##(let [fs (for [n (range 3)] #(* n n))] (for [f fs] (f)))
03:53sexpbot⟹ (0 1 4)
04:08tomojfor+->>, evil?
04:12tomojhttps://gist.github.com/44ebe95923fa6a4bc5c7 extremely evil
04:13tomojotoh &(->> (* x x) (for [x (range 10)]) (map inc))
04:14Deranderwhy am I awake?
04:14tomojkinda neat looking but ultimately pure evil I think
04:15opqdonut:D
04:15opqdonutindeed
04:16tomoj&(->> (throw (Exception.)) (if true 4))
04:16sexpbot⟹ 4
04:18tomoj&(map #(-> % :name (if "named!" "unnamed!")) [{:name "bob"} {:age 23}])
04:18sexpbot⟹ ("named!" "unnamed!")
04:18raek-> and ->> feels kinda weird with macros
04:18tomojall kinds of crazy stuff I never thought of..
04:19tomoj"kinda"? :)
04:22raekfrellin' K-RAY-Z.
04:23raek(->> (f x z v) (when-let [x y]) (when-let [z u]) (when-let [v w]))
04:24raek(->> (f0 a b c) (when-let [c (f3 b)]) (when-let [b (f2 a)]) (when-let [a (f1 x)]))
04:25raekthis feels like a reversed maybe monad
04:35TobiasRaederMorning
04:36hiredmanhttps://github.com/clojure/clojure/commit/8fda34e4c77cac079b711da59d5fe49b74605553
04:36hiredmannice
04:36hiredmanhttp://clojure02.managed.contegix.com/display/design/Improvements+to+interop+from+Java
04:36hiredmanrhickey's comments at the bottom are great too
04:46opqdonuthaha
04:48raeknice.
05:10ejacksonmorning y'alls
05:13Raynesejackson: Good morning.
05:40RaynesTuna fish and mayo sandwich for breakfast.
05:45ejacksonbreakfast of champions
05:46RaynesOr the poor.
05:46RaynesScavengers.
05:47ejacksonwell, I had oats, yummmmmm
06:08robonobohi, does anyone know if there is a tarball available for the newly released leiningen 15 and where I might get it?
06:08robonobos/15/1.5
06:08sexpbot<robonobo> hi, does anyone know if there is a tarball available for the newly released leiningen 1.5 and where I might get it?
06:09raekrobonobo: check the download page at https://github.com/technomancy/leiningen
06:09raekhttps://github.com/technomancy/leiningen/tarball/master
06:09raekor maybe https://github.com/technomancy/leiningen/tarball/1.5.0
06:09clojurebotGabh mo leithscéal?
06:14robonoboraek: i needed the last one, thanks
06:29raekrobonobo: are you building leiningen yourself?
06:30robonoboraek: i updated the lein package in homebrew (mac package manager)
06:30raekah
06:50thorwilhmm, if i use ring's wrap-params with a handler without explicit arguments, i can access request parameters in the defn
06:50thorwillike in the example on http://clojuredocs.org/ring/ring.middleware.params/wrap-params
06:51thorwilbut what if i want to pass an explicit argument to my handler, in addition?
07:21xkbhi
07:21xkbI'm trying to solve this: http://www.algorithmist.com/index.php/UVa_103 using Clojure
07:22xkbI already figured the sorting part out myself, and I'm now trying to apply the LIS algortihm
07:22xkbthe "standard" algorithm uses a matrix to keep track of the results of comparing lists
07:22xkbhow would you implement this in clojure?
07:29ejacksonxkb: i don't know the algo, but probably through returning it in a reduce or in a recursion
07:32clgvxkb: if you can give us pseudocode or a mathematical description of the algorithm we might try to come up with a clojure implementation ;)
07:36xkbclgv: my link contains another link to a c++ implementation
07:36xkb(and the math specs)
07:37xkbmy attempt thusfar is on: https://gist.github.com/882976
07:38xkbmy lcs should probably be adapted for this problem
07:41clgvthe c++ "implementation" scares me... O.O
07:43xkbclgv: ye.. I had the same
07:43xkbclgv: that's why I wanted to create a clean clojure implementation
07:43xkbI found several on the web, Java, C, C++ and they are all ugly
07:43clgvit's indeed plain C but using vectors from C++ and using global variables implicitely in a function...
07:47clgvthis one looks more concise
07:47clgvhttp://www.algorithmist.com/index.php/Longest_Increasing_Subsequence.cpp
07:49xkbah that's readable indeed
07:49clgvwas linked by the wikipedia entry on the problem
07:49xkbfinding a LIS is not really a problem though, my main problem is how to apply it to the problem
07:50xkbmost solutions use some kind of "side-effect" to keep track of the end-result during the calculation of the stacking boxes
07:50xkbthe java version uses the diagonal of a (nr-of-boxes x nr-of-boxes) matrix
07:50clgvdo you need a fast approach?
07:51xkbnah, just an elegant one :)
07:51clgvthan you could just sort all vectors internally and then sort the vectors lexicographically
07:51xkbthat's what I do now
07:52xkbfirst each box, then all boxes
07:52xkbthat still doesnt solve it, you need some kind of trail
07:52xkbe.g. box 1 fits in 2, 2 fits in 4
07:53clgvhm yeah. you have to decide which boxes to skip to reach the longest sequence
07:54xkbindeed
07:54clgvyou could do an exhaustive search on that or try a branch-and-bound approach. wikipedia also suggests dynamic programming
07:54xkband that's where I get stuck
07:54clgvI dont know if there is a suitable bound function though...
07:54xkbtranslating the DP to Clojure kinda messes with my mind
07:55clgvhumm my first thought is that you might translated DP naturally with lazy-sequences
07:56clgve.g. if you have a 2 dimensional DP you could make a lazy-sequence for every row
07:56clgvthis way you only calculate what you really need and you have the intended "caching effect"
07:56xkband stop if the condition fails, for each combination of rows?
07:57clgvno, I was already referring to a DP translation of the problem
07:57xkbah :)
07:57clgvusually it stops when you calculated cell (N,N) or (N,1)
09:06thorwili have this as part of my routing (using moustache): post (app wrap-params [[path not-empty] &] submit-article)
09:07thorwilin (defn submit-article ...) i can destructure the request parameters just fine
09:07thorwilbut i want to have "path" available, too
09:08thorwilwithout wrap-params, it would be: (app [[path not-empty] &] (submit-article path))
09:09thorwili can't find a way to combine both, it's always wrong number of parameters
09:09Chousukethorwil: can you use partial?
09:09Chousukeeg. (partial submit-article path)
09:10ChousukeI don't know how the functions work though so the closure you get might not be what you want.
09:11thorwilChousuke: java.lang.UnsupportedOperationException: nth not supported on this type: PersistentHashMap
09:12Chousukeoh well, I guess not, then.
09:12thorwilassoc-param sound like it could be the right thing: http://mmcgrana.github.com/ring/middleware.params-api.html
09:12thorwilbut i fail to find out what the right value for "map" is
09:13Chousukethorwil: any map, it seems.
09:57Dranikhi all
09:57Dranikhow to read a text file and get a list of lines?
09:58gfrlogthere is slurp and split
09:58gfrlog,(doc slurp)
09:58clojurebot"([f & opts]); Reads the file named by f using the encoding enc into a string and returns it."
09:59gfrlog,(doc clojure.string/split)
09:59clojurebotIt's greek to me.
09:59gfrlogdang
09:59gfrlog,(doc split)
09:59clojurebotGabh mo leithscéal?
09:59Dranikthanks
09:59gfrlogsure
10:00clgvDranik: there is also clojure.java.io/reader and line-seq
10:00TimMcdrewolson: line-seq
10:00TimMcAh, clgv beat me to it.
10:00gfrlogI knew there was a better answer. I just didn't say that I knew it.
10:01TimMcSorry, Dranik ^
10:01Dranikclgv: thanks!
10:01TimMcDranik: Here's an example: https://github.com/timmc/CS4300-HW4/blob/master/src/timmcHW4/core.clj#L268
10:02Dranikfeeling myself like a complete newbie :-)
10:02TimMcDranik: http://clojuredocs.org/ is your friend
10:03clgvyeah, you can completely forget about IO when developing algorithms and such. who needs IO then? - wait! where do I get my problem instances from? ;)
10:03DranikTimMc: feeling myself like a complete newbie :-)
10:07gfrlogthere should be something in clojars where I can mark a lib as "don't even resolve its own dependencies"
10:08angermanin what kind of idiotic region do i live in where people shout "m… m… monster grilling"...
10:13TimMcgfrlog: What's this now?
10:14gfrlogTimMc: if I have a bare project with one dependency, and "lein deps" fails...
10:14gfrlogthen BOOO
10:14ejacksonangerman: I can't even begin to speculate on that one
10:14gfrlogfortunately this dep has a forked version on clojars, I suspect for exactly that reason
10:14TimMcIt has a dependency that is not in repos?
10:15gfrlogI believe so
10:15gfrlogsome highly specific version of jetty
10:15gfrlogorg.jboss.netty:netty:jar:3.2.0.BETA1
10:15gfrlogis the indirect dependency that fails
10:15gfrlogfor the "plaza" lib
10:26drewrdepends on how you define web dev
10:27drewrif it's HTTP protocol work I like clojure but for browser-facing work I still like django
11:01Guest57647raek: Thanks, I'll have a look at your suggestions
11:02raektechnomancy: is there a way to export an epresent presentation to, say, a pdf? (for those who has not yet converted to Emacs)
11:05clgvraek: and hopefully also for those that never will ;)
11:06clgvexcept if you make only presentations related to emacs ....
11:55TimMctechnomancy: Ran into the :repl-retry-limit today. Any particular reason it is specified using the number of retries (with a fixed sleep in between) rather than a total timeout period?
11:56sritchieamalloy: hey, I JUST saw this message you sent over a month ago -- http://commons.apache.org/io/api-release/org/apache/commons/io/input/SwappedDataInputStream.html
11:57amalloyhah
11:58amalloysritchie: how did you avoid seeing it for a month?
11:59sritchiesexpbot had a message for me, and I was on so erratically that I clicked away the message on colloquy each time
11:59amalloyhaha
11:59sritchieso, it turned out to be much faster to do a bulk read into a byte array, then this -- https://gist.github.com/883338
12:00sritchieI actually wanted to ask you about my little-float method. clearly there's a pattern here that I can abstract away
12:01amalloywell first i'd change 'bits' to 'bytes' :P
12:02sritchiewhoops, nice
12:02sritchieI'll ask this without examining the function first, as I haven't peeked at it in a while -- is this a good candidate for a macro, to write out that code
12:03amalloyhm. maybe. it seems like reduce would get you most of the way there though
12:04amalloyand map-indexed to do the shifting and anding
12:07sritchieamalloy: this feels like a good one to practice
12:07sritchies/to/for
12:07sexpbot<sritchie> amalloy: this feels like a good one for practice
12:07RaynesFor a minute there, I thought he was going to say that he couldn't figure out how to retrieve the message, at which point I'd have loaded my rifle and shot myself in the face.
12:08sritchieRaynes: haha, yes. I'd prefer if sexpbot would text message me every twenty minutes... that would make like easier
12:08RaynesHeh
12:08amalloysritchie: sure, it's not a terrible idea to make this a macro. i think the macro version will end up looking a lot like the function version, so if you want practice maybe you should write both and compare
12:11sritchieamalloy: quick skype call, but that's a good idea. I'll go play with these and report back in a bit
12:16Caffeineif (symbol? (symbol 'meh)) => true && (def (symbol 'meh) '(1 2 3)) => "First arg to def must be a symbol" then what am I missing?
12:17amalloyCaffeine: first arg to def is a list: elements are 'symbol and ''meh
12:17amalloybecause def doesn't evaluate its first argument
12:17Caffeineuh
12:19dnolenCaffeine: def is a special form.
12:19Caffeineokk... I should use set! in these cases I guess
12:20amalloyCaffeine: usually you should rethink why you find yourself in these cases
12:20dnolenCaffeine: what are you trying to do?
12:20CaffeineI have not-yet-symbols .. and I want to give them a value ... ('not-yet-symbol '(its future value))
12:21Caffeineamalloy: Yeah, I'm probably not thinking this stuff right
12:21dnolenCaffeine: what are not-yet-symbols?
12:21amalloyi often see this sort of pattern: (defn f [args] (letfn [(f* [args] (f* something recursive))] (f* args)))
12:21amalloyin my own code i prefer to write (defn f [args] ((fn f* [args] (f* something recursive)) args). does anyone think this is substantially less readable and i shouldn't do it?
12:22Caffeinebrb gotta go NOW sorry
12:29technomancyraek: no, just running htmlize on the org source.
12:29technomancyTimMc: no reason in particular. I didn't imagine anyone would actually run up against that in real life
12:30technomancyTimMc: unless the problem was that it started trying to connect before downloading deps; that's something I really should address.
12:31TimMcInteresting... 100 is the default, and it sleeps for 100 millis... so it should time out after 10 s, yeah?
12:34TimMcOK, yeah, that's about right. Anyway, it's only affecting me intermittently.
12:35technomancyTimMc: it sucks that you can't configure that on a user-wide basis. you caught me approximately 12 hours too late to get that into 1.5.0 =(
12:36TimMcHah, it's fine.
12:36TimMcI was able to debug the "couldn't connect" message with a Google search.
12:37technomancy(require 'leiningen.repl) (alter-var-root #'leiningen.repl/*retry-limit* (constantly 200)) ;; in ~/.lein/init.clj if you like
12:37TimMcThanks, I might use that.
12:52Dantasejackson: hello :) fine ? Look, could i bothering you with another question ?
13:53tsdhHi
13:53tsdhI have a LazySeq question.
13:54midstsdh: go ahead and ask
13:54scottj(doall tsdh)
13:55tsdhIf I do something like (do (time (foo-1 (get-lazy-seq))) (time (foo-2 (get-lazy-seq)))) where `get-lazy-seq' is a function returning a LazySeq, and foo-{1,2} do something with that (realize them), the foo-2 call is much faster. Does that mean that a LazySeq's realization is cached somehow?
13:56parasebaHi. I have a java.sql.Connection, I want to override the close method. Do I need to override each and every method of Connection interface, like when using reify? is there any workaround?
14:00TimMctsdh: Indeed.
14:01joegalloMaybe use proxy?
14:01tsdhTimMc: Cached forever, or until memory gets exhausted (aka, implemented as sort of WeakReferences)?
14:01TimMctsdh: Except it's not really cached -- it's computed, and you're holding onto the head of a linked list.
14:02TimMctsdh: The trick is that the rest of the list, past some point, simply hasn't been computed yet.
14:02parasebajoegallo: I have a Java object, to which I want to forward every call except for one. proxy also requires you to declare every method in the interface
14:03parasebawhat I want is actually to wrap my instance, and forward *almost* every method call to it
14:03tsdhTimMc: I don't see exactly where I'm holding onto the head in my code above.
14:04TimMcAh...
14:04TimMcI see what you're asking now.
14:05TimMcI wonder if JIT is affecting this.
14:05amalloytsdh: if (get-lazy-seq) returns a new seq every time, the most plausible explanation is that foo2 is faster than foo1
14:05amalloytry (do (time (doall (get-lazy-seq))) (time (doall (get-lazy-seq))))
14:06parasebatsdh: maybe you could try reverting the order of calls to foo-1 and foo-2?
14:06tsdhamalloy: I have a testmacro that gets equivalent forms that should compute the same, compares the results, and times each execution. Whatever I provide as first form is slowest.
14:07tsdhArgh!!!
14:07amalloy&(do (time (= (doall (range 1e6)))) (time (= (doall (range 1e6)))))
14:07sexpbot⟹ "Elapsed time: 518.640372 msecs" "Elapsed time: 583.172628 msecs" true
14:08tsdhOf course, to compare *all* results, map them to =, and thus I hold onto the heads! ;-)
14:08jkkrameryou could run using dotimes and drop the first few runs to account for hotspot
14:08angermanwow. Just got the hang of sandbar…
14:09tsdhThat's what I really like here. I ask something, we start discussion, and your replies point exactly into the right direction so that I can spot the error myself, and don't have to feel like an idiot. :-)
14:11amalloytsdh: it still doesn't seem like that should lead to the behavior you were seeing. if anything i'd expect the second to be slower, because it has more memory contention
14:12tsdhamalloy: That's only because my example code doesn't match the code where I see the issue.
14:12amalloyhah
14:12amalloythat's something you should consider not doing! :)
14:12tsdhamalloy: The latter is more like (map foo (foo-1 (get-lazy-seq)) (foo-2 (get-lazy-seq))).
14:12joegalloparaseba: i'm not sure i see why you can't just proxy the class in question...
14:13joegallo(.run (proxy [Thread] [] (run [] (println "foo")) --> prints foo
14:14parasebajoegallo: the thing is Thread acts as your base class, providing all methods. I only have an instance (already created) and an interface with lots of methods, only one of which I'm interested in overriding
14:14joegalloah, so you can't override the class of the instance, because you aren't in control of the creation of the instance
14:15parasebajoegallo: exactly
14:15joegallookay, makes sense to me now
14:16parasebajoegallo: there is probably something wrong with my reasoning, but it seems a pretty common use case. Something like an on-the-fly wrapper
14:16joegalloyeah, it would be nice
14:22parasebamy actual use case, is I want to run a service and its tests in the same transaction (to clean up everything after the tests are run), so I want a no-op when the db connection is closed
14:27dnolenusing SLaTeX to output Clojure == lovely typography.
14:32__name__Example or it did not happen.
14:32dnolen__name__: blog post forthcoming.
14:34sritchieamalloy: so! just had time to look at my function. here's what I've got -- https://gist.github.com/883338
14:34__name__dnolen: URL?
14:34__name__(To your blog.)
14:34dnolen__name__: http://dosync.posterous.com
14:35sritchiethe reduce step tidies things up really nicely. the next step is doing one map across (butlast bits), and one across (rest bits) -- the problem is that I want to pass that missing element along, unchanged
14:35amalloysritchie: i don't see why you're treating the last byte as a special case
14:36angermandnolen: "a large number of interesting logic program(s?) can be written"
14:36amalloyie, first-pass can bit-and the lowest-order byte with 0xff anyway. it won't *do* anything if it's already less than 256, but so what
14:36sritchieah, that's true. I'm making the mistake of trying to replicate my java code
14:37amalloyjava code is self-replicating. you can't stop it from spreading, like rabbits
14:37dnolenangerman: thx
14:37sritchieyes! it even forces my clojure abstraction passes to get longer and longer
14:38angermandnolen: you'r welcome.
14:41amalloysritchie: similarly for the map-indexed. nobody minds if you shift something by zero
14:42sritchieamalloy: okay, here's another pass -- https://gist.github.com/883338
14:42angermanOhh firefox. … why can thou not have your tabs up high like Chrome/
14:43semperosangerman: Firefox 4
14:43angermansemperos: yes.
14:43amalloysritchie: bit-xor is associative and commutative; what's the point of a reverse?
14:44amalloythen, you can combine the map-indexed and the map into a single map-indexed of two stages, or leave it this way if it's more readable
14:44sritchieamalloy: working on that last comment now
14:45angermanwow. but FF4 is fast.
14:45amalloythat is, (map-indexed f (map g list)) is (map-indexed (fn [idx val] (f idx (g val))))
14:46amalloymodulo a "list" i forgot at the end of the second version
14:47sritchieamalloy: https://gist.github.com/883338
14:48amalloyhooray, looking much shorter now. i'd use ->> to reduce the nesting, personally
14:48amalloy(->> bitseq (map-indexed (fn...)) (reduce bit-xor) (Float/intBitsToFloat))
14:49sritchieI could toss -> into that internal anonymous function too
14:49amalloycould you?
14:49bartjer, I would like to get my feet wet with contributing to open source Clojure projects
14:49amalloyoh, i guess so
14:49bartjapart from core/contrib
14:50bartjwhat would be a good bet please?
14:50amalloythat seems like a less clear gain to me, but it's not inherently bad so feel free
14:51sritchieamalloy: haha, I agree, I'm just pleased with these iterations
14:51amalloyand now that you've got it down to a minimal form, it becomes pretty clear how you can generalize it
14:52amalloyas a macro with a slot for Float/intBitsToFloat, or a function like (littleize #(Float/intBitsToFloat %) bitseq)
14:52sritchiehttps://gist.github.com/883338
14:53sritchieit's amazing how clean these functions can become
14:54amalloysritchie: if i were going to use ->, i'd write (-> (bit-and bit 0xff) (bit-shift-left (* 8 idx))). not sure why, really, but it feels better
14:54amalloyobviously that's a pretty vague critique; stick with yours if you prefer it
14:55amalloysritchie: did you read my article on The Evolution of An Idea? if you like this kind of iterative process you might find it interesting
14:56sritchieamalloy: I did, I found it really interesting
14:57sritchieI'm going to start blogging about some of this hadoop stuff, and I really enjoyed the format of that article
14:57amalloyooc why use bit-xor instead of bit-or?
14:57sritchiethe results of all this are interesting, of course, but I really enjoy seeing the process
14:57amalloyor even +
14:59sritchieamalloy: I guess the real reason is that when I started this, I didn't know how to convert a bit sequence into little endian format, so I found an example in java, then went about the exercise of generalizing it using clojure
15:00sritchie+ is giving me the right answer, but I had thought you needed a bitwise operation to combine these, after the bit shifts
15:01amalloysritchie: you constructed a list of integers, each of which is a sequence of bits, and you've carefully arranged it so no two integers have one bits in the same place
15:01amalloyif you never need to carry, then + is just |
15:02sritchiedoes that work for eight byte numbers, though?
15:02sritchiesince java uses four bytes for integers?
15:03sritchiepardon if that misses the point
15:03sritchieyeah, I guess it doesn't change anything
15:03amalloyyeah, it shouldn't
15:26Lulu58e2amalloy: can I have a link to that article?
15:26amalloy$google amalloy hubpages evolution of an idea
15:26sexpbotFirst out of 16 results is: What is Clojure? - HubPages
15:26sexpbothttp://hubpages.com/hub/What-is-Clojure
15:26amalloydamn
15:26amalloyhttp://hubpages.com/hub/The-evolution-of-an-idea
15:27Lulu58e2thx
16:22technomancybartj: if you are still looking, clojars needs help
16:25bartjtechnomancy, is there a bug list somewhere?
16:26technomancybartj: unfortunately no, it would kind of be a self-starter thing. the maintainer has mostly disappeared. maybe not the best place to start if you're looking for more guidance.
16:28raekheh, there's a lib called robert/bruce
16:28raektechnomancy: looks like ol' hooke got some company in the repo: http://clojars.org/repo/robert/
16:30technomancyroberts unite!
16:31chouserIs this supposed to work? https://gist.github.com/883884
16:33raekhrm. if I changed (.x this) into x, it didn't throw
16:34bartjtechnomancy, you mean this - https://github.com/ato/clojars-web/issues
16:36technomancybartj: yeah, that's a good list. see if you can get a response on http://groups.google.com/group/clojars-maintainers before sinking much time into it.
16:37bartjtechnomancy, who is ato? have never seen ato here?
16:37chouserraek: I keep forgetting deftype instance fields are available with bare names like that
16:37technomancybartj: he disappeared over a year ago =(
16:38chouserbut it doesn't seem to work
16:38bartjtechnomancy, has anybody taken over (partially I mean) the project yet ?
16:39technomancybartj: no, but at least a few others have root access to the server
16:39hiredmanthe type inferered by the compiler is the wrong type
16:39technomancyif he's totally unresponsive we should be able to deploy new features
16:40chouseroh, wait.
16:40hiredmanit is the stub type used to generate non-reflective calls
16:44chouserok, but raek's syntax is correct and works around the problem.
16:45bartjtechnomancy, I have applied for membership to clojars-maintainers. do you have permissions to grant membership?
16:47technomancybartj: sure
16:49waxroseDo you necessarily have to be well versed to be accepted as a maintainer? (silly question)
16:50technomancywaxrose: good question. there aren't really any ground rules here. fresh blood could probably pull it off with a little oversight.
16:50technomancyI don't have the time to take it over myself, but I might be able to handle doing code reviews &c.
16:53waxrosehmm, sounds hopeful then
16:54seancorfieldamalloy: love your evolving of an idea hub page... i tweeted it and then wasn't sure if @amalloy on twitter is you :|
16:54amalloyseancorfield: it's not me, sadly
16:54amalloyi'm @alanmalloy
16:54seancorfieldah, ok
16:56seancorfielddeleted my tweet and posted a new one highlighting you... thanx
16:56seancorfieldalso realized i wasn't following you :(
16:58amalloydude, i didn't even realize you could delete tweets. this whole twitter thing is still a mess for me
16:59amalloyhaha. looking at someone's tweet which begins "the thing about clojure", and twitter has helpfully pointed me to other tweets mentioning "the thing"
16:59hiredman~search for the+thing
16:59clojurebot<#clojure:amalloy> haha. looking at someone's tweet which begins "the thing about clojure", and twitter has helpfully pointed me to other tweets mentioning "the thing"
16:59clojurebot<#clojure:amalloy> dude, i didn't even realize you could delete tweets. this whole twitter thing is still a mess for me
16:59clojurebot<#clojure:technomancy> bartj: unfortunately no, it would kind of be a self-starter thing. the maintainer has mostly disappeared. maybe not the best place to start if you're looking for more guidance.
16:59clojurebot<#clojure:paraseba> joegallo: the thing is Thread acts as your base class, providing all methods. I only have an instance (already created) and an interface with lots of methods, only one of which I'm interested in overriding
17:00hiredmanhuh, maybe I don't have a handle on this lucene query syntax
17:00amalloyhiredman: the second one looks weird to me. "the" isn't mentioned
17:00hiredmanthe maybe be a stopword
17:00hiredmanmay
17:01hiredmanhttp://en.wikipedia.org/wiki/Stop_words
17:01semperosso if I have a fn that takes & args, and I need to pass the & args to another function's & args, how do I do it? (make sense?)
17:01hiredman(doc apply)
17:01raeksemperos: (defn f [& args] (... (apply g args) ...))
17:01clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
17:02semperosyeah, thought so
17:02semperosI keep asking the same question in different forms over the weeks...
17:03semperosthanks hiredman raek
17:05semperosbrehaut: got your mail, but it was cut off at "to send a nil to a"
17:17raekwhat swing component would you use to display a text file? JTextArea? JTextPane?
17:18amalloysemperos: if you provide the rest of his mail, i can probably complete it in a way that will almost make sense but will make brehaut sound dumb
17:19semperosdoubtful
17:19semperoswe like brehaut
17:19semperoshe's finished it for me, regardless, but thanks for the thought
17:20semperosraek: what do you want to do with the file?
17:21raekdisplay it to the user (read only)
17:21brehautamalloy: who said you needed to fabricate stuff to make me appear dumb?
17:21raekI'm making a client for the Gopher protocol...
17:21semperosany reason a JTextArea won't work?
17:21raeknot that I'm aware of...
17:22raekI also wonder how it handles large files
17:23semperosconsider the scroll panes
17:23semperoshttp://download.oracle.com/javase/tutorial/uiswing/components/textarea.html
17:25brehauttechnomancy: at least the comments are up to date :/
17:25technomancybrehaut: "TODO: figure out how to do stop words with an sql select" uh... =\
17:26brehauttechnomancy: the comments about it being a bit stupid was what i was thinking of
17:27technomancybrehaut: well that's not even about search; it's about parsing the results
17:27technomancythe best part is there's a lucene index on disk already
17:27raekhrm, should I really read the whole stream into one big string?
17:27brehautoh dear
17:27technomancyall this to say: yes, it needs some work.
17:36bartjtechnomancy, do you have a running instance of clojars-web on your local m/c ?
17:36semperosraek: question for me would be, if you're going to have such massive files that it would be a burden to load one all at once in a read-only JTextArea, is it providing a good service having it there?
17:36semperosas part of the gui, that is
17:53[hercynium]_I'm stumped (and a noob) - I've got a function that returns a list of (:foo "val1" :bar "val2") ... how do I turn that into a hash-map?
17:54hercynium(hash-map (this-function)) certainly doesn't work :)
17:55hiredman(doc apply)
17:55clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
17:55jkkramer,(apply hash-map '[:foo "val1" :bar "val2"])
17:55clojurebot{:foo "val1", :bar "val2"}
17:56hercyniumooo, I see. thanks!
17:57amalloy&(sequential? (sorted-map))
17:57sexpbot⟹ false
17:57amalloyanyone think that should be true?
18:00amalloyin practice i think it would lead to some issues, but it seems like in theory it makes sense: there's a specific order for traversing the map
18:12hercyniumooo, got it working! \o/
18:17bartjhercynium, if you have your keys and values in separate lists, zipmap would be ideal, IMO
18:18hercyniumbartj: yeah, I saw that, and I think I can use apply to enable that and make the code I have a lot shorter
18:19ampleyflyis there a way to cause leins .m2-directory to be placed somewhere else than ~ (on windows, specifically)?
18:22amalloyampleyfly: i'd look at maven settings, not lein settings
18:23amalloy$google set maven m2 repository directory home
18:23sexpbotFirst out of 4290 results is: Maven - Settings Reference
18:23sexpbothttp://maven.apache.org/settings.html
18:25ampleyflywell, I assume then that there should be a maven installation somewhere
18:25amalloyampleyfly: lein is built on top of maven
18:25ampleyflybut all I have is leiningen-1.4.2-standalone.jar
18:26ampleyflyand no settings.xml file to be seen
18:26ampleyflybut maybe it's in there
18:26amalloyampleyfly: the standalone jar probably has maven in it
18:27ampleyflyyup, think I found it
18:31ampleyflywell, seems there's no config but that the default path is used
18:32amalloyindeed, that's what defaults are for :)
18:35ampleyflyhrr, what does "interpolation" mean in the context of contents of an xml file?
18:36amalloy${user.home} => /home/myname
18:37bartj$google define:interpolate
18:37sexpbotFirst out of results is:
18:37amalloy$dict interpolate
18:37sexpbotamalloy: verb-transitive: To insert or introduce between other elements or parts.
18:38ampleyflywell that's an odd usage
18:39mecI'm having a problem where my agents only run once, even tho they (send-off *agent* func) themselves inside func
18:39ampleyflyanyway, I guess ${env.HOME} would give the same as %HOME% on windows?
18:40amalloythat's the idea
18:42mecanyway to get the exceptions thrown by agents?
18:42amalloy&(let [a (agent 0)] (send a (fn[x] (inc x) (send a inc))) (await a) @a)
18:42amalloyhm
18:42sexpbotExecution Timed Out!
18:45amalloymec: i seem to recall reading about having agents send to themselves being unsupported, but i could be wrong
18:46mecThats how they're used in Rich's ant demo. The problem I had was trying (.sleep Thread ms) but it wasnt showing that exception so I couldnt figure out what was wrong
18:47ampleyflysuccess, although it is a bit annoying that settings.xml still has to be in ~/.m2
18:47brehautmec that ant demo is very old; pre 1.0. you want to double check that the version of the code you have is up to date
18:47amalloyyes, that demo abuses agents because futures didn't exist at the time
18:48amalloyampleyfly: where would you prefer it to be?
18:48ampleyflyit would be nice if maven used the value of an environment variable, if present, for the default location
18:49mecamalloy: do you know any up to date idiomatic examples instead?
18:49amalloyhave you tried setting M2_HOME?
18:50amalloyhttp://maven.apache.org/download.html seems to have pretty detailed instructions for windows
18:50ampleyflyamalloy: ... you're right, I looked at it first, assuming lein set it when it was installed, noticed it was not set and then forgot about it
18:51raekmec: agents can be good for sending off something to be executed in the background that the ordinary code is not conserned about (e.g. logging)
18:52raekif you need to wait for an agent action to complete, or execute something regularily, consider using executors directly
18:52raek(those are what agents and the future macro are built on top of)
18:52raekmec: http://blog.raek.se/2011/01/24/executors-in-clojure/
18:53mecraek: thanks
18:54raekthat posts does not mention ScheduledExecutorService though, but the idea is the same
18:54raekhttp://download.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html
18:55hiredmanhttps://github.com/hiredman/clojurebot/blob/master/src/hiredman/schedule.clj
18:56amalloyhiredman: ooc what does clojurebot use scheduled tasks for?
18:57hiredmanpolling feeds
18:58raek(I also recommend cron4j for, well, cron-like things)
18:58amalloyah, makes sense
19:01ampleyflyamalloy: well, setting the environment variable M2_HOME, to which I assume the line "The Maven install: $M2_HOME/conf/settings.xml" refers, doesn't seem to do it :(
19:01ampleyflyit does say $M2_HOME and not ${env.M2_HOME}, though
19:02ampleyflyso maybe I misunderstood something
19:03amalloyampleyfly: (a) what line are you referring to, (b) $M2_HOME is the unix syntax for %M2_HOME% and is often used in an informal way to mean "the value of variable M2_HOME" regardless of OS
19:05ampleyflyThere are two locations where a settings.xml file may live:
19:05ampleyflyThe Maven install: $M2_HOME/conf/settings.xml
19:05ampleyflyA user's install: ${user.home}/.m2/settings.xml
19:05ampleyflyI'm referring to the oddity of insisting on writing ${user.home}, ${env.HOME} etc everywhere but on that line
19:07amalloyit's a bit odd
19:10amalloyyou can't just capitulate by putting your settings.xml in ~/.m2/settings.xml, and have that xml file say "don't put anything else here, put it somewhere else"?
19:10ampleyflyyeah, I have =)
19:10ampleyflyand it works!
19:10ampleyflyso thanks a lot for all the help
19:11amalloyhurrah! now tell me why having the repo in ~/.m2 makes you so sad :)
19:11ampleyflyamalloy: ~ is on an ssd which is not that big
19:12amalloyah
19:13amalloya lot of programs put all kinds of crap in ~ on windows, whether you want them to or not. i wonder how hard it is to tell windows to use a different drive for ~
19:14ampleyflywell, at least on windows 7 most (if not all) of the program data gets put in AppData, which you can move
19:18ampleyflyit's better, but still a hassle to set up development stuff on
19:33mfredricksoncan anyone tell me how to make the following true:
19:33mfredrickson,(= :foo (symbol ":foo"))
19:33clojurebotfalse
19:33brehautmfredrickson: :foo is a keyword
19:33brehaut,(= :foo (keyword "foo"))
19:33clojurebottrue
19:34mfredricksonbrehaut: thanks, i've been staring at that for toooo long
19:34brehautno problem
19:35Deranderhaha
19:37ataggartI've found the more intractable the problem, the more likely it is to have a trivially dumb cause.
19:40amalloyataggart: i have a problem for you. i need to visit hundreds of cities all over the globe to pitch my new startup idea, but i'm not sure how to minimize my travel time
19:40ataggart... awesome
19:41mfredricksonnp = "trivially dumb cause"
19:41mfredrickson:-)
19:41mecobviously this is a job for Mr Brute Force
19:41brehautamalloy: your trivially dumb cause is that you only need to visit san fran
19:42amalloybrehaut: funny because it's true
19:44brehautmec: not Mr Greedy Algorithm ?
19:44AdamantSMT solver!
19:44Adamantok, not really
19:46ataggartanyone know how to cleanly uninstall lein?
19:47amalloyataggart: rm lein && rm lein*.jar?
19:47ataggart¿Dónde Está?
19:47brehautamalloy: ataggart also ~/.lein/
19:47ataggartI have lein in usr/lcoal/bin, but not sure where everything else might be
19:48ataggartorly
19:48ataggartwell shucks that's a nice way to do it
19:48technomancyataggart: the lein shell script should be the only thing it keeps outside ~/.lein
19:48amalloyit's the Unix way
19:48amalloys/way/Way
19:48sexpbot<amalloy> it's the Unix Way
19:48brehauttechnomancy what about ~/.m2/repository/leiningen ?
19:48ataggartI was expecting stuff to be shotgunned into lib, etc.
19:49amalloybrehaut: pretend ~/.m2 is /tmp
19:49technomancybrehaut: that hasn't been used for a while
19:49technomancyself-installs go in ~/.lein/self-installs now
19:50brehauti wonder how i got it then; this machine is only 3 months old
19:54amalloybrehaut: installed an old version of lein? technomancy is always saying people don't download the newest
19:55brehautamalloy: well i am a muppet so who knows
19:56ataggartlein now defaults new projects to 1.2.1. I hadn't even realized it was released.
19:57brehautataggart: i think its just waiting on maven central before its announced?
20:03technomancybrehaut: yeah, it's a stealth-release
20:52mrnex2010hey, is something like this possible? (defmacro exists? [x] `(try (= ~x) (catch java.lang.Exception ~'e false)))
20:53technomancy,(resolve 'java.util.Date)
20:53clojurebotjava.util.Date
20:53technomancymrnex2010: is that what you want?
20:53mrnex2010lovely! thx a lot man
20:54mrnex2010indeed
20:55mrnex2010oh but, even when i do: (try (resolve d) (catch Exception e (print "llll" e)))
20:56mrnex2010i get an exception instead of it being catched
20:56TimMc,(resolve 'java.util.NoDate)
20:56clojurebotjava.lang.ClassNotFoundException: java.util.NoDate
20:57mrnex2010if d is not defined it doesnt catch it
20:57mrnex2010,(try (resolve d) (catch Exception e (print "llll" e)))
20:57clojurebotmrnex2010: It's greek to me.
20:58amalloy,('d (ns-map *ns*))
20:58clojurebotnil
20:58amalloy,('first (ns-map *ns*))
20:58clojurebot#'clojure.core/first
20:58amalloy,('java.util.Date (ns-map *ns*))
20:58clojurebotnil
20:59amalloyso as long as you don't want to resolve classes, mrnex2010, it's probably good enough?
20:59hiredman,(import 'java.util.Date)
20:59clojurebotjava.util.Date
20:59hiredman,('Date (ns-map *ns*))
20:59clojurebotjava.util.Date
20:59mrnex2010amaloy: thanks a lot :D
20:59amalloyhiredman: sure, but that only works for imported classes and only by their short names
20:59technomancymrnex2010: you probably need to quote d
21:00technomancyhard to tell what you're really wanting though
21:00mrnex2010technomancy: oh youre right
21:00amalloy*shame for suggesting a hacky solution instead of noticing the missing '*
21:01hiredmanclojure doesn't have reified environments so it is not possible to refer to the current lexical environment and look up names in it
21:01mrnex2010for that? im writing a lib with some shortcuts, and that i needed for a macro where you can write clojure and bash together, so if something isnt defined it will go thru bash. if that makes any sense
21:02mrnex2010its just to avoid writhing "" a lot of times
21:02hiredmanbut that doesn't take into account lexically bound names
21:03hiredmanyou may want to consider some kind of quasi/syntax-quote
21:04mrnex2010thats why i am trying with a try (no pun)
21:04mrnex2010so if it doesnt exist it returns the symbol as a string
21:04amalloymrnex2010: his point is that (let [x 1] (inc x)) won't resolve x
21:05mrnex2010oh
21:05hiredman,(let [x 1] (resolve 'x))
21:05amalloyin either case
21:05clojurebotnil
21:06mrnex2010how about (try (eval 'd) (catch Exception e (print "llll" e))) but that just worried me about possible side effects
21:07hiredman~search for lexical+environment
21:07clojurebot<#clojure:hiredman> clojure doesn't have reified environments so it is not possible to refer to the current lexical environment and look up names in it
21:07hiredman^-
21:07amalloyeval doesn't have access to lexicals either
21:08mrnex2010k thx
21:19dnolenSLaTeX + Clojure fun, http://dosync.posterous.com/a-preview, styles needs tweakin (and the code itself does as well)
21:42parasebaHow could I make this work? (read-str (prn (java.util.Date.))) ?
21:43parasebas/read-str/read-string
21:43sexpbot<paraseba> How could I make this work? (read-string (prn (java.util.Date.))) ?
21:45parasebathat should be: (read-string (pr-str (java.util.Date.)))
21:46parasebaI get java.lang.RuntimeException: java.lang.Exception: Unreadable form
21:48amalloy&(doc *print-dup*)
21:48sexpbot⟹ "; When set to logical true, objects will be printed in a way that preserves their type when read in later. Defaults to false."
21:48amalloy,(binding [*print-dup* true] (read-string (pr-str (java.util.Date.))))
21:48clojurebotjava.lang.IllegalArgumentException: No method in multimethod 'print-dup' for dispatch value: class java.util.Date
21:49amalloyso you'd have to define a print-dup method for java.util.Date: clojure doesn't yet know how to print that in a readable way
21:50amalloysomething like (defmethod print-dup java.util.Date [d out] (.write out (str "#=" `(Date. (...get arguments to Date constructor from d)))))
21:51parasebaamalloy: that will print a Date, but what about the parsing part?
21:51amalloyno, it won't print a date. it will print the string #=(Date. 1 2 3)
21:51amalloywhich the clojure reader recognizes as "hang on! don't return the following form: instead, read it, eval it, and return that"
21:51TimMc,(read-string "#=(+ 1 2)") Doubt this will be allowed...
21:51clojurebotjava.lang.RuntimeException: java.lang.Exception: EvalReader not allowed when *read-eval* is false.
21:52parasebaohhhh magic!!!!
21:52TimMcIndeed.
21:52parasebathat's so cool
21:52TimMcAnd now you also know how to prevent one kind of code injection.
21:52amalloyheh
21:52parasebalong live S-expressions ... no more json needed
21:53amalloyparaseba: funny you mention that; it's the subject of my latest blog
21:53TimMchttp://hubpages.com/hub/Dont-use-XML-JSON-for-Clojure-only-persistence-messaging
21:53amalloymuahaha. minions to promote my writing for me. genius
21:54parasebaperfect timing!! that's exactly what I was trying to do....
21:54TimMchaha
21:54amalloyparaseba: i don't mention print-dup, though
21:54TimMcamalloy: Yes you do.
21:54amalloythat is, i say that it exists and how to use it, but don't mention how to print new kinds of objects
21:55amalloydo i?
21:55paraseba"For ultra-high fidelity, you can bind *print-dup* to true while printing, and Clojure will make an extra effort to make sure the output is machine-readable"
21:55amalloyi'll add a section on defining print-dup methods
21:57parasebathanks for the help and the post
21:57amalloy&(binding [*print-dup* true] (pr [1 2 *ns*]))
21:57sexpbot⟹ [1 2 #=(find-ns sandbox7565)]nil
21:57amalloy&(binding [*print-dup* false] (pr [1 2 *ns*]))
21:57sexpbot⟹ [1 2 #<Namespace sandbox7565>]nil
22:19amalloyparaseba: i've edited the hub. do you see anything helpful i've missed in the new section?
22:20amalloyTimMc, feel free to jump in too
22:20parasebaamalloy: let me see
22:21TimMcamalloy: You might mention *read-eval* very briefly.
22:21TimMcG'night!
22:22amalloynight
22:23parasebaamalloy: maybe you could use the constructor (Date. long) and (.getTime d)
22:24parasebaamalloy: maybe a reference to clojure documentation? is this mechanism documented anywhere? in particular the reader hook
22:24amalloyit's surprisingly hard to find that documented
22:24parasebahehe tell me about it ....
22:27parasebaamalloy: take a look at the code for print-ctor
22:27amalloyeh? where?
22:27parasebaclojure.core
22:28parasebait takes care of the #= part for you
22:28amalloynice
23:32technomancythunk: nothing ended up happening on your front with the clojars hacks, did it?
23:43dnolenholy crap does defining equal and hashCode speed up collection performance.
23:45amalloydnolen: really? i'd guess that the default identity-oriented versions of that are pretty fast, and fairly decent partitioning for hashing etc
23:47dnolenamalloy: Logos really leans on PersistentHashMap, by defining hashCode and equals I'm seeing almost a 2X speed up in some cases. Zebra can be solved in ~2ms now. That's a 3X lead on SWI.
23:49dnolenit's faster than the times recorded by the original miniKanren developers on a 3ghz Xeon using Skew Random Binary Access Lists.
23:49brehautdnolen: thats awesome!
23:50amalloydnolen: i don't understand any of that but it sounds great :)