#clojure log - Mar 23 2011

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:21 carlo_au: how do people use vim with clojure these days?

0:22 the site for vimclojure seems to be down/gone

0:46 dakrone: carlo_au: it's still being developed: https://bitbucket.org/kotarak/vimclojure

0:46 something must be wrong with the site

0:47 carlo_au: dakrone: I cloned that bitbucket repo but it seems to be different to the vimclojure-x.x.x.zip bundle that people talk about installing

0:47 no README.txt, etc

0:50 dakrone: I'd post on the mailing list asking about it http://groups.google.com/group/vimclojure

1:17 carlo_au: dakrone: will do

1:53 Lulu58e2: ,(doc any)

1:53 clojurebot: Pardon?

1:57 pdk: try some

2:05 Lulu58e2: Thanks

2:06 I keep thinking any when it's not-any

2:06 (but yeah, some is what I was looking for)

2:09 Is there a function to get all the values of a map for a list of keys?

2:13 cemerick: ,(-> {:a 5 :b 6 :d 9} (select-keys [:b :d]) vals)

2:13 clojurebot: (9 6)

2:14 cemerick: Lulu58e2: ^^

2:14 Lulu58e2: Wicked, thanks

2:14 I was only down to the "m"s in the API

2:14 cemerick: or…

2:15 ,((juxt :b :d) {:a 5 :b 6 :d 9})

2:15 clojurebot: [6 9]

2:18 cemerick: knowing what order the vals are coming out in is generally good

2:18 Lulu58e2: Okay, I don't have keyword keys, so the first will work

2:21 ?

2:21 I'm not sure I follow you there.

2:24 Does one of those functions ensure order?

2:25 Oh, nevermind, juxt would

2:25 I see now

