#clojure logs

2009-04-30

00:01hiredmanhttp://gist.github.com/104249
00:04durka42that's neat
00:41z5hAre there a set of regression tests run against clojure releases? Are they available somewhere?
00:47z5hahhh. part of clojure-contrib http://code.google.com/p/clojure-contrib/source/browse/#svn/trunk/src/clojure/contrib/test_clojure
02:27Lau_of_DKTop of the morning gents
05:37neotykHi All
05:38neotykAfter downloading clojure I have problems building clojure-contrib (fresh from svn), error in types.clj:14
05:40neotykonly when built clojure from svn can build clojure-contrib
05:52leafwneotyk: that is not surprising
05:52leafwclojure-contrib svn repos chases clojure repos.
05:53neotykleafw: wouldn't it be a good idea to have distribution jars as clojure has?
05:54leafwneotyk: I am not sure how many people uses clojure-contrib that doesn't write parts of it too. Documentation is the code itself at the moment, as far as I've seen.
05:56neotykleafw: for new comers like me, I wan't to get clojure env in vim and it needs clojure-contrib
05:57neotykso to use vimclojure i need to build from svn
05:57neotykfine by me, but not very user friendly
05:58leafwneotyk: explain it to the mailing list, a solution may come up.
05:59neotykleafw: I'll post to list
06:23Raynesneotyk: Do you have the newest rev of Clojure? If not, try building Clojure from source (comes with an ant build script, no catches ;).) and then using it to build clojure.contrib.
06:25neotykRaynes: clojure-contrib builds fine if clojure is built from svn, just mailed it to mailinglist
08:11cemerickthe interaction of namespaced keywords and requiring namespaces w/ an :as alias is really painful. Assuming you've required com.foo.mynamespace :as myns, (= :myns/foo :com.foo.mynamespace/foo) => false
08:11cemerickam I missing something really simple here?
08:14rhickey::myns/foo
08:22cemerickI guess I was pretty tired, or something. Yeah, that's my excuse. :-(
08:23AWizzArdrhickey: did you see my messages (about 14 hours ago)?
08:23rhickeyAWizzArd: no
08:23Raynescemerick got owned by The Creator.
08:23AWizzArdCan you scroll up in the history of this channel?
08:23Raynes:p
08:25rhickeyAWizzArd: find the time anchor in http://clojure-log.n01se.net/date/2009-04-29.html
08:26AWizzArdIt started http://clojure-log.n01se.net/date/2009-04-29.html#17:45
08:28jdzi have not used hg, but imho git is awesome
08:29rhickeyAWizzArd: what's the question?
08:29cemerickoh good, an SCM LOC pissing match. Haven't seen one of those in a while. :-P
08:31AWizzArdI just was not sure if you maybe missed that your main points can easily be achieved with hg and git. In the last talk there were several git fans who had time to answer, while some experienced hg users could not say overly much.
08:32AWizzArdThat could have left the impression that work with branches in hg is somehow difficult.
08:35rhickeyIt's not just about the SCM, it's SCM, plus pubic Clojure hosting, plus commercial hosting (I'm not learning/using 2 things), plus IDE/tools support
08:35rhickeythese decisions are never purely technical
08:36AWizzArdyes
08:37AWizzArdIf the choice is (one-of :git :hg), then I am already sure, it is a good descision.
08:37AWizzArdWould just be nice if you got a fair impression of both candidates.
08:38rhickeyTorvalds says they're essentially the same, modulo some implementation details
08:38cemerickdoes anyone know of either some materials (blog posts/wikis/etc) that dig deep into how to leverage clojure's multimethods maximally, or alternatively, a codebase that does so? We now officially have a hash of various usage patterns, and I'd like to go beyond my intuition about idiomatic design, etc.
08:40AWizzArdrhickey: I also had mostly that impression. I was/am using both systems.
08:41cemerickI suppose I could dig into CL materials, but there's obviously a lot more capability in clojure, and I'd rather avoid the impedance mismatch.
08:42rhickeycemerick: have you seen enclojure's support for looking at multimethods?
08:42AWizzArdcemerick: could you tell a bit more what the obviously extras in capability are?
08:43neotykas recently jvanzyl (maven guy) is totally after git I'd expect very good support for it in Java world
08:43AWizzArdneotyk: Sun uses hg for the OpenJDK and for OpenSolaris...
08:43cemerickrhickey: You mean some widgets for doing some introspection on them?
08:43rhickeycemerick: yeah, really neat
08:43AWizzArdI think for people working in the Java domain hg seems to be a good fit.
08:43cemerickwe actually haven't upgraded our enclojure in quite a while -- we're using remote REPLs extensively, and everything's working, and I don't want to upgrade until we have some breathing room to allow for breakage.
08:44neotykAWizzArd: I know, and kenai is HQ as well
08:44cemerickAWizzArd: arbitrary dispatch fns (or dispatch multimethods themselves) brings a whole 'nuther level to it all.
08:44neotykbut Sun is not providing much of the tooling for it, does it?
08:45AWizzArdcemerick: some lines of CL code can extend CLs multimethods to do the same.
08:46AWizzArdI think it is a good design descision that rhickey took with Clojure. In CL it is possible, but noone is doing it.
08:46cemerickAWizzArd: Good to know. I'd certainly prefer avoiding picking up any bad (non-clojure-idiomatic) habits from other multimethod systems, though.
08:46AWizzArdyes
08:47cemerickit's bad enough that I've been thumbing through a pile of scheme code here and there. I actually wrote (define (...)) the other day in enclojure, and couldn't understand why I was getting evaluation errors for 30 seconds.
08:47AWizzArd*g*
08:54AWizzArdGoogle did some measurements of how fast cloning a hg repository is vs cloning a git repo over http. For hg they had about 8 seconds, for git it were around 178 seconds.
09:19cemerickhrm, what's the magic java.util.Formatter incantation to get a list's elements to be printed out?
09:19cemericknm, it was just a lazy seq...
11:38cemerick~max
11:38clojurebotmax people is 164
11:38cemerickI wonder what prompted that spike, and then falloff
11:38AWizzArdyes, strange
11:38AWizzArdAlso watch the number of members in the google group
11:38AWizzArdand the number of postings made
11:39cemerickThat's like a 30% short-term spike. That must have corresponded with rhickey presenting somewhere. Maybe qcon?
11:45RaynesI might just scream the next time I hear "Git is awesome!!1!1!!"
11:45bitbckt"Git is awesome!!1!1!!"
11:47RaynesI openly recognize that Git must be great, but the fanboyism that goes on about it is painful.
11:48bitbcktThe people on either side of a Holy War are equally to blame.
11:48tashafaclojure is on the front page of HackerNews
11:48tashafaif heads didnt alreadyknow
11:49cemerickis there any way to define an exception type that is specifically catchable in clojure code? I've tried proxying Exception and then doing (catch (class proxied-exception) ...), but try/catch is a macro, so it's looking for a classname there...
11:51danlarkincemerick: you need to gen-class the Exception derivative
11:51cemerickok, that's what I figured.
11:51cemerickwhoa, it's my first .java file in at least a month! :-)
11:52danlarkinit's annoying, but c'est la vie for now. You can always use Chouser's error-kit though!
11:52dnolencemerick: try/catch isn't a macro, it's special form right? in general, that's the trouble with special forms.
11:52cemerickeh, too simple a case for that...but yes, I do plan on digging into it eventually
11:52cemerickdnolen: yes, yes, you're right
11:53dnolen;)
11:54rhickeycemerick: being a special form is irrelevant - the jvm bytecode itself catches exceptions by classname
11:56cemerickrhickey: sure -- what I was thinking was that I could proxy an exception type, get a sample proxied exception, get its class, and then use that class/name to catch with.
11:56Chouseror
11:56cemerickIt's been a while since I've used proxy, and now it seems that (class proxied-exception) always returns something like clojure.proxy.java.lang.Exception, rather than a separate class identifying the proxy that was created.
11:56clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
11:57Chouseror use error-kit
11:57cemerickthat's all sort of moot though, since try/catch requires a classname symbol
11:57cemerick:-)
11:57cemerickChouser: danlarkin beat you to it!
11:58Chouseroh, sorry.
11:58cemerickChouser: I definitely plan on digging into what you've done with error-kit, but it was way too easy to just create a 4-line .java file.
11:58cemerick...in this case, anyway.
12:04cemerickI'm way, way behind on my skimming of contrib in general -- I *just* "discovered" graph, which saved me a bunch of time.
12:14replacacemerick: be careful with custom exceptions -> they often get wrapped in runtime exception on the way up the stack
12:14cemerickreplaca: by clojure, you mean?
12:14replacacemerick: that means it's hard to count on the exception type :-(
12:14replacacemerick: yeah, by clojure
12:14cemerickhrm. I guess we'll see how it goes.
12:15rhickeyreplaca: could be by anyone, Java's checked exceptions misfeature means there's no guaranteed path for any arbitrary exception to travel unchanged
12:15cemerickI'm using the ex to catch constraint violations while processing a stateful queue, so if necessary, I could alter a ref with error info.
12:16replacarhickey: I understand. In the case to which I was referring it was just me and clojure :-)
12:16replacaBut I think that at the time rhickey and Chouser made me understand the reasons
12:16cemerickthank goodness we don't use much in the way of libraries
12:17replacachecked exceptions seemed like such a good idea back in '94
12:17rhickeyusing types to convey data (what went wrong) is a bad idea
12:17rhickeyso static
12:18Chouserrhickey: really? why? something about Java classes in particular, or general to the idea of types.
12:18Chouserhm... you want more of a tag or property based thing
12:18replacarhickey: agreed, but it's nice too be able to have a place to shove a globally understood token that I can guarantee is unique to my code
12:19Chouserthrow a map full of details?
12:19rhickeyChouser: types are generally closed - a map would be far preferable, all call paths should be able to convey all problems
12:20Chouserhm... error-kit throws a map, and you can catch on whatever you want, but the syntax provided makes it by far easiest to catch by type
12:21rhickeythink about how silly it is to have to define a new class rather than just say :problem :my-ns/my-problem-foo
12:21rhickeyopen and extensible, no proliferation of useless types
12:21rhickeydynamic
12:22rhickeycall-foo-throwing-bar becomes possible
12:22rhickeye.g. if you have a problem, throw this thingy
12:22ChousukeIn such a system, what alternatives do you have if you wanted the "sanity checks" that static typing can offer? :/
12:23ChousukePerhaps you could assign types to things, but those types could not be used to make decisions in the program logic itself.
12:23rhickeyChousuke: are you pro- or anti- checked exceptions?
12:24ChousukeI'm against them, I guess :P
12:24replacarhickey throws down the gauntlet :-)
12:25ChousukeI'm not talking about just exceptions though, but typing and compile-time checking in general.
12:25clojurebothttp://paste.lisp.org/display/74305
12:25rhickeythen you know there is a tradeoff to static 'sanity checks' - rigidity and inflexibility
12:25rhickeyChousuke: it's just a continuum of rigidity
12:26mattreplmaybe "sanity checks" could be provided by identifying generalized types based on attributes (keys). either by looking at code or the runtime
12:27technomancydanlarkin: how's your http client going?
12:27rhickeyI think there wil be a world where we have substantially more introspection capabilities for our code and that could support any number of pre-runtime validations and reasoning about all sorts of properties of our programs, type-based or not
12:27rhickeyenforced or advisory
12:28danlarkintechnomancy: http://gist.github.com/98612 is the last I've worked on it
12:29cemerickhttp client?
12:29technomancydanlarkin: cool; thanks. any further plans for it?
12:29replacaApropos of almost nothing: my latest ideas for a utility is a function that reads all your files and finds defns that have the doc string after the args.
12:29Raynesbitbckt: That is exactly why I put absolutely no mind to the VCS. I just use whatever options I have. :p
12:30danlarkinrhickey: I look forward to the utopian future :)
12:31rhickeydanlarkin: http://java-source.net/open-source/code-analyzers
12:31bitbcktRaynes: Then your frustration seems misplaced.
12:33danlarkintechnomancy: yes... well... it's at least got to expose some way to add in arbitrary HTTP headers
12:33technomancydanlarkin: yeah. that and a more interesting name would be nice. =)
12:33technomancybut names are hard
12:34danlarkinI'm gunning for clojure.contrib.http, ideally
12:34technomancythat's a pretty good name. =)
12:34rhickeyclojure-in-clojure -> clojure-ast-as-clojure-data -> clojure-datalog -> ask-your-question
12:36replacadanlarkin: maybe we could have both clojure.contrib.http.{client,server}
12:38danlarkinreplaca: not from me :-o
12:38cemerickdanlarkin: not that you're taking feature requests or anything, but it'd be great if your http lib could wrap apache http-client (we don't bother using java.net.* anymore for http stuff)
12:38technomancycemerick: not if it's going in contrib
12:38danlarkincemerick: I whipped it up exactly because I didn't want to depend on apache http-client
12:39replacadanlarkin: yeah, but let's leave space in the namespace for it
12:39cemerickman, I'm always outnumbered on the use-the-libs-that-are-available argument. ;-)
12:40replacacemerick: I think that argument is going to be a feature of clojure
12:40technomancycemerick: some day in the glorious future of Clojure, you'll be able to automatically handle dependencies without writing XML
12:40cemerickreplaca: what, that contrib has clojure-y reimplementations of existing libs?
12:41cemericktechnomancy: come by sometime, I'll show you :-)
12:41technomancycemerick: o rly?
12:41replacacemerick: well, figuring out when that's the right thing and when the existing java version in the right thing
12:42rsynnotthas anyone tried clojure on the java google app engine, btw?
12:42technomancyrsynnott: apparently it works, but you don't get threads
12:42technomancyso it's not that interesting
12:42Chouserrsynnott: yeah, there are tutorials out there
12:42tashafayeah theres a tutorial out there
12:42tashafahttp://elhumidor.blogspot.com/
12:42Chouserout where? out there!
12:42Chouseroh, much better. :-)
12:42cemericktechnomancy: dependencies in git repos, git submodule to pull them in, one-time dependency addition via Netbeans' project properties. *shrug*
12:43rsynnottah, yep, the thread thing could potentially be a bit of a problem
12:43rsynnottmakes it not all that useful
12:43technomancycemerick: heh; I've been playing around with something similar: http://github.com/technomancy/corkscrew
12:44technomancycemerick: but you have to be able to depend on stuff in mvn repos for it to really shine, which I haven't gotten to yet
12:45cemericktechnomancy: we keep things simple by only depending on stuff we pull from private repos.
12:45technomancycemerick: that's a lot more work though; you have to convert every dependency by hand.
12:45cemerickThankfully, we've never had to depend on anything that requires any kind of fancy transitive-dependency-resolution stuff, either.
12:45Lau_of_DKGood evening gents
12:45technomancycemerick: yeah, that's where it gets really tricky.
12:45cemerickI refuse to depend on external services for running builds.
12:46technomancycemerick: sure, but the less-manual way to do that is to get an internal mvn repo that can mirror external ones
12:46technomancyso you don't have to convert everything by hand
12:47cemerickwell, I dislike maven on a number of fronts. Ivy is nicer, but not by much.
12:47technomancy cemerick: Ivy uses maven repos
12:47technomancyI'm just talking about the repo format here
12:48cemerickwell, we used our own ivy repo for about a year, and that was too much trouble. Now we just have a git repo for each dependency.
12:50AWizzArdrhickey: does it cost much memory to make use of the mvcc feature of the stm? Example: I have 5 refs, each storing objects of 500+ MB and then make a snapshot of all 5 and keep them several minutes while at the same time I actively modify the original refs.
12:52rhickeyAWizzArd: that's the beauty of structural sharing, your new versions should share substantially with your snapshot
12:53AWizzArdthat would indeed be very helpful for my persistency lib
12:57AWizzArdIf I have 10 refs and want to take a consistent snapshot of them all I would have to do it in a dosync, ensuring all refs, yes?
12:59rhickeyAWizzArd: just dosync will ensure a consistent read view, ensure is about preventing your transaction from completing if another transaction has changed them
12:59rhickeyyou never see the effects of other transactions in your own
13:00AWizzArdah ok
13:02technomancydanlarkin: do you want to put this HTTP lib into a real repo?
13:02technomancyor I could do it if you prefer
13:02technomancyI'd like to hack on it some
13:02danlarkintechnomancy: I had avoided that so far because I thought it best belonged in contrib and didn't want it to get all confusing when it moved or something
13:03technomancydanlarkin: seems like a readme would set things straight
13:04danlarkinyou can git clone the gist, you know
13:04danlarkinbut if you want to create a github project for it, be my guest
13:04technomancydanlarkin: yeah, but I'd like to set up a test suite etc, which would need more than one file
13:04hiredmansounds like the developement model I pioneered
13:04technomancyhiredman: heh
13:05technomancydanlarkin: ok, will do.
13:05danlarkinooooo tests, excellent
13:05technomancy=)
13:06lenstIt turns out gists can have more than one file.
13:06danlarkinI love when someone other than me writes tests
13:07AWizzArd~def ensure
13:07lensthttp://gist.github.com/96442
13:08technomancylenst: too late; it's a project. =)
13:08technomancydanlarkin: what do you suppose the best way to test it would be? maybe bundle a copy of ring that we can make requests to?
13:08AWizzArd~def touch
13:09danlarkintechnomancy: I've just been testing against example.com/netcat
13:09danlarkinbut like someone (you?) said, relying on an internet connection to run tests is suboptimal
13:10technomancydanlarkin: yeah, I'm not a fan. IMHO it needs to be self-contained; I'm just wondering what the best server to bundle and test against would be.
13:11hiredman:|
13:11danlarkinwell if it's going to be in contrib then it shouldn't really bundle anything
13:11hiredmanyou don't want to use apache's httpclient but you want to bundle a webserver?
13:12technomancytest dependencies are not the same as runtime deps
13:12hiredman...
13:13technomancyfor ease of hacking right now, it makes sense to bundle it since the only people who are going to use it are going to be folks hacking on it, so they'll need to run the test suite all the time
13:13technomancyonce it gets to the point where people are going to use it without modifying it, it doesn't make sense to keep that extra baggage
13:13danlarkin*shrug*, could always use a ServerSocket?
13:14technomancythat's not bad either I guess
13:14technomancyexcept it won't be able to tell you when requests are malformed
13:14technomancyyou'll just have to be more careful when specifying what you're expecting
13:15technomancythere's no built-in lightweight HTTP server in the JDK then?
13:15danlarkinnot in java5
13:16technomancywell having a java6 dependency for the test suite only is not bad
13:16danlarkinit is for me, since I am running java5
13:17technomancyoh... =(
13:17technomancywhy's that?
13:18danlarkinit comes with OS X 10.5
13:20technomancyok, I'll see about sticking with the ServerSocket then
13:20danlarkinI think that would be ideal... not sure how complicated it would be to have it just accept whatever input and then return the smallest valid HTTP 1.1/0 response
13:21danlarkinhopefully not very
13:37Raynesbitbckt: Just because I avoid the Holy War of Git doesn't mean it's not annoying.
13:39bitbcktRaynes: Why be annoyed by something you have no stake in? Seems like wasted cycles, to me.
13:40Raynesbitbckt: I still have to listen to the zealots. I'm not sure what you're getting at. Just because you can hear the siren doesn't mean you are sounding it. :\
13:42bitbcktRaynes: I've gotten where I'm going: it doesn't make much sense to me to be concerned, if you don't much care what the outcome is.
13:42bitbcktRaynes: The underlying point of this conversation and its topic is: to each their own.
13:43Raynesbitbckt: I'm not concerned, I just simply think it's annoying that whenever someone mentions "Git" people cream themselves.
13:44Raynesbitbckt: To each their own. Enough said.
13:44bitbcktRaynes: Indeed.
14:53technomancyis there anything like while-let?
15:00stuhooddoesn't look like it... maybe you could doseq over a lazy sequence that continuously calls your predicate?
15:00stuhood...yuck
15:01danlarkinthere's when-let
15:01danlarkinor is that not what you mean
15:03stuhooddanlarkin: he needs a loop
15:03neotykwhat happened to lazy-cons?
15:03stuhoodneotyk: replaced by lazy-seq
15:03neotykstuhood: thanks
15:04danlarkinohhh, I see. That might be a useful abstraction to make over the loop ... if... recur idiom
15:04rhickeyfor and doseq have :let options now
15:15AWizzArdah, didn't know that it was available for doseq
15:16AWizzArdfor for I made the experience that often the core of the loop goes into the :let
15:18stuhoodwhy put the let in an option instead of around the for?
15:19AWizzArdbecause only inside the for the data gets generated
15:19clojurebotfor is not used enough
15:19AWizzArd~ botsnack
15:19clojurebotthanks; that was delicious. (nom nom nom)
15:20stuhoodmmm, so why not inside the for? (for [...] (let ...))
15:21Chousukeconvenience, I guess.
15:22rhickeystuhood: the only reason to use :let is to use it in a subsequent clause and save evaluating it twice
15:22rlbIs there a standard clojure idiom for mapping over a sequence to create more than one result sequence? I assume clojure has something like srfi-1's unzip, but I wondered if there might be a preferable approach.
15:23AWizzArdfor example for can do this
15:23Chousukehmm
15:23rlb(avoiding the need to create a temporary, zipped sequence)
15:24AWizzArd,(for [x (range 10) :when (even? x)] [x (* x x)])
15:24clojurebot([0 0] [2 4] [4 16] [6 36] [8 64])
15:24AWizzArdReturns even numbers and their square
15:24stuhoodrhickey: gotcha.
15:25rlbAWizzArd: if that's for me, I'm looking for the eventual result to be [0 2 4 6 36] and [0 4 16 36 64].
15:25Chousukehmm
15:26rlbAWizzArd: while you can just unzip your result, I was wondering if there might be some alternate, well known approach to avoid the intermediate sequence of tuples. If not, I can always just build the lists in parallel more explicitly.
15:27rlbIn any case, it's not a big problem -- I just wanted to make sure I wasn't overlooking something obvious in clojure.
15:28Chousukeclojurebot: unzip
15:28clojurebotHuh?
15:28Chousukehmm :(
15:29Chousukeanyway, I can't think of a way to do this lazily :/
15:32AWizzArdrlb: ah okay I see. Well, I am not aware if there already is a function that avoids the intermediate data. So, going the explicit route seems right to me. But maybe Contrib has something.
15:32stuhoodthe intermediate tuples seems like a reasonably elegant solution
15:34Chousuke(def foo (lazy-seq (concat (apply map vector (map (fn [x] [(* 3 x) (* 2 x)]) [1 2 3 4 (do (println 5) 5)]))))) seems to be lazy :P
15:34Chousukewell, hm, I dunno how lazy, though :)
15:34AWizzArdstuhood: performance may be an issue
15:35AWizzArdrlb wants something similar as group-by which at the same time is doing a mapping
15:36stuhoodAWizzArd: maybe i don't understand the question, but if you generate a sequence of tuples, and then map nth across that sequence, everything is still lazy
15:37AWizzArdIf one requests data out of that sequence then it would be more performant to get the desired result directly, instead of iterating over the data twice
15:40technomancyoh nice; :let in for. handy
15:42AWizzArda loop for that task is quite verbose
15:46stuhoodindeed. here's one that generates a sequence of integers and strings:
15:46stuhood(let [tuple-seq (map #(list % (str %)) (range 1000000)) int-seq (map first tuple-seq) str-seq (map second tuple-seq)] ...)
15:49Chousukewith that, both of the values get realised when either is accessed through the seqs :/
15:49ChousukeI guess there's no way around that without using delay
15:49stuhoodyes, but if you don't want that behaviour, then shouldn't you just create two sequences in the first place?
15:50ChousukeI suppose
16:11rlbIf I don't care about traversing the input sequence multiple times independently, then I can just return multiple lazy result sequences based on the input. That's fine as long as the traversal isn't expensive (wrt cache, virtual memory, or anything else).
16:11hiredmanlazy-seq results are cached if you hang on to the head of the seq
16:12hiredmanso if you over a seq twice, but hang on to a reference to it, the second time doesn't do the computations to generate the seq
16:14stuhood*facepalm
16:14stuhoodso (let [tuple-seq (range 1000000) int-seq tuple-seq str-seq (map str tuple-seq)] ...) would have the same effect
16:14rlbhiredman: I'm not concerned about the computations -- imagine you have a sequence that's effectively bigger than RAM, even though the results of your multiple map calls won't be. You may want to make sure to only touch each input element one time for the generation of your N output elements. But it's easy to do that manually.
16:14rlbhiredman: i.e. you only want to touch each thing one time b/c you don't want to hit swap more than you have to.
16:14rlb(just as an example -- similar arguments can apply wrt cache)
16:15rlbAnyway, I was mostly just curious whether or not there was a clojure idiom I didn't know. There are plenty of other ways to handle this and related problems...
16:16rlbThanks for the help.
16:18AWizzArdYou want something similar to for, such as (group-into [x (range 10) :when (even? x)] x (* x x)) ==> ([0 2 4 6 8] [0 4 16 36 64])
16:18AWizzArdwould be a nice addition to clojure.contrib.seq-utils
16:21rlbAWizzArd: hmm, assuming it does what it looks like it does, that sounds about right.
16:21AWizzArdyes, it just doesn't exist ;)
16:23kotarak,(reduce (fn [[fs ss] [f s]] (list (conj fs f) (conj ss s))) [[] []] [[0 0] [2 4] [4 16] [6 36]])
16:23clojurebot([0 2 4 6] [0 4 16 36])
16:24AWizzArdeager but good
16:25kotarakThis must obviously consume the whole seq to build the first vector. Vectors are eager.
17:05technomancydanlarkin: does the HTTP client send an EOF or something when it's done with the request?
17:05technomancytrying to use raw sockets to test this thing. =)
17:05danlarkinI think it has to send two "\r"s or something like that
17:06technomancyoh, ok... same as how the response separates the headers from the body then
17:07technomancyactually... that ignores request bodies
17:07technomancywhich is fine for now, but those will be necessary
17:14stuhoodyou're implementing an http client?
17:15technomancystuhood: for now just trying to add tests to danlarkin's
17:18technomancyah... I see my problem. the "bindings" of with-open are lexical, not dynamic
17:20technomancybinding doesn't always mean binding, I guess.
17:57boredandblogginghow is RT.loadResourceScript supposed to be used? If I want to load a .clj thats not in the same directory, I keep getting a FileNotFoundException
17:58dliebkeis the file on your classpath?
18:01boredandblogging*sigh* need it was going to be something that stupid, dliebke, thanks :-)
18:01technomancyboredandblogging: generally you shouldn't be using load or loadResourceScript or anything unless you're messing around in the repl... in a real project you should stick to use and require
18:02boredandbloggingtechnomancy: can you give me a link where I can read up on that? basically I'm just trying to call the .clj from java code at the moment
18:03technomancyboredandblogging: oh, didn't realize you were working from Java. I know next to nothing about that.
18:06cp2hmm...
18:06cp2http://doihaveswineflu.org/
18:11ctdeanWhat's a simple way to read the contents of a file into a string?
18:13hiredmanslurp?
18:13hiredman,
18:13clojurebotEOF while reading
18:13hiredman,(doc slurp)
18:13clojurebot"([f]); Reads the file named by f into a string and returns it."
18:13ctdeangreat, thanks
18:33lisppaste8technomancy pasted "http client convenience functions" at http://paste.lisp.org/display/79490
18:33technomancydanlarkin: is that too cute?
18:43danlarkintechnomancy: is it necessary? I like just having request
18:44technomancydanlarkin: I think it helps minimize the noise
18:45technomancybut using eval is unfortunate
18:45danlarkinI feel like it creates noise
18:46technomancyin the implementation or the interface?
18:46danlarkinoh... sorry, I'm talking about the existence of the functions... the interface
18:47danlarkinthe implementation is cute but I think not a great idea for library code
18:47technomancyyeah, the stacktraces will get messy
18:48technomancyI guess since method defaults to get, you only have to specify it when you need to pass in custom headers or use post etc.
18:48danlarkinright
18:49technomancyalso: response headers need to allow for case-insensitive lookup
18:49technomancyso we'll need to return an fn instead of a map
18:50danlarkinI donno about that... then you can't run keys or vals on it... iterate over it, etc
18:51technomancythat's true
18:51technomancybut how would you allow for a case-insensitive lookup?
18:52technomancyit's possible with proxy, but that gets ugly
18:52danlarkinyeah proxy's all I can think of... but why does it need case-insensitive lookup?
18:53technomancybecause according to the spec, "content-type" should be treated the same as "Content-Type"
18:53danlarkinahh
18:53technomancyit's kind of wacky, but that's the correct behaviour
18:54danlarkinwhat about #(.toLowerCase %)ing all the keys?
18:55technomancythis is pretty edge-casey... I'll slap a TODO on it and deal with it later.
18:57technomancydanlarkin: how about this compromise: :headers is a map, :get-header is a fn that handles case correctly.
18:58danlarkinyes, that would be okay with me
18:58danlarkinI *think* python's urllib2 does that same thing
19:00technomancydanlarkin: current state: http://github.com/technomancy/clojure-http-client/blob/a0f94a7778419ec353c3fc5e2bad1ef65193cb8a/test/clojure/http/test/client.clj
19:03danlarkintechnomancy: it's looking solid
19:03danlarkinand tests! hooray
19:04technomancyI renamed "create-url" to "url" in order to be consistent with the "file" function in java-utils
19:04technomancyand implemented custom request headers.
19:05technomancyapart from that I think the only changes were making internal stuff private
19:12danlarkin_yeah the change to "url" is a good idea, good to be consistent
19:14technomancystill needs to support request bodies
19:14technomancytransforming a map into a form-encoded POST body
19:15hiredman(doc repl)
19:15clojurebotNo entiendo
19:17hiredman(doc clojure.main/repl)
19:17clojurebotGabh mo leithsc�al?
19:17hiredman,(doc clojure.main/repl)
19:17clojurebot"([& options]); Generic, reusable, read-eval-print loop. By default, reads from *in*, writes to *out*, and prints exception summaries to *err*. If you use the default :read hook, *in* must either be an instance of LineNumberingPushbackReader or duplicate its behavior of both supporting .unread and collapsing CR, LF, and CRLF into a single \\newline. Options are sequential keyword-value pairs. Available options and their d
20:02danlarkintechnomancy: here's a docstring for create-cookie-string, if you like: https://gist.github.com/7c99d0a79ae714ec1ca3
20:05technomancycool
20:08danlarkinoops! I put it after the arg list :) that's what I get for being too lazy to open the file in emacs
20:12technomancygood thing I didn't apply the patch directly. =)
20:19gnuvince_I'd like to preface this following statement with this: I am drunk
20:19gnuvince_CLOJURE FUCKING RULES!
20:38cp2gnuvince_: :)
22:07lisppaste8hiredman annotated #79434 "parent node fixed" at http://paste.lisp.org/display/79434#5
22:33eeehi
22:34durka42hi eee
22:34eeebeen stuck on my heap for days
22:34eeewill have to really study it this weekend
22:35eeeneed a second pair of eyes
22:35eeebut other than that it looks promissing
22:35eee(I think)
22:35eeeas a cool think for clj
22:36eeehad to comment out a line of code to "make it work"
22:36eeebut I don't get why :)
22:36eeewhat's up with others?
22:48chessguyhi eee . what is it you're working on, exactly
23:02eeehttp://code.google.com/p/jc-pheap/
23:07danlarkinblarg, why are my tests failing with "Wrong number of args passed to keyword: :type"... I'm not using type :(
23:08danlarkinsome change in clojure or contrib brought this on, since they used to work and I haven't touched the code
23:11hiredmanonly two places :type is used in core, the type function and print-method
23:12chessguyeee: sounds interesting. do you literally mean that no operations have side effects, or just no _visible_ side effects?
23:12eeelet me think
23:13danlarkinhiredman: the unit tests for my json lib
23:13eeeit's pretty close to the former
23:13chessguyimpressive
23:13eeei mean, you have to do 'new'
23:13eeewhen you insert
23:14eeeso is that a side affect?
23:14eeeeffect
23:14eeekinda philosophical question
23:14danlarkinI went to fix a bug (decode-from-string raises an exception when passed an empty string) but now I've gotten myself sidetracked :(
23:14chessguydo you get back a different object on different calls of new?
23:15eeejvm would give you a new object
23:15eeebut . . i mean, the whole jvm "changed"
23:15eeeso that's like a side-effect, too
23:15eeebut I guess that's not what you mean
23:16eeeso I think it's the former
23:16chessguywell if we wanted to outlaw side effects completely, we'd use haskell or something, right?
23:16eeemaybe that is one thing someone else could confirm
23:17eeei found an article on haskel which did lot's of destructive stuff
23:17eeewas way complicated
23:17eeehe showed that he could quicksort in place
23:17eeepartition in one pass
23:17eeeetc
23:17eeebut it was insane
23:18hiredmanclojurebot: shave that yak!
23:18clojurebotfastest sheers on IRC
23:18eeeat any rate, I have a test that should be showing that no operation affects any other view
23:19eeethe hard part was supporting deletes from the middle of the heap
23:19eeeand change priority from middle of heap
23:19eeei may have succeeded
23:20eeebut there's a gnawing feeling there's a bug that I just haven't found yet
23:20eeealso, usability
23:20eeelet's say I put in "a" with priority 5
23:21eeethen I put in "b" with priority 4
23:21eeethen I decide "a" needs an update
23:21eeeit is in the heap somewhere
23:21eeemin is where "b" is
23:22eeeso I have to tell the truth and say change "a" from 5 to 3
23:22eeebut if the program won't crash if you had said change "a" from 98 to 3
23:22eeeeven though no such value
23:23eeeis that ok?
23:23eeeone reason is that there can currently be more than one "a"
23:24danlarkinhiredman: the error is either something to do with my custom assert-expr or something in test-is, I have concluded
23:25chessguyeee: do you have actual use cases for this structure?
23:25eeegreat question
23:25eeethat would answer my question for me
23:26eeeso next step is to try to use it for A* search problems
23:26eeelike 15 puzzle
23:26eeeor I could implement shortest path
23:27eeeA* can just use regular heap without those fancy structures
23:27eeebut
23:27eeedjikstra's
23:28eeeneed's "decreaseKey()"
23:28eeei went for extra credit here making my life tough and you can "increaseKey()" too
23:29eeeand there are two deletes for deleting out of the middle. eagerDelete and lazyDelete
23:29clojurebotfor is not a loop
23:29eeefor
23:30cadswhat can I use in clojure for drawing graphs or 3d mathematical surfaces?
23:30danlarkinhiredman: figured out! the syntax to call test-is/report changed. *sigh*
23:30hiredmantada
23:32chessguyeee: they say you should have at least 3 instances of a problem to really write a good solution for it
23:33eeeok
23:33eeemy ultimate goal is to do parallel branch and bound in clojure
23:34eeebut first I needed the heap
23:34eeethen I need to learn the parallel stuff in clj
23:34eeeas well as just getting good at clj
23:35eeethe problem in the most generic terms, is that breadth-first-search is space-consuming
23:35eeebesides time-wasting
23:36eeedepth-first is just silly . . .sometimes even with a bounding function
23:36eeebut
23:36eeebreadth-first with a bounding function and a heuristic as to what to try first
23:36eeewell
23:36eeethe heap allows you to try stuff in priority order
23:37eeeand the bounding function allows you to delete what you can prune from the queue
23:37eeewhich requires delete from the middle
23:37eeei'd use eagerDelete to try to reclaim the memory as soon as possible there
23:38eeesince memory is the main commodity
23:38eeeso that's the problem space
23:39eeecads, this is cheating
23:39eeebut
23:39eeeyou can call gnuplot from java
23:40eeeas an exec
23:41eeehttp://www.ies.co.jp/math/java/misc/SimpleGraph3D/SimpleGraph3D.html
23:41eeea 3d java thing
23:47eeegnight all