#clojure logs

2009-01-08

01:19knapruser=> java.lang.ClassCastException: clojure.lang.LazilyPersistentVector cannot be cast to clojure.lang.Symbol (pg.clj:0)
01:19knapruser=>
01:19knapr(ns progs.netflix.pg
01:19knapr (:import (libs.name.choi.joshua [fnparse :as fnp]))
01:20knapri have c:/clojure in the classpath
01:20knaprso but fnparse folder in c:/clojure/libs/
01:24knaprah require
01:26knaprjava.lang.Exception: namespace 'fnparse.src.name.choi.joshua.fnparse'
01:26knaprnot found after loading '/fnparse/src/name/choi/joshua/fnparse' (pg.clj:
01:26knapr?
01:29hoeckknapr: :import is for java classes only
01:30knapryes i did (:require now
01:30knaprname.choi.joshua is the namespace
01:30knaprbut the whole path is fnparse/src/name/choi/joshua
01:32hoeckaha, does your classpath contain "..../fnparse/src/"?
01:33knaprC:/clojure
01:33knaprthen i added fnparse/src to the require
01:35knaprok worked
01:35hoeckcool
04:13Kerris7Has there been any movement on the Planet Clojure front?
04:18duck1123Kerris7: I think there is a Yahoo Pipes for Clojure
04:18Kerris7duck1123: I guess that's no movement, then.
04:39danlarkinKerris7: I want one too :)
05:22danlarkinI keep typing "prinln ..." in python... *sigh*
05:22danlarkinprintln I mean
05:35djpowellI'm using resultset-seq; Am I right in understanding that when I run code that runs over a seq, that if I'm iterating along the seq with doseq, and nothing is holding onto the head of the seq, that the seq will get garbage collected as I iterate it, and so I can iterate along infinitely longs seqs this way?
05:46cgranddjpowell: you're right
05:47djpowellcool, thought so - just a sanity check
05:48djpowellI'd had an OutOfMemoryError caused exactly by what is currently being discussed on the mailing list regarding lazyness - hopefully not def'ing the lazy sequence will fix that
05:49djpowellI'm basically using clojure to do some grouping of data from multiple database queries.
06:31duck1123clojurebot: braindump
06:31clojurebotI don't understand.
06:31duck1123that wasn't it
06:31duck1123clojurebot: what do you know?
06:31clojurebotI don't understand.
06:32cgrandclojurebot: brain dump?
06:32clojurebotbrain dump is http://clj.thelastcitadel.com/clojurebot
06:33duck1123thanks
06:33cgrand404
06:33cgrand:-(
06:34duck1123clojurebot: macro help?
06:34clojurebotmacro help is http://clojure-log.n01se.net/macro.html
06:50lisppaste8duck1123 pasted "error trying to pass functions to be evaled and included" at http://paste.lisp.org/display/73288
06:51duck1123anyone willing to help me figure this out?
06:57cgrandduck1123: did you try with (eval %) instead of (%)?
06:57duck1123yes, I got a different error, one sec
06:58duck1123hmm... It's different than the last time I tried, but I'm getting a NPE
06:59cgrandwhy is auth-handlers a fn?
06:59cgrandsince it's a fn, try (eval (list %))
06:59duck1123there we go: java.lang.ExceptionInInitializerError
07:00duck1123auth-handlers is a fn so I can break them up into different sections. Now that I think of it, it doesn't need to be
07:01kotarakduck1123: check the backtrace. There should be something more useful then ExceptionInInitializerError
07:02cgrandwell, here with ~@(map #(eval (list %)) handler-fns)
07:02cgrandit works
07:03lisppaste8duck1123 annotated #73288 with "using eval" at http://paste.lisp.org/display/73288#1
07:06duck1123ok, that works somewhat. But now I'm getting quoting problems.
07:06duck1123This may be more work than it's worth
07:06lisppaste8cgrand annotated #73288 with "dohandlers" at http://paste.lisp.org/display/73288#2
07:19durkais an atom a good choice for a "static variable" in the C sense?
07:19durkai.e., a state that needs to be available, and possibly updated, each time the fn is called
07:20durka(let [history (atom {})] (fn [...] ... (swap! history ...)))
07:23durkas/fn/defn
07:30Chouserdurka: probably. will it ever be called in a transaction?
07:31durkapossibly, i suppose
07:31durkato the caller it appears side-effect free
07:33Chouserif it gets retried in a transaction, 'history' will still contain the changes made by the previous try. Will that break anything?
07:36durkain the two places i'm using this so far, yes and no respectively
07:36durka:)
07:36durkaone use case is remembering visited directories to avoid symlink loop while recursively scanning
07:37durkathe other is memoizing an algorithm
07:37durkaactually in the first case i think it's fine
07:38danlarkindurka: for memoizing you can use clojure.core/memoize
07:38durkabecause the atom is inside the defn, and passed to tree-seq, so if the whole function got retried by a transaction it would be recreated
07:38durkadanlarkin: there i go reinventing the wheel again
07:49Chouserdurka: good, then you're all set.
07:50Chouserdurka: if the chain of questions I asked leads to "a retry might break it", or even if you're just not sure, you can drop back to a ref and you're covered.
07:51durkaso with a ref i would have to start inernal transactions
07:51durkabut those would get absorbed into any parent transaction?
07:52Chouserright
08:04durkais add-classpath deprecated?
08:04Chouseralways has been
08:05ChouserRich added it somewhat reluctantly, I think, to allow a little bit more flexibility at a REPL, but it's not meant to be used in programs.
08:06technomancyit would help if the docstring mentioned its deprecation.
08:07technomancyor if it were fixed to work reliably; that'd be great too. =)
08:07durkai'm writing a program that really wants to know the full classpath, and there doesn't seem to be a way to find out what's been added with add-classpath without relying on the internal implenentation of clojure.lang.RT
08:14technomancywhat's the reason behind the reluctance to write add-classpath?
08:15technomancyit seems like a huge leap forward compared to defining your classpath in CLI args or environment variables, assuming it could be gotten to work correctly.
08:28Chousertechnomancy: I don't fully understand it. It has to do with classloaders and delegation and other ugly details of the JVM.
08:31technomancyso he's not opposed to the idea, he's just opposed to the implementation because it can't be Done Right on the JVM?
08:31ChouserI couldn't say, but I guess that's my general impression.
08:36technomancyI can buy that.
08:37rhickeytechnomancy: what problems are you having with add-classpath? - made changes recently to fix problem with import
08:38ChouserI've hit some kind of wall regarding the reading of every post to the group.
08:38technomancyrhickey: I will try it again with a recent build if that implies that it's not deprecated.
08:39technomancypretty sure it was an import problem though; lisp code was working fine
08:40replacaChouser: just an overload problem?
08:40Chouserreplaca: :-) possibly.
08:40Carkquestion : it has been a little while since i used clojure so i updated everything but i get an error while starting up swank : No such var: clojure.lang.RT/ROOT_CLASSLOADER (basic.clj:261)
08:41Carkanybody having this issue ?
08:41replacaChouser: bad for you, but maybe good for clojure. If clojure's successful, the group will end up being split, I'm sure.
08:41Chouseror maybe the sophistication of the members is such that each thread is more specialized into a corner I care less about, rather than general Clojure topics that I find compelling.
08:41Chouserreplaca: right, I don't mean to imply this is a bad sign for Clojure or anything. Just a sharing a little personal observation. :-)
08:42replacaChouser: you mean like weird proxy ideas :-)
08:42ChouserCark: ROOT_CLASSLOADER is inaccessible as of yesterday. Other code may need to be updated.
08:42Carkah thanks !
08:42Carkhum any other way to access it ?
08:43ChouserCark: I don't use swank, and don't know if fixes have been made.
08:43ChouserCark: you can try replacing "clojure.lang.RT/ROOT_CLASSLOADER" with "(clojure.lang.RT/baseLoader)"
08:43Carkchouser : ok thank you, i'll do that
08:43Chouserreplaca: hm, dunno, maybe I haven't read that thread.
08:45replacaChouser: and you're getting senile :-) Cause, you responded.
08:45Chouserreplaca: ah! oh. hm.
08:47replacaChouser: the thread to which I refer (in which we agreed that I was sick :-)): http://groups.google.com/group/clojure/browse_thread/thread/e51f75750da6cbb8/ab03fa5e5245194a?lnk=gst&q=faulhaber#ab03fa5e5245194a
08:47Carkchouser : would you beleive this was fixed as we were speaking !
08:47ChouserCark: I would.
08:52achim_pthat's a bug, right?:
08:52achim_puser=> (- (Integer/MAX_VALUE) (int -1))
08:52achim_pjava.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0)
08:52achim_pbut user=> (- (Integer/MAX_VALUE) (int -2147483648))
08:52achim_p-1
08:56durkaGorilla=> (- Integer/MAX_VALUE -2147483648)
08:56durka4294967295
08:56durkaGorilla=> (- Integer/MAX_VALUE (int -2147483648))
08:56durka-1
08:56durkathat's very strange...
08:59achim_pi think i'll post to the group
08:59replacadurka: clojurebot gives me -1 in both cases
09:00replaca,(- Integer/MAX_VALUE -2147483648)
09:00clojurebot-1
09:00durka,(class -2147483648)
09:00clojurebotjava.lang.Integer
09:00achim_pi see why it's happening
09:01ChousukeI get -1 for both
09:03achim_pit's in Numbers/minus(int, int) the second xor doesn't work because if y = -MIN_INT then -y==y (unchecked)
09:16Chouseryou have to check your code to make sure it doesn't use reflection if you want it to work as an applet.
09:17durkaChouser: did you see my report last night
09:17durkaon os x your applet works in appletviewer but not in browsers
09:17Chouserdurka: no, I didn't see that.
09:18durka-gonehere's a trace http://paste.lisp.org/display/73276
09:19Chouserwhoa. final method what?
09:19durka-gone.
09:19Chouserhuh
09:19durka-gonein the console it didn't have those boxes around the .
09:20AWizzArdis there a modulo function in Java/Clojure?
09:21AWizzArdI don't want rem() but modulo
09:22kotarakAWizzArd: I think there was something on the list a few days ago.
09:25mmcgranaif I have an arbitrary string, is there a way to get a Pattern equivalent to the one that you would get with using that string in the literal pattern syntax. i.e. #"foo\\" <=> (??? "foo\\")
09:26AWizzArdmmcgrana: do you want regular expressions?
09:27mmcgranaif i understand you correctly, yes
09:27Chousermmcgrana: re-pattern
09:28Chouserexpect then you'd need the literal string to be "foo\\\\" in order to get #"foo\\"
09:28mmcgranaChouser: the syntax is different though, right?
09:28AWizzArdTo learn more about regex themself have a look at http://www.regular-expressions.info/
09:29Chouserthe syntax for building the string is different, but once you've built the string re-pattern will give you the equivalent regex Pattern
09:33mmcgranaI'm trying to build a tool that needs to take a string in the form of the literal regex syntax and convert it to a pattern. I understand that I need (re-pattern "foo\\\\") to get #"foo\\", but I'm not sure how to go from "foo\\" -> "foo\\\\" programatically.
09:34danlarkinmmcgrana: (.pattern #"foo\\")
09:34Chouserthe problem is literal clojure strings cannot represent all of the possible regex literals. That's exactly why #"" now uses different escaping rules than ""
09:35Chouser#"\w" is a legal regex literal. "\w" is NOT a legal string literal
09:35mmcgranaChouser: ok, ic
09:36mmcgranadanlarking: I think i was looking for the reverse of that
09:36mmcgranasrry about the misspelling
09:37Chousermmcgrana: now if you're reading the regex from a file or something, that's a different matter.
09:37Chouserbecause then it doesn't have to be a legal Clojure string literal
09:38mmcgranayeah, thats the idea. then I can just use re-pattern, right?
09:39Chouseryes
09:40mmcgranaok, got it. thanks Chouser, danlarkin, AWizzArd for your help
09:40hiredmanclojurebot: bit is <reply>0
09:40clojurebotAlles klar
09:40hiredmanclojurebot: bit is also <reply>1
09:40clojurebotIn Ordnung
09:40hiredmanclojurebot: bit?
09:40clojurebot0
10:02aperotteChouser: I read on the google group that you were working on texture, how is it coming along?
10:02aperotteChouser: textjure*
10:03ChouserI'm pretty badly distracted by other things.
10:03Chouserat this point it's mostly just another Swing repl
10:07hiredmanclojurebot: a bit, one bit only!
10:07clojurebot1
10:12aperotteChouser: ok, is there anything I can do to help the project along?
10:13Chouseraperotte: sure, any code that leads to the goal would be very welcome
10:13kotarakChouser: is there some repo online?
10:13aperotteChouser: I have the general idea of the goal, but I'm not sure I know exactly what you had envisioned
10:13Chouserthe goal (for now) is best possible integrated text editor and repl with no extrenal dependencies
10:15Chouserfor me, that includes vim-like keybindings, but I'd be content with emacs-like keybindings in a framework that would support vi-like bindings when someone gets around to it
10:15Chouserhere's what i've got so far: http://github.com/Chouser/textjure/tree/master
10:15powr-tocIs there anyway that clojure could evaluate and display only a small portion of a lazy-seq if (and only if) it was evaluated at the REPL?
10:16powr-tocsorry, to be clear I mean evaluated BY the REPL
10:16hiredman*print-length*
10:16Chouserpowr-toc: you can (set! *print-length* 103) to prevent the repl from printing too much
10:16powr-toccool
10:16aperotteChouser: ok, I'll take a look and get back to you
10:17Chouserthe "no external deps" is specifically to reduce installation complexity and reduce the possibility of breakage due to changes in deps.
10:18gnuvince_vi keybindings?
10:18Chousergnuvince_: yes. they are the Right Way to run an editor. :-)
10:19gnuvince_In that case, somebody could use Vim. If the intention is to make an editor for people new to Clojure, I think it's fair to assume that a large majority of them will be coming from the Java world where they're used to modeless editing.
10:19gnuvince_In which case going with the usual keyboard shortcuts would probably be less off putting.
10:19hiredmanpffft
10:20ChouserI agree that should be the default, but I really want both.
10:20kotarakYes! Please!
10:20gnuvince_If you can manage to stick them both in there, then there's no problem.
10:21powr-tocDoes the REPL read a .clojure-config file where you can set parameters like *print-length* etc?
10:21ChouserI want this to (eventually) be powerful enough for me to use for at least a lot of my Clojure work, even if not for all programming work. Without that, this will always be a thing I'm creating for "other people" and it will be doomed.
10:21gnuvince_Do you see the project as a sort of IDLE for Python; a way for new users to test the thing, but most people eventually move away from it?
10:21Chouserpowr-toc: no. there's a user.clj, but last I knew that gets checked too early.
10:22Chousergnuvince_: I think if we can get that, we've got a good start, certainly enough to release and support. But I have dreams...
10:23gnuvince_k
10:25Chouserthe thing is, textjure has a lot of competition, primarily in the form of plugins for every IDE and editor under the sun: emacs, vim, netbeans, eclipse, jedit, etc. Which of course is fantastic.
10:25ChouserAnd a lot of these can share and/or borrow a lot of code from each other, which is also great.
10:26ChouserAnd it will be hard to lure away anyone who already has a serious investment in any of those, which is also fine.
10:28danlarkinChouser: just build a textmate-like project drawer to emacs, and then it will be the perfect editor. what more could you want? ;)
10:28ChouserSo the differentiator for textjure is two things: no external dependencies -- grab clojure, grab textjure (or maybe a single .jar with them bundled together) and you've got a solid environment.
10:28hiredmanclojurebot: emacs?
10:28clojurebotbut I like using notepad++!
10:29Chouserand: 100% clojure. No java code, no elisp code, no viml or ruby. If you know clojure you can tweak any part of it.
10:29kotarakChouser: I would really be happy to see textjure (especially with vi bindings) take off.
10:30powr-tocChouser: have you ever thought of enforcing structure editing (as available for drscheme)?
10:30Chouseroh, the no deps give you complete cross-platform support too, which seems to be difficult for a lot of the plugin systems to handle (enclojure sometimes doesn't quite work on Windows, clojure-box only works on windows, etc.)
10:30kotarakI like Vim. Bram did an awesome job. But it's limitation regarding external interfaces are starting to annoy me. (read "Gorilla")
10:30Chouserkotarak: yes. he was aiming for 100% backward compatibility with vi, which may have made sense at the time, but (for me at least) makes no sense now.
10:31hiredmanthat and vimscript
10:31kotarakah. Vim with Clojure scripting..... *dream*
10:31Chouserpowr-toc: What do you mean by "enforcing"? From the little i've seen of drscheme, paredit and such, I'd be very interested to have something like that to plug into textjure
10:33powr-tocChouser: just that when run in that mode, free-form textual editing isn't supported, rather everything is managed directly in terms of the sexp AST
10:33Chouserpowr-toc: how does that handle comments?
10:34powr-tocChouser: no idea, I've never used it ;-)
10:34powr-tochttp://uk.youtube.com/watch?v=GnQV4je9wTQ
10:34powr-tocDivaScheme is what I'm referring to
10:35Chouseryeah, I saw parts of a DivaScheme video. looks like it could be useful, but would take some extra effort to learn. So eventually, sure, but not a requirement.
10:37kotarakEvery feature should be optional. In particular such a rather esoteric editing style.
10:37powr-tocChouser: yeah, when I tried it I found the keybindings too confusing, so abandoned it... I still love the idea though! :-)
10:38ChouserI hadn't planned on soliciting help yet, so I don't know what patches I'd accept, but my personal plan is:
10:39Chouser1. finish the keybinding infrastructure to support either default swing text editor bindings or very basic vi-like bindings
10:40Chouser2. add editor commands (load, save, send-to-repl, etc.) to vi bindings, drop-down menus, and default-swing-mode hotkeys.
10:40Chouser3. add syntax highlighting to editor and repl
10:40Chouser4. add indentation support
10:41ChouserI think that'd be enough to be useful to be worth releasing.
10:58danlarkinanyone have a quick breakdown of the java web app deal? what the heck is the difference between tomcat/jboss/jetty/looking glass/geronimo/etc? I've tried reading wikipedia but it's all buzzwords to me
11:00technomancyJetty seems to have an emphasis on keeping it small and sane. Tomcat looks frighteningly complex.
11:00technomancy^ initial uninformed impressions
11:00drewrI'd say JBoss is probably the biggest beast in the list, but I'm no expert.
11:01drewrPeople seem to like Jetty these days.
11:01drewrIt comes embedded in a lot of stuff I download.
11:01technomancytomcat is written by a guy who thought executable XML should not be an offense punishable with jail time, which rules it out for me.
11:02danlarkinHmm
11:03Kerris7lol technomancy
11:03powr-toctechnomancy: yeah, it's a shame the Java world was obsessed with it for a while :-(
11:03powr-toc
11:04danlarkina few years ago for a job I had to install (drop some .wars in a directory) some java web apps on our server, at that point it seemed like *everyone* was using tomcat.
11:04powr-toc(executable XML that is)... ant, tomcat, various IOC schemes :-( even jetty has it :-\
11:05technomancyoh crap; jetty has it too? =(
11:05waltersyeah, at least they've finally collectively realized dynamic languages make sense
11:06powr-toctechnomancy: yeah... and it's configuration is possibly even more poorly documented than tomcat :-(
11:06technomancyhuh... well I only use it through compojure
11:06technomancylooks like jetty doesn't *require* xml, it just supports it.
11:07powr-toctechnomancy: if you have to, the trick to groking it is to see how things fit together in terms of java interfaces (study the javadocs) and then translate it into the xml :-\
11:07technomancybut that does mean it implicitly suggests that it's not a horrible idea, which is incorrect.
11:08powr-toctechnomancy: that's true... I always found jetty easier to plug together in plain java, but for some systems it's not an option to have configuration compiled in
11:09technomancypowr-toc: so far I've been able to let compojure handle all the details, and that's worked great
11:09powr-tocthankfully with clojure, you should be able to avoid it :-) though I suspect a thin layer of clojure functions/macro's might help
11:10powr-tocsweet! I've only briefly looked at compojure... I love sinatra, so compojure naturally appeals
11:10danlarkinand which backend does compojure use?
11:10technomancypowr-toc: it's a little weird just because it's so new and there's not a lot of guidelines on how to organize stuff or test stuff, but that just means you get to be involved in those decisions.
11:11technomancydanlarkin: it uses jetty
11:11Chouserbut people have gotten compojure servlets to work in tomcat, I believe.
11:11hiredmanclojurebot: compojure?
11:11clojurebotcompojure is http://github.com/weavejester/compojure/tree/master
11:11technomancyclojurebot: compojure is also a concise web framework inspired by Sinatra
11:11clojurebotAlles klar
11:12gnuvince_(doc lazy-seq)
11:12clojurebotPardon?
11:13danlarkinand also pretty much *the* way to write a java web app is to make it a servlet? and then that can be run by a "servlet container"?
11:13Chouser(dov lazy-cons)
11:13Chouser(doc lazy-cons)
11:13clojurebotExpands to code which produces a seq object whose first is first-expr and whose rest is rest-expr, neither of which is evaluated until first/rest is called. Each expr will be evaluated at most once per step in the sequence, e.g. calling first/rest repeatedly on the same node of the seq evaluates first/rest-expr once - the values they yield are cached.; arglists ([first-expr & rest-expr])
11:13technomancyhelma (a JS/rhino web framework) uses jetty too, and some folks at work have been deploying rails apps on it.
11:13technomancysince I'm not qualified to have an opinion on it, I'll steal one from others I trust.
11:14hiredmanI like the idea of generating a war file and just droping in a directory somewhere, but I have no idea if that is how it works, or how to do that
11:14powr-toctechnomancy: yeah, I used it as an embedded http server a couple of years ago... it's pretty awesome, though the docs could be better
11:15technomancyhiredman: I dunno; I prefer a non-violent approach.
11:15hiredman:P
11:15technomancy...
11:15technomancymy war file jokes are never as funny as they sound in my head
11:20powr-tocWhat would be the easiest way to address a 2D grid of vectors? [[:X :O :O] [:O :X :O
11:20powr-toc]
11:20powr-toc]
11:21powr-tocsorry pushed return too soon! It was supposed to be naughts and crosses grid
11:21technomancyok... if you want a #() function to just return a vector, is there a cleaner way than #(identity [:foo % :bar]) ?
11:22powr-tocshould I just use a nested nth on X and y?
11:22hiredmantechnomancy: vector
11:22kotarak#(vector :foo % :bar)
11:23technomancyhiredman, kotarak: of course; thanks
11:23Chouser(fn [x] [:foo x :bar]) ends up competing with #() for claity and brevity
11:23Chousersometimes I switch to using 'for' in these cases.
11:24technomancy"for" being list comprehensions?
11:24Chouser(for [x my-seq] [:foo x :bar]) instead of (map #(vector :foo % :bar) my-seq)
11:24Chousertechnomancy: yeah
11:24technomancyI like vector, but fn is better than identity.
11:25technomancyhuh... I kinda skimmed that section of the book since it reminded me of "we don't need no stinkin' lambdas" python, but I clearly need to look past my biases. =)
11:25kotarakclojurebot: for is not a loop
11:25clojurebotIk begrijp
11:31gnuvince_kotarak: excellent blog post, congratulations.
11:31kotarakhuh?
11:32gnuvince_Oops
11:32gnuvince_Sorry
11:32gnuvince_Similar names
11:32gnuvince_I meant Mark Engelberg
11:33gnuvince_But if you wrote a blog post, I'm sure it would be excellent ;)
11:33kotarakhehe ;D
11:43powr-tocare there any good code examples for test-is?
11:43powr-tocI know it has some included... but I mean, is there anything more substantial that uses it?
11:44kotarakThere is the clojure test stuff in contrib, I think.
11:45powr-tockotarak: thanks... looking through it now :-)
11:46powr-tockotarak: presumably these are unit tests for clojure and it's library it's self right?
11:46kotarakyes
11:52danlarkinpowr-toc: http://github.com/danlarkin/clojure-json/tree/master/test/test.clj I use it there... pretty basic usage though
12:42billczakwilson: you around?
13:24technomancythis "laziness traps" blog post is really thought-provoking: http://programming-puzzler.blogspot.com/2009/01/laziness-in-clojure-traps-workarounds.html
13:26hiredmandunno
13:27StartsWithKhow can i find url of resource that is in the same package as my .clj file?
13:27hiredmanseems like Chouser's response to him on the group solved his problem, no fuss, no muss
13:27technomancyah; I haven't made it through the thread yet
13:27technomancyspoiler alert! =)
13:28technomancyat least it's helpful to think about how these things work, even if the default doesn't change.
13:45hiredman1d6+3
13:45clojurebot8
13:48vladsharp_could anyone provide suggestions for sorting a collection by multiple "keys"?
13:48vladsharp_of course, i could split the sort results from the first key, then sort the sub-sequences...
13:49hiredmanreduce the keys into one key
13:50hiredmanalso
13:50hiredman(doc sort-by)
13:50clojurebotReturns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator.; arglists ([keyfn coll] [keyfn comp coll])
13:50hiredmanwait
13:50hiredmanthat is not what I wanted
13:50hiredmanthere is that other one someone was talking about
13:51hiredman*shrug*
13:51vladsharp_i'm all ears (yes i could reduce the keys into one, and that would entail a string comparison and be reasonably easy to implement)
13:52vladsharp_was wondering though if there was a built-in method for doing that, but the documentation didn't yield any results
13:54danlarkinthere's merge-with..
13:54danlarkin(doc merge-with)
13:54clojurebotReturns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter).; arglists ([f & maps])
13:56danlarkinI'm not sure exactly what you're asking for, vladsharp_, but would that help?
13:57vladsharp_it doesn't look like it
13:57vladsharp_example: sort a list of strings first based on length, then in lexographic order
13:58vladsharp_so (a apple b boo) would be sorted to (a b boo apple)
14:03hiredmanyou can use a custom comparator
14:03hiredman(doc sort)
14:03clojurebotReturns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator.; arglists ([coll] [comp coll])
14:03hiredman(doc comparator)
14:03clojurebotReturns an implementation of java.util.Comparator based upon pred.; arglists ([pred])
14:07hiredman,(fn [a b] (if (> (count a) (count b)) a (.(defn roll-die [sides]
14:07clojurebotEval-in-box threw an exception:EOF while reading
14:07hiredman (let [a (java.util.LinkedList. (range 1 (inc sides)))
14:07hiredman _ (java.util.Collections/shuffle a)]
14:07hiredman (first a)))
14:07hiredmaner
14:07hiredmanoops
14:08hiredman,(sort (comparator (fn [a b] (if (> (count a) (count b)) a (.compareTo a b)))) ["a" "apple" "b" "boo"])
14:08clojurebot("a" "apple" "b" "boo")
14:09vogelrnhiredman: As I recently learned, you don't actually need comparator because clojure functions implement comparator anyway
14:09lisppaste8StartsWithK pasted "Get resource url" at http://paste.lisp.org/display/73303
14:09hiredman,(sort (fn [a b] (if (> (count a) (count b)) b (.compareTo a b)))) ["a" "apple" "b" "boo"])
14:09clojurebotjava.lang.UnsupportedOperationException: count not supported on this type: sandbox$eval__1885$fn__1887
14:09StartsWithKis there another way to get resource url, or is this the right one?
14:10hiredman,(sort (fn [a b] (if (> (.length a) (.length b)) b (.compareTo a b)))) ["a" "apple" "b" "boo"])
14:10clojurebotjava.lang.UnsupportedOperationException: count not supported on this type: sandbox$eval__1891$fn__1893
14:10vogelrnhmmm
14:12ChouserStartsWithK: you're trying to find the url to a namespace?
14:13StartsWithKChouser: url to file in same package as my .clj file
14:13Chouseranyway, that's the same general procedure that I've used.
14:14hiredman,((fn [a b] (if (> (.length a) (.length b)) b (.compareTo a b))) "a" "b")
14:14clojurebot-1
14:14hiredman,(sort (comparator (fn [a b] (if (> (count a) (count b)) b (.compareTo a b)))) ["a" "apple" "b" "boo"])
14:14clojurebot("a" "apple" "b" "boo")
14:14StartsWithKthanks
14:15hiredmanoh
14:15hiredmanduh
14:17vladsharp_,(sort (comparator (fn [a b] (if (> (count a) (count b)) nil (.compareTo a b)))) ["a" "apple" "boo" "b"])
14:17clojurebot("a" "b" "boo" "apple")
14:18vladsharp_thanks for the hint :P
14:24vogelrnvladsharp_: I don't think that quite works
14:24vladsharp_vogelrn: i'm not sure why the nil is there, but it works on the example, no?
14:24vogelrn,(sort (comparator (fn [a b] (if (> (count a) (count b)) nil (.compareTo a b)))) ["apple" "a" "booc" "aood"])
14:24clojurebot("a" "booc" "aood" "apple")
14:25vladsharp_ah
14:25lisppaste8achim_p pasted "comparator cascade" at http://paste.lisp.org/display/73304
14:25achim_pvladsharp_: i solved a similar problem like this (see paste)
14:25hiredman,(sort (comparator (fn [a b] (if (> (count a) (count b)) nil (.compareTo b a)))) ["a" "booc" "aood" "b"])
14:25clojurebot("a" "b" "booc" "aood")
14:26vogelrnachim_p: that looks a bit complex
14:26durka-gonecomp-cascade might not be the best name because clojure.core/comp has nothing to do with comparators
14:26hiredman,(sort (comparator (fn [a b] (if (> (count a) (count b)) nil (not (.compareTo a b))))) ["a" "booc" "aood" "b"])
14:26clojurebot("a" "booc" "aood" "b")
14:26achim_pdurka: right
14:28vogelrn,(sort (fn [a b] (cond (< (count a) (count b)) -1 (> (count a) (count b)) 1 :else (.compareTo a b))) ["a" "booc" "aood" "b"])
14:28clojurebot("a" "b" "aood" "booc")
14:29achim_pvogelrn: it's a bit more generic, sorting by count and then lexicographically wasn't exactly what i needed to do
14:30hiredman,(#(sort (list % %2)) "booc" "aood")
14:30clojurebot("aood" "booc")
14:30vogelrnachim_p: ah, ok, I think I see what it does now
14:31vogelrnI had just glanced at it briefly
14:31hiredman,(#(let [x (sort (list % %2))] (if (.equals (first x) %) 1 -1)) "booc" "aood")
14:31clojurebot-1
14:31hiredman,(#(let [x (sort (list % %2))] (if (.equals (first x) %) 1 -1)) "booc" "aood")
14:31clojurebot-1
14:31hiredman,(sort (comparator (fn [a b] (if (> (count a) (count b)) nil #(let [x (sort (list % %2))] (if (.equals (first x) %) 1 -1))))) ["a" "booc" "aood" "b"])
14:31clojurebot("a" "b" "booc" "aood")
14:32hiredmandamn you sir
14:32vogelrnwhat are you trying to do
14:32hiredmanI don't know any more
14:33vogelrnthe nil should be a 1, I don't know about the rest :P
14:36vogelrnoh, and there's a missing parenthesis before the anonymous function literal
14:37vogelrnI think it's checking if the function (rather than its return value) is true
14:37vladsharp_hmnnn is this a macro? (map #(% x y) cs)
14:37vogelrn(doc map)
14:37clojurebotReturns a lazy seq consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments.; arglists ([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])
14:38vladsharp_lambda, silly me
14:38vogelrnyeah, the #() is an anonymous function literal, with %/%1, %2, etc as the arguments
14:38vladsharp_this is pretty much my 3rd day of playing with clojure
14:39vogelrnI've been playing with it for a couple weeks, but that doesn't mean much :P
14:40vladsharp_hmmm it can be pretty fun (also my first lisp)
14:40vladsharp_it's the point at which you go oooh so that's where feature x in javascript, ruby, language y comes from
14:41vladsharp_to some extent, at least
14:41vogelrnyeah, although I'm somewhat concerned that it's distracting me from getting acclimated with java again :P
14:42vogelrnit's fun to learn, reviewing java stuff, somewhat less so
14:42vladsharp_who needs ... oh wait.
14:44hiredmanclojurebot: give me a bit
14:44clojurebot0
14:44technomancyclojurebot: give me a bit
14:44clojurebot0
14:44technomancyclojurebot: give me a bit
14:44clojurebot0
14:45technomancyhiredman: is it always the same bit?
14:45hiredmannope
14:45technomancyI was kind of hoping for a 1
14:45vogelrnlol
14:45hiredmanbrand spanking new bits each and every time
14:45vladsharp_clojurebot: give me a bit
14:45clojurebot0
14:45hiredmanunless someone futzed with it
14:45vladsharp_clojurebot: give me a byte
14:45clojurebotTitim gan �ir� ort.
14:46vladsharp_that's pretty good compression
14:46hiredmanclojurebot: gimmie a bit oh that
14:46clojurebot0
14:46hiredmanhuh
14:47hiredmanweird, anyway, it sent a 1 in privmsg
14:47hiredmanrandom numbers, go figure
15:15rhickeyhiredman: fns used as comparators can be either simple predicates or fancier returning -1/0/1 - both work
16:02murphy_tccHello
16:02Chouserhi
16:04murphy_tccPlaying around a bit with multimethods in Clojure I wondered whether there was a way to specify the type hierarchy that is used by a multimethod.
16:05murphy_tccDoes someone know whether that's possible?
16:05Chouseryou can add to the hierarchy
16:05Chouseryou're aware of 'derive'?
16:05murphy_tccSure, but I was wondering whether I could have multiple sets of multimethods that used different hierarchies.
16:08Chouserhttp://groups.google.com/group/clojure/browse_frm/thread/f8b1be403c927b03/a0ec60c2f11554b6
16:09murphy_tccChouser: Thanks, that's what I was looking for.
16:56wlrChouser: apropos nothing... timestamps on clojure-log are 4h 38min behind the EST for corresponding messages in my chat client :-)
16:56hiredmanthanks rhickey
17:13Chouserwlr: bleh. that server has issues.
22:35knaprhow do I use standard javatyes? like double[][] for example?
22:38Chouseruse them in what way?
22:59zakwilsonknapr: You want a Java array of doubles? See make-array.
22:59zakwilsonBut Chouser has a point. Why do you want that?
23:01vogelrnyou know, one of the pros of Clojure -is- supposed to be java interop :P
23:02vogelrnalthough maybe I misinterpreted the tone of that, had forgotten what Chouser originally said
23:03zakwilsonI may have misread his intent. He seems to have been merely asking for clarification.
23:06Chouseryes, I didn't mean to be condescending or anything.
23:07Chousercreating an array vs. using an array vs. type hinting an array, etc.
23:09vogelrnChouser: yeah I misinterpreted zakwilson as being condescending until I bothered to look back at what he was referring to: what you said 20 minutes ago
23:20zakwilsonI probably sounded a little condescending. I shouldn't have.