2:34 ,(doall (map #((fn [] (print %))) (take 5 (range)))

2:34 clojurebot: EOF while reading

2:34 Lulu58e2: ,(doall (map #((fn [] (print %))) (take 5 (range))))

2:34 clojurebot: 01234

2:34 (nil nil nil nil nil)

2:37 Lulu58e2: Didn't need the extra parenthesis around fn

2:47 ,(map (fn [f] (f)) (map #(fn [] (* % %)) (take 3 (range))))

2:47 clojurebot: (0 1 4)

2:48 Lulu58e2: Okay, 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?

2:50 I need a list of curried functions (I'm not sure if the term applies here, exactly)

2:52 partial might be what I need

3:53 raek: Lulu58e2_afk: also consider using 'for' ##(let [fs (for [n (range 3)] #(* n n))] (for [f fs] (f)))

3:53 sexpbot: ⟹ (0 1 4)

4:08 tomoj: for+->>, evil?

4:12 https://gist.github.com/44ebe95923fa6a4bc5c7 extremely evil

4:13 otoh &(->> (* x x) (for [x (range 10)]) (map inc))

4:14 Derander: why am I awake?

4:14 tomoj: kinda neat looking but ultimately pure evil I think

4:15 opqdonut: :D

4:15 indeed

4:16 tomoj: &(->> (throw (Exception.)) (if true 4))

4:16 sexpbot: ⟹ 4

4:18 tomoj: &(map #(-> % :name (if "named!" "unnamed!")) [{:name "bob"} {:age 23}])

4:18 sexpbot: ⟹ ("named!" "unnamed!")

4:18 raek: -> and ->> feels kinda weird with macros

4:18 tomoj: all kinds of crazy stuff I never thought of..

4:19 "kinda"? :)

4:22 raek: frellin' K-RAY-Z.

4:23 (->> (f x z v) (when-let [x y]) (when-let [z u]) (when-let [v w]))

4:24 (->> (f0 a b c) (when-let [c (f3 b)]) (when-let [b (f2 a)]) (when-let [a (f1 x)]))

4:25 this feels like a reversed maybe monad

4:35 TobiasRaeder: Morning

4:36 hiredman: https://github.com/clojure/clojure/commit/8fda34e4c77cac079b711da59d5fe49b74605553

4:36 nice

4:36 http://clojure02.managed.contegix.com/display/design/Improvements+to+interop+from+Java

4:36 rhickey's comments at the bottom are great too

4:46 opqdonut: haha

4:48 raek: nice.

5:10 ejackson: morning y'alls

5:13 Raynes: ejackson: Good morning.

5:40 Tuna fish and mayo sandwich for breakfast.

5:45 ejackson: breakfast of champions

5:46 Raynes: Or the poor.

5:46 Scavengers.

5:47 ejackson: well, I had oats, yummmmmm

6:08 robonobo: hi, does anyone know if there is a tarball available for the newly released leiningen 15 and where I might get it?

6:08 s/15/1.5

6:08 sexpbot: <robonobo> hi, does anyone know if there is a tarball available for the newly released leiningen 1.5 and where I might get it?

6:09 raek: robonobo: check the download page at https://github.com/technomancy/leiningen

6:09 https://github.com/technomancy/leiningen/tarball/master

6:09 or maybe https://github.com/technomancy/leiningen/tarball/1.5.0

6:09 clojurebot: Gabh mo leithscéal?

6:14 robonobo: raek: i needed the last one, thanks

6:29 raek: robonobo: are you building leiningen yourself?

6:30 robonobo: raek: i updated the lein package in homebrew (mac package manager)

6:30 raek: ah

6:50 thorwil: hmm, if i use ring's wrap-params with a handler without explicit arguments, i can access request parameters in the defn

6:50 like in the example on http://clojuredocs.org/ring/ring.middleware.params/wrap-params

6:51 but what if i want to pass an explicit argument to my handler, in addition?

7:21 xkb: hi

7:21 I'm trying to solve this: http://www.algorithmist.com/index.php/UVa_103 using Clojure

7:22 I already figured the sorting part out myself, and I'm now trying to apply the LIS algortihm

7:22 the "standard" algorithm uses a matrix to keep track of the results of comparing lists

7:22 how would you implement this in clojure?

7:29 ejackson: xkb: i don't know the algo, but probably through returning it in a reduce or in a recursion

7:32 clgv: xkb: if you can give us pseudocode or a mathematical description of the algorithm we might try to come up with a clojure implementation ;)

7:36 xkb: clgv: my link contains another link to a c++ implementation

7:36 (and the math specs)

7:37 my attempt thusfar is on: https://gist.github.com/882976

7:38 my lcs should probably be adapted for this problem

7:41 clgv: the c++ "implementation" scares me... O.O

7:43 xkb: clgv: ye.. I had the same

7:43 clgv: that's why I wanted to create a clean clojure implementation

7:43 I found several on the web, Java, C, C++ and they are all ugly

7:43 clgv: it's indeed plain C but using vectors from C++ and using global variables implicitely in a function...

7:47 this one looks more concise

7:47 http://www.algorithmist.com/index.php/Longest_Increasing_Subsequence.cpp

7:49 xkb: ah that's readable indeed

7:49 clgv: was linked by the wikipedia entry on the problem

7:49 xkb: finding a LIS is not really a problem though, my main problem is how to apply it to the problem

7:50 most solutions use some kind of "side-effect" to keep track of the end-result during the calculation of the stacking boxes

7:50 the java version uses the diagonal of a (nr-of-boxes x nr-of-boxes) matrix

7:50 clgv: do you need a fast approach?

7:51 xkb: nah, just an elegant one :)

7:51 clgv: than you could just sort all vectors internally and then sort the vectors lexicographically

7:51 xkb: that's what I do now

7:52 first each box, then all boxes

7:52 that still doesnt solve it, you need some kind of trail

7:52 e.g. box 1 fits in 2, 2 fits in 4

7:53 clgv: hm yeah. you have to decide which boxes to skip to reach the longest sequence

7:54 xkb: indeed

7:54 clgv: you could do an exhaustive search on that or try a branch-and-bound approach. wikipedia also suggests dynamic programming

7:54 xkb: and that's where I get stuck

7:54 clgv: I dont know if there is a suitable bound function though...

7:54 xkb: translating the DP to Clojure kinda messes with my mind

7:55 clgv: humm my first thought is that you might translated DP naturally with lazy-sequences

7:56 e.g. if you have a 2 dimensional DP you could make a lazy-sequence for every row

7:56 this way you only calculate what you really need and you have the intended "caching effect"

7:56 xkb: and stop if the condition fails, for each combination of rows?

7:57 clgv: no, I was already referring to a DP translation of the problem

7:57 xkb: ah :)

7:57 clgv: usually it stops when you calculated cell (N,N) or (N,1)

9:06 thorwil: i have this as part of my routing (using moustache): post (app wrap-params [[path not-empty] &] submit-article)

9:07 in (defn submit-article ...) i can destructure the request parameters just fine

9:07 but i want to have "path" available, too

9:08 without wrap-params, it would be: (app [[path not-empty] &] (submit-article path))

9:09 i can't find a way to combine both, it's always wrong number of parameters

9:09 Chousuke: thorwil: can you use partial?

9:09 eg. (partial submit-article path)

9:10 I don't know how the functions work though so the closure you get might not be what you want.

9:11 thorwil: Chousuke: java.lang.UnsupportedOperationException: nth not supported on this type: PersistentHashMap

9:12 Chousuke: oh well, I guess not, then.

9:12 thorwil: assoc-param sound like it could be the right thing: http://mmcgrana.github.com/ring/middleware.params-api.html

9:12 but i fail to find out what the right value for "map" is

9:13 Chousuke: thorwil: any map, it seems.

9:57 Dranik: hi all

9:57 how to read a text file and get a list of lines?

9:58 gfrlog: there is slurp and split

9:58 ,(doc slurp)

9:58 clojurebot: "([f & opts]); Reads the file named by f using the encoding enc into a string and returns it."

9:59 gfrlog: ,(doc clojure.string/split)

9:59 clojurebot: It's greek to me.

9:59 gfrlog: dang

9:59 ,(doc split)

9:59 clojurebot: Gabh mo leithscéal?

9:59 Dranik: thanks

9:59 gfrlog: sure

10:00 clgv: Dranik: there is also clojure.java.io/reader and line-seq

10:00 TimMc: drewolson: line-seq

10:00 Ah, clgv beat me to it.

10:00 gfrlog: I knew there was a better answer. I just didn't say that I knew it.

10:01 TimMc: Sorry, Dranik ^

10:01 Dranik: clgv: thanks!

10:01 TimMc: Dranik: Here's an example: https://github.com/timmc/CS4300-HW4/blob/master/src/timmcHW4/core.clj#L268

10:02 Dranik: feeling myself like a complete newbie :-)

10:02 TimMc: Dranik: http://clojuredocs.org/ is your friend

10:03 clgv: yeah, 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:03 Dranik: TimMc: feeling myself like a complete newbie :-)

10:07 gfrlog: there should be something in clojars where I can mark a lib as "don't even resolve its own dependencies"

10:08 angerman: in what kind of idiotic region do i live in where people shout "m… m… monster grilling"...

10:13 TimMc: gfrlog: What's this now?

10:14 gfrlog: TimMc: if I have a bare project with one dependency, and "lein deps" fails...

10:14 then BOOO

10:14 ejackson: angerman: I can't even begin to speculate on that one

10:14 gfrlog: fortunately this dep has a forked version on clojars, I suspect for exactly that reason

10:14 TimMc: It has a dependency that is not in repos?

10:15 gfrlog: I believe so

10:15 some highly specific version of jetty

10:15 org.jboss.netty:netty:jar:3.2.0.BETA1

10:15 is the indirect dependency that fails

10:15 for the "plaza" lib

10:22 * clgv feels like being the only one not doing web development in clojure. ;)

10:23 * __name__ is not doing it either.

10:25 * ejackson either

10:26 * clgv feels like he is one of three people not doing web development in clojure. ;)

10:26 drewr: depends on how you define web dev

10:27 if it's HTTP protocol work I like clojure but for browser-facing work I still like django

11:01 Guest57647: raek: Thanks, I'll have a look at your suggestions

11:02 raek: technomancy: is there a way to export an epresent presentation to, say, a pdf? (for those who has not yet converted to Emacs)

11:05 clgv: raek: and hopefully also for those that never will ;)

11:06 except if you make only presentations related to emacs ....

11:55 TimMc: technomancy: 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:56 sritchie: amalloy: 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:57 amalloy: hah

11:58 sritchie: how did you avoid seeing it for a month?

11:59 sritchie: sexpbot had a message for me, and I was on so erratically that I clicked away the message on colloquy each time

11:59 amalloy: haha

11:59 sritchie: so, it turned out to be much faster to do a bulk read into a byte array, then this -- https://gist.github.com/883338

12:00 I actually wanted to ask you about my little-float method. clearly there's a pattern here that I can abstract away

12:01 amalloy: well first i'd change 'bits' to 'bytes' :P

12:02 sritchie: whoops, nice

12:02 I'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:03 amalloy: hm. maybe. it seems like reduce would get you most of the way there though

12:04 and map-indexed to do the shifting and anding

12:07 sritchie: amalloy: this feels like a good one to practice

12:07 s/to/for

12:07 sexpbot: <sritchie> amalloy: this feels like a good one for practice

12:07 Raynes: For 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:08 sritchie: Raynes: haha, yes. I'd prefer if sexpbot would text message me every twenty minutes... that would make like easier

12:08 Raynes: Heh

12:08 amalloy: sritchie: 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:11 sritchie: amalloy: quick skype call, but that's a good idea. I'll go play with these and report back in a bit

12:16 Caffeine: if (symbol? (symbol 'meh)) => true && (def (symbol 'meh) '(1 2 3)) => "First arg to def must be a symbol" then what am I missing?

12:17 amalloy: Caffeine: first arg to def is a list: elements are 'symbol and ''meh

12:17 because def doesn't evaluate its first argument

12:17 Caffeine: uh

12:19 dnolen: Caffeine: def is a special form.

12:19 Caffeine: okk... I should use set! in these cases I guess

12:20 amalloy: Caffeine: usually you should rethink why you find yourself in these cases

12:20 dnolen: Caffeine: what are you trying to do?

12:20 Caffeine: I have not-yet-symbols .. and I want to give them a value ... ('not-yet-symbol '(its future value))

12:21 amalloy: Yeah, I'm probably not thinking this stuff right

12:21 dnolen: Caffeine: what are not-yet-symbols?

12:21 amalloy: i often see this sort of pattern: (defn f [args] (letfn [(f* [args] (f* something recursive))] (f* args)))

12:21 in 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:22 Caffeine: brb gotta go NOW sorry

12:29 technomancy: raek: no, just running htmlize on the org source.

12:29 TimMc: no reason in particular. I didn't imagine anyone would actually run up against that in real life

12:30 TimMc: unless the problem was that it started trying to connect before downloading deps; that's something I really should address.

12:31 TimMc: Interesting... 100 is the default, and it sleeps for 100 millis... so it should time out after 10 s, yeah?

12:34 OK, yeah, that's about right. Anyway, it's only affecting me intermittently.

12:35 technomancy: TimMc: 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:36 TimMc: Hah, it's fine.

12:36 I was able to debug the "couldn't connect" message with a Google search.

12:37 technomancy: (require 'leiningen.repl) (alter-var-root #'leiningen.repl/*retry-limit* (constantly 200)) ;; in ~/.lein/init.clj if you like

12:37 TimMc: Thanks, I might use that.

12:52 Dantas: ejackson: hello :) fine ? Look, could i bothering you with another question ?

13:53 tsdh: Hi

13:53 I have a LazySeq question.

13:54 mids: tsdh: go ahead and ask

13:54 scottj: (doall tsdh)

13:55 tsdh: If 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:56 paraseba: Hi. 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:00 TimMc: tsdh: Indeed.

14:01 joegallo: Maybe use proxy?

14:01 tsdh: TimMc: Cached forever, or until memory gets exhausted (aka, implemented as sort of WeakReferences)?

14:01 TimMc: tsdh: Except it's not really cached -- it's computed, and you're holding onto the head of a linked list.

14:02 tsdh: The trick is that the rest of the list, past some point, simply hasn't been computed yet.

14:02 paraseba: joegallo: 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:03 what I want is actually to wrap my instance, and forward *almost* every method call to it

14:03 tsdh: TimMc: I don't see exactly where I'm holding onto the head in my code above.

14:04 TimMc: Ah...

14:04 I see what you're asking now.

14:05 I wonder if JIT is affecting this.

14:05 amalloy: tsdh: if (get-lazy-seq) returns a new seq every time, the most plausible explanation is that foo2 is faster than foo1

14:05 try (do (time (doall (get-lazy-seq))) (time (doall (get-lazy-seq))))

14:06 paraseba: tsdh: maybe you could try reverting the order of calls to foo-1 and foo-2?

14:06 tsdh: amalloy: 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:07 Argh!!!

14:07 amalloy: &(do (time (= (doall (range 1e6)))) (time (= (doall (range 1e6)))))

14:07 sexpbot: ⟹ "Elapsed time: 518.640372 msecs" "Elapsed time: 583.172628 msecs" true

14:08 tsdh: Of course, to compare *all* results, map them to =, and thus I hold onto the heads! ;-)

14:08 jkkramer: you could run using dotimes and drop the first few runs to account for hotspot

14:08 angerman: wow. Just got the hang of sandbar…

14:09 tsdh: That'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:11 amalloy: tsdh: 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:12 tsdh: amalloy: That's only because my example code doesn't match the code where I see the issue.

14:12 amalloy: hah

14:12 that's something you should consider not doing! :)

14:12 tsdh: amalloy: The latter is more like (map foo (foo-1 (get-lazy-seq)) (foo-2 (get-lazy-seq))).

14:12 joegallo: paraseba: i'm not sure i see why you can't just proxy the class in question...

14:13 (.run (proxy [Thread] [] (run [] (println "foo")) --> prints foo

14:14 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

14:14 joegallo: ah, so you can't override the class of the instance, because you aren't in control of the creation of the instance

14:15 paraseba: joegallo: exactly

14:15 joegallo: okay, makes sense to me now

14:16 paraseba: joegallo: there is probably something wrong with my reasoning, but it seems a pretty common use case. Something like an on-the-fly wrapper

14:16 joegallo: yeah, it would be nice

14:22 paraseba: my 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:27 dnolen: using SLaTeX to output Clojure == lovely typography.

14:32 __name__: Example or it did not happen.

14:32 dnolen: __name__: blog post forthcoming.

14:34 sritchie: amalloy: 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 (To your blog.)

14:34 dnolen: __name__: http://dosync.posterous.com

14:35 sritchie: the 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:35 amalloy: sritchie: i don't see why you're treating the last byte as a special case

14:36 angerman: dnolen: "a large number of interesting logic program(s?) can be written"

14:36 amalloy: ie, 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:36 sritchie: ah, that's true. I'm making the mistake of trying to replicate my java code

14:37 amalloy: java code is self-replicating. you can't stop it from spreading, like rabbits

14:37 dnolen: angerman: thx

14:37 sritchie: yes! it even forces my clojure abstraction passes to get longer and longer

14:38 angerman: dnolen: you'r welcome.

14:41 amalloy: sritchie: similarly for the map-indexed. nobody minds if you shift something by zero

14:42 sritchie: amalloy: okay, here's another pass -- https://gist.github.com/883338

14:42 angerman: Ohh firefox. … why can thou not have your tabs up high like Chrome/

14:43 semperos: angerman: Firefox 4

14:43 angerman: semperos: yes.

14:43 amalloy: sritchie: bit-xor is associative and commutative; what's the point of a reverse?

14:44 then, 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:44 sritchie: amalloy: working on that last comment now

14:45 angerman: wow. but FF4 is fast.

14:45 amalloy: that is, (map-indexed f (map g list)) is (map-indexed (fn [idx val] (f idx (g val))))

14:46 modulo a "list" i forgot at the end of the second version

14:47 sritchie: amalloy: https://gist.github.com/883338

14:48 amalloy: hooray, looking much shorter now. i'd use ->> to reduce the nesting, personally

14:48 (->> bitseq (map-indexed (fn...)) (reduce bit-xor) (Float/intBitsToFloat))

14:49 sritchie: I could toss -> into that internal anonymous function too

14:49 amalloy: could you?

14:49 bartj: er, I would like to get my feet wet with contributing to open source Clojure projects

14:49 amalloy: oh, i guess so

14:49 bartj: apart from core/contrib

14:50 what would be a good bet please?

14:50 amalloy: that seems like a less clear gain to me, but it's not inherently bad so feel free

14:51 sritchie: amalloy: haha, I agree, I'm just pleased with these iterations

14:51 amalloy: and now that you've got it down to a minimal form, it becomes pretty clear how you can generalize it

14:52 as a macro with a slot for Float/intBitsToFloat, or a function like (littleize #(Float/intBitsToFloat %) bitseq)

14:52 sritchie: https://gist.github.com/883338

14:53 it's amazing how clean these functions can become

14:54 amalloy: sritchie: 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:54 obviously that's a pretty vague critique; stick with yours if you prefer it

14:55 sritchie: 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:56 sritchie: amalloy: I did, I found it really interesting

14:57 I'm going to start blogging about some of this hadoop stuff, and I really enjoyed the format of that article

14:57 amalloy: ooc why use bit-xor instead of bit-or?

14:57 sritchie: the results of all this are interesting, of course, but I really enjoy seeing the process

14:57 amalloy: or even +

14:59 sritchie: amalloy: 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:00 + is giving me the right answer, but I had thought you needed a bitwise operation to combine these, after the bit shifts

15:01 amalloy: sritchie: 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:01 if you never need to carry, then + is just |

15:02 sritchie: does that work for eight byte numbers, though?

15:02 since java uses four bytes for integers?

15:03 pardon if that misses the point

15:03 yeah, I guess it doesn't change anything

15:03 amalloy: yeah, it shouldn't

15:26 Lulu58e2: amalloy: can I have a link to that article?

15:26 amalloy: $google amalloy hubpages evolution of an idea

15:26 sexpbot: First out of 16 results is: What is Clojure? - HubPages

15:26 http://hubpages.com/hub/What-is-Clojure

15:26 amalloy: damn

15:26 http://hubpages.com/hub/The-evolution-of-an-idea

15:27 Lulu58e2: thx

16:22 technomancy: bartj: if you are still looking, clojars needs help

16:25 bartj: technomancy, is there a bug list somewhere?

16:26 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:28 raek: heh, there's a lib called robert/bruce

16:28 technomancy: looks like ol' hooke got some company in the repo: http://clojars.org/repo/robert/

16:30 technomancy: roberts unite!

16:31 chouser: Is this supposed to work? https://gist.github.com/883884

16:33 raek: hrm. if I changed (.x this) into x, it didn't throw

16:34 bartj: technomancy, you mean this - https://github.com/ato/clojars-web/issues

16:36 technomancy: bartj: 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:37 bartj: technomancy, who is ato? have never seen ato here?

16:37 chouser: raek: I keep forgetting deftype instance fields are available with bare names like that

16:37 technomancy: bartj: he disappeared over a year ago =(

16:38 chouser: but it doesn't seem to work

16:38 bartj: technomancy, has anybody taken over (partially I mean) the project yet ?

16:39 technomancy: bartj: no, but at least a few others have root access to the server

16:39 hiredman: the type inferered by the compiler is the wrong type

16:39 technomancy: if he's totally unresponsive we should be able to deploy new features

16:40 chouser: oh, wait.

16:40 hiredman: it is the stub type used to generate non-reflective calls

16:44 chouser: ok, but raek's syntax is correct and works around the problem.

16:45 bartj: technomancy, I have applied for membership to clojars-maintainers. do you have permissions to grant membership?

16:47 technomancy: bartj: sure

16:49 waxrose: Do you necessarily have to be well versed to be accepted as a maintainer? (silly question)

16:50 technomancy: waxrose: good question. there aren't really any ground rules here. fresh blood could probably pull it off with a little oversight.

16:50 I don't have the time to take it over myself, but I might be able to handle doing code reviews &c.

16:53 waxrose: hmm, sounds hopeful then

16:54 seancorfield: amalloy: love your evolving of an idea hub page... i tweeted it and then wasn't sure if @amalloy on twitter is you :|

16:54 amalloy: seancorfield: it's not me, sadly

16:54 i'm @alanmalloy

16:54 seancorfield: ah, ok

16:56 deleted my tweet and posted a new one highlighting you... thanx

16:56 also realized i wasn't following you :(

16:58 amalloy: dude, i didn't even realize you could delete tweets. this whole twitter thing is still a mess for me

16:59 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:59 hiredman: ~search for the+thing

16:59 clojurebot: <#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:59 <#clojure:amalloy> dude, i didn't even realize you could delete tweets. this whole twitter thing is still a mess for me

16:59 <#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:59 <#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:00 hiredman: huh, maybe I don't have a handle on this lucene query syntax

17:00 amalloy: hiredman: the second one looks weird to me. "the" isn't mentioned

17:00 hiredman: the maybe be a stopword

17:00 may

17:01 http://en.wikipedia.org/wiki/Stop_words

17:01 semperos: so 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:01 hiredman: (doc apply)

17:01 raek: semperos: (defn f [& args] (... (apply g args) ...))

17:01 clojurebot: "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."

17:02 semperos: yeah, thought so

17:02 I keep asking the same question in different forms over the weeks...

17:03 thanks hiredman raek

17:05 brehaut: got your mail, but it was cut off at "to send a nil to a"

17:17 raek: what swing component would you use to display a text file? JTextArea? JTextPane?

17:18 amalloy: semperos: 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:19 semperos: doubtful

17:19 we like brehaut

17:19 he's finished it for me, regardless, but thanks for the thought

17:20 raek: what do you want to do with the file?

17:21 raek: display it to the user (read only)

17:21 brehaut: amalloy: who said you needed to fabricate stuff to make me appear dumb?

17:21 raek: I'm making a client for the Gopher protocol...

17:21 semperos: any reason a JTextArea won't work?

17:21 * technomancy whimpers a bit at https://github.com/ato/clojars-web/blob/master/src/clojars/db.clj#L184

17:21 raek: not that I'm aware of...

17:22 I also wonder how it handles large files

17:23 semperos: consider the scroll panes

17:23 http://download.oracle.com/javase/tutorial/uiswing/components/textarea.html

17:25 brehaut: technomancy: at least the comments are up to date :/

17:25 technomancy: brehaut: "TODO: figure out how to do stop words with an sql select" uh... =\

17:26 brehaut: technomancy: the comments about it being a bit stupid was what i was thinking of

17:27 technomancy: brehaut: well that's not even about search; it's about parsing the results

17:27 the best part is there's a lucene index on disk already

17:27 raek: hrm, should I really read the whole stream into one big string?

17:27 brehaut: oh dear

17:27 technomancy: all this to say: yes, it needs some work.

17:36 bartj: technomancy, do you have a running instance of clojars-web on your local m/c ?

17:36 semperos: raek: 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:36 as 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:54 hercynium: (hash-map (this-function)) certainly doesn't work :)

17:55 hiredman: (doc apply)

17:55 clojurebot: "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."

17:55 jkkramer: ,(apply hash-map '[:foo "val1" :bar "val2"])

17:55 clojurebot: {:foo "val1", :bar "val2"}

17:56 hercynium: ooo, I see. thanks!

17:57 amalloy: &(sequential? (sorted-map))

17:57 sexpbot: ⟹ false

17:57 amalloy: anyone think that should be true?

18:00 in 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:12 hercynium: ooo, got it working! \o/

18:17 bartj: hercynium, if you have your keys and values in separate lists, zipmap would be ideal, IMO

18:18 hercynium: bartj: yeah, I saw that, and I think I can use apply to enable that and make the code I have a lot shorter

18:19 ampleyfly: is there a way to cause leins .m2-directory to be placed somewhere else than ~ (on windows, specifically)?

18:22 amalloy: ampleyfly: i'd look at maven settings, not lein settings

18:23 $google set maven m2 repository directory home

18:23 sexpbot: First out of 4290 results is: Maven - Settings Reference

18:23 http://maven.apache.org/settings.html

18:25 ampleyfly: well, I assume then that there should be a maven installation somewhere

18:25 amalloy: ampleyfly: lein is built on top of maven

18:25 ampleyfly: but all I have is leiningen-1.4.2-standalone.jar

18:26 and no settings.xml file to be seen

18:26 but maybe it's in there

18:26 amalloy: ampleyfly: the standalone jar probably has maven in it

18:27 ampleyfly: yup, think I found it

18:31 well, seems there's no config but that the default path is used

18:32 amalloy: indeed, that's what defaults are for :)

18:35 ampleyfly: hrr, what does "interpolation" mean in the context of contents of an xml file?

18:36 amalloy: ${user.home} => /home/myname

18:37 bartj: $google define:interpolate

18:37 sexpbot: First out of results is:

18:37 amalloy: $dict interpolate

18:37 sexpbot: amalloy: verb-transitive: To insert or introduce between other elements or parts.

18:38 ampleyfly: well that's an odd usage

18:39 mec: I'm having a problem where my agents only run once, even tho they (send-off *agent* func) themselves inside func

18:39 ampleyfly: anyway, I guess ${env.HOME} would give the same as %HOME% on windows?

18:40 amalloy: that's the idea

18:42 mec: anyway to get the exceptions thrown by agents?

18:42 amalloy: &(let [a (agent 0)] (send a (fn[x] (inc x) (send a inc))) (await a) @a)

18:42 hm

18:42 sexpbot: Execution Timed Out!

18:45 amalloy: mec: i seem to recall reading about having agents send to themselves being unsupported, but i could be wrong

18:46 mec: Thats 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:47 ampleyfly: success, although it is a bit annoying that settings.xml still has to be in ~/.m2

18:47 brehaut: mec 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:47 amalloy: yes, that demo abuses agents because futures didn't exist at the time

18:48 ampleyfly: where would you prefer it to be?

18:48 ampleyfly: it would be nice if maven used the value of an environment variable, if present, for the default location

18:49 mec: amalloy: do you know any up to date idiomatic examples instead?

18:49 amalloy: have you tried setting M2_HOME?

18:50 http://maven.apache.org/download.html seems to have pretty detailed instructions for windows

18:50 ampleyfly: amalloy: ... 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:51 raek: mec: 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:52 if you need to wait for an agent action to complete, or execute something regularily, consider using executors directly

18:52 (those are what agents and the future macro are built on top of)

18:52 mec: http://blog.raek.se/2011/01/24/executors-in-clojure/

18:53 mec: raek: thanks

18:54 raek: that posts does not mention ScheduledExecutorService though, but the idea is the same

18:54 http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html

18:55 hiredman: https://github.com/hiredman/clojurebot/blob/master/src/hiredman/schedule.clj

18:56 amalloy: hiredman: ooc what does clojurebot use scheduled tasks for?

18:57 hiredman: polling feeds

18:58 raek: (I also recommend cron4j for, well, cron-like things)

18:58 amalloy: ah, makes sense

19:01 ampleyfly: amalloy: 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:01 it does say $M2_HOME and not ${env.M2_HOME}, though

19:02 so maybe I misunderstood something

19:03 amalloy: ampleyfly: (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:05 ampleyfly: There are two locations where a settings.xml file may live:

19:05 The Maven install: $M2_HOME/conf/settings.xml

19:05 A user's install: ${user.home}/.m2/settings.xml

19:05 I'm referring to the oddity of insisting on writing ${user.home}, ${env.HOME} etc everywhere but on that line

19:07 amalloy: it's a bit odd

19:10 you 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:10 ampleyfly: yeah, I have =)

19:10 and it works!

19:10 so thanks a lot for all the help

19:11 amalloy: hurrah! now tell me why having the repo in ~/.m2 makes you so sad :)

19:11 ampleyfly: amalloy: ~ is on an ssd which is not that big

19:12 amalloy: ah

19:13 a 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:14 ampleyfly: well, at least on windows 7 most (if not all) of the program data gets put in AppData, which you can move

19:15 * amalloy moved from a 6-y/o xp installation to ubuntu. fairly clueless about windows these days

19:18 ampleyfly: it's better, but still a hassle to set up development stuff on

19:33 mfredrickson: can anyone tell me how to make the following true:

19:33 ,(= :foo (symbol ":foo"))

19:33 clojurebot: false

19:33 brehaut: mfredrickson: :foo is a keyword

19:33 ,(= :foo (keyword "foo"))

19:33 clojurebot: true

19:33 * mfredrickson slaps head

19:34 mfredrickson: brehaut: thanks, i've been staring at that for toooo long

19:34 brehaut: no problem

19:35 Derander: haha

19:37 ataggart: I've found the more intractable the problem, the more likely it is to have a trivially dumb cause.

19:40 amalloy: ataggart: 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:40 ataggart: ... awesome

19:41 mfredrickson: np = "trivially dumb cause"

19:41 :-)

19:41 mec: obviously this is a job for Mr Brute Force

19:41 brehaut: amalloy: your trivially dumb cause is that you only need to visit san fran

19:42 amalloy: brehaut: funny because it's true

19:44 brehaut: mec: not Mr Greedy Algorithm ?

19:44 Adamant: SMT solver!

19:44 ok, not really

19:46 ataggart: anyone know how to cleanly uninstall lein?

19:47 amalloy: ataggart: rm lein && rm lein*.jar?

19:47 ataggart: ¿Dónde Está?

19:47 brehaut: amalloy: ataggart also ~/.lein/

19:47 ataggart: I have lein in usr/lcoal/bin, but not sure where everything else might be

19:48 orly

19:48 well shucks that's a nice way to do it

19:48 technomancy: ataggart: the lein shell script should be the only thing it keeps outside ~/.lein

19:48 amalloy: it's the Unix way

19:48 s/way/Way

19:48 sexpbot: <amalloy> it's the Unix Way

19:48 brehaut: technomancy what about ~/.m2/repository/leiningen ?

19:48 ataggart: I was expecting stuff to be shotgunned into lib, etc.

19:49 amalloy: brehaut: pretend ~/.m2 is /tmp

19:49 technomancy: brehaut: that hasn't been used for a while

19:49 self-installs go in ~/.lein/self-installs now

19:50 brehaut: i wonder how i got it then; this machine is only 3 months old

19:54 amalloy: brehaut: installed an old version of lein? technomancy is always saying people don't download the newest

19:55 brehaut: amalloy: well i am a muppet so who knows

19:56 ataggart: lein now defaults new projects to 1.2.1. I hadn't even realized it was released.

19:57 brehaut: ataggart: i think its just waiting on maven central before its announced?

20:03 technomancy: brehaut: yeah, it's a stealth-release

20:52 mrnex2010: hey, is something like this possible? (defmacro exists? [x] `(try (= ~x) (catch java.lang.Exception ~'e false)))

20:53 technomancy: ,(resolve 'java.util.Date)

20:53 clojurebot: java.util.Date

20:53 technomancy: mrnex2010: is that what you want?

20:53 mrnex2010: lovely! thx a lot man

20:54 indeed

20:55 oh but, even when i do: (try (resolve d) (catch Exception e (print "llll" e)))

20:56 i get an exception instead of it being catched

20:56 TimMc: ,(resolve 'java.util.NoDate)

20:56 clojurebot: java.lang.ClassNotFoundException: java.util.NoDate

20:57 mrnex2010: if d is not defined it doesnt catch it

20:57 ,(try (resolve d) (catch Exception e (print "llll" e)))

20:57 clojurebot: mrnex2010: It's greek to me.

20:58 amalloy: ,('d (ns-map *ns*))

20:58 clojurebot: nil

20:58 amalloy: ,('first (ns-map *ns*))

20:58 clojurebot: #'clojure.core/first

20:58 amalloy: ,('java.util.Date (ns-map *ns*))

20:58 clojurebot: nil

20:59 amalloy: so as long as you don't want to resolve classes, mrnex2010, it's probably good enough?

20:59 hiredman: ,(import 'java.util.Date)

20:59 clojurebot: java.util.Date

20:59 hiredman: ,('Date (ns-map *ns*))

20:59 clojurebot: java.util.Date

20:59 mrnex2010: amaloy: thanks a lot :D

20:59 amalloy: hiredman: sure, but that only works for imported classes and only by their short names

20:59 technomancy: mrnex2010: you probably need to quote d

21:00 hard to tell what you're really wanting though

21:00 mrnex2010: technomancy: oh youre right

21:00 amalloy: *shame for suggesting a hacky solution instead of noticing the missing '*

21:01 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:01 mrnex2010: for 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:02 its just to avoid writhing "" a lot of times

21:02 hiredman: but that doesn't take into account lexically bound names

21:03 you may want to consider some kind of quasi/syntax-quote

21:04 mrnex2010: thats why i am trying with a try (no pun)

21:04 so if it doesnt exist it returns the symbol as a string

21:04 amalloy: mrnex2010: his point is that (let [x 1] (inc x)) won't resolve x

21:05 mrnex2010: oh

21:05 hiredman: ,(let [x 1] (resolve 'x))

21:05 amalloy: in either case

21:05 clojurebot: nil

21:06 mrnex2010: how about (try (eval 'd) (catch Exception e (print "llll" e))) but that just worried me about possible side effects

21:07 hiredman: ~search for lexical+environment

21:07 clojurebot: <#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:07 hiredman: ^-

21:07 amalloy: eval doesn't have access to lexicals either

21:08 mrnex2010: k thx

21:19 dnolen: SLaTeX + Clojure fun, http://dosync.posterous.com/a-preview, styles needs tweakin (and the code itself does as well)

21:42 paraseba: How could I make this work? (read-str (prn (java.util.Date.))) ?

21:43 s/read-str/read-string

21:43 sexpbot: <paraseba> How could I make this work? (read-string (prn (java.util.Date.))) ?

21:45 paraseba: that should be: (read-string (pr-str (java.util.Date.)))

21:46 I get java.lang.RuntimeException: java.lang.Exception: Unreadable form

21:48 amalloy: &(doc *print-dup*)

21:48 sexpbot: ⟹ "; When set to logical true, objects will be printed in a way that preserves their type when read in later. Defaults to false."

21:48 amalloy: ,(binding [*print-dup* true] (read-string (pr-str (java.util.Date.))))

21:48 clojurebot: java.lang.IllegalArgumentException: No method in multimethod 'print-dup' for dispatch value: class java.util.Date

21:49 amalloy: so 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:50 something like (defmethod print-dup java.util.Date [d out] (.write out (str "#=" `(Date. (...get arguments to Date constructor from d)))))

21:51 paraseba: amalloy: that will print a Date, but what about the parsing part?

21:51 amalloy: no, it won't print a date. it will print the string #=(Date. 1 2 3)

21:51 which the clojure reader recognizes as "hang on! don't return the following form: instead, read it, eval it, and return that"

21:51 TimMc: ,(read-string "#=(+ 1 2)") Doubt this will be allowed...

21:51 clojurebot: java.lang.RuntimeException: java.lang.Exception: EvalReader not allowed when *read-eval* is false.

21:52 paraseba: ohhhh magic!!!!

21:52 TimMc: Indeed.

21:52 paraseba: that's so cool

21:52 TimMc: And now you also know how to prevent one kind of code injection.

21:52 amalloy: heh

21:52 paraseba: long live S-expressions ... no more json needed

21:53 amalloy: paraseba: funny you mention that; it's the subject of my latest blog

21:53 TimMc: http://hubpages.com/hub/Dont-use-XML-JSON-for-Clojure-only-persistence-messaging

21:53 amalloy: muahaha. minions to promote my writing for me. genius

21:54 paraseba: perfect timing!! that's exactly what I was trying to do....

21:54 TimMc: haha

21:54 amalloy: paraseba: i don't mention print-dup, though

21:54 TimMc: amalloy: Yes you do.

21:54 amalloy: that is, i say that it exists and how to use it, but don't mention how to print new kinds of objects

21:55 do i?

21:55 paraseba: "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:55 * amalloy looks

21:55 amalloy: i'll add a section on defining print-dup methods

21:57 paraseba: thanks for the help and the post

21:57 amalloy: &(binding [*print-dup* true] (pr [1 2 *ns*]))

21:57 sexpbot: ⟹ [1 2 #=(find-ns sandbox7565)]nil

21:57 amalloy: &(binding [*print-dup* false] (pr [1 2 *ns*]))

21:57 sexpbot: ⟹ [1 2 #<Namespace sandbox7565>]nil

22:19 amalloy: paraseba: i've edited the hub. do you see anything helpful i've missed in the new section?

22:20 TimMc, feel free to jump in too

22:20 paraseba: amalloy: let me see

22:21 TimMc: amalloy: You might mention *read-eval* very briefly.

22:21 G'night!

22:22 amalloy: night

22:23 paraseba: amalloy: maybe you could use the constructor (Date. long) and (.getTime d)

22:24 amalloy: maybe a reference to clojure documentation? is this mechanism documented anywhere? in particular the reader hook

22:24 amalloy: it's surprisingly hard to find that documented

22:24 paraseba: hehe tell me about it ....

22:27 amalloy: take a look at the code for print-ctor

22:27 amalloy: eh? where?

22:27 paraseba: clojure.core

22:28 it takes care of the #= part for you

22:28 amalloy: nice

23:32 technomancy: thunk: nothing ended up happening on your front with the clojars hacks, did it?

23:43 dnolen: holy crap does defining equal and hashCode speed up collection performance.

23:45 amalloy: dnolen: really? i'd guess that the default identity-oriented versions of that are pretty fast, and fairly decent partitioning for hashing etc

23:47 dnolen: amalloy: 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:49 it's faster than the times recorded by the original miniKanren developers on a 3ghz Xeon using Skew Random Binary Access Lists.

23:49 brehaut: dnolen: thats awesome!

23:50 amalloy: dnolen: i don't understand any of that but it sounds great :)

Logging service provided by n01se.net