#clojure logs

2010-02-13

00:01underdevqed: do you have those clojure yasnippets?
00:20joshua-choiQuestion: I'm looking at some undocumented reader macros. What do #< and #= do?
00:30qed,(doc #<)
00:30clojurebotUnreadable form
00:30qed,(doc #=)
00:30clojurebotEvalReader not allowed when *read-eval* is false.
00:39somniumb
00:52gstrattonHow do I persuade Leiningen to use my version of a jar instead of downloading its own?
01:05gstrattonAh, name it correctly
01:18no_mindhow do I calculate the memory consumed by a clojure app
01:25technomancyno_mind: JMX is one way to do it
01:26danlarkinPIRANHAMOOOOOOOOOOOOOOOOOOOOOSE
01:27qedcan anyone help me troubleshoot why my paredit is flaking out? I can't use C-) when I'm [|] to slurp
01:27qed{} are behaving irregularly as well
01:34qed*sigh* -- what could have changed to screw this up so badly?
01:40qedi give up
01:51piccolinoIs there some way to indicat directly that a function should be in a specific namespace?
02:53LauJensenDoes anybody know of a catch-all location paramter you can pass to nginx, in order to trap all urls under a certain domain ? like md.dk, md.dk/one/two etc
02:58LauJensenNvm, faked it
03:33defnhello
03:33kmurph79how is a hash map different from a hash?
03:38defna hash map refers to key/value pairs, whereas a hash generally refers to the value alone within the context of a hash map
03:39defnerr im sorry that's not right
03:39defnwell, it sort of is
03:41defnkmurph79: does that make sense?
03:41defnyou have a key, you run it through a hash function -- in a hash map you store the value in the container the key points to
03:42defnlike :fred -> [Fred's phone number] -- The hash is Fred's phone number
03:42kmurph79yeah
03:43noidithat's not quite right
03:43noidihttp://en.wikipedia.org/wiki/Hash_map
03:43kmurph79and a hash-map would the value and the number?
03:43defnyes
03:43defnerrr, the key and the number
03:43kmurph79yeah
03:43defn:a -> "A", :b -> "B", and so on
03:43defn:a is a key, "A" is a value
03:44defn"A" is the hash, the whole thing is a hash map
03:44morphlingkmurph79: do you come from ruby? they use "hash" short for hash map
03:44defnyes i was just going to say, many people use the two terms interchangeably
03:44kmurph79morphling: yes :)
03:44defnkmurph79: you may also hear someone talking about a "map" -- which can often refer to a hash map
03:45defnin clojure "map" could also refer to (map #(+ 1 %) [1 2 3])
03:45defnnamely, the function map
03:45defn,(doc map)
03:45clojurebot"([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence 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."
03:46defnthats a whole lot of mumbo jumbo which means you apply some partial function to each element in a collection
03:47defnkmurph79: in clojure there are two ways that i know of to represent "partials" -- think of partials like half a function
03:47defn,(partial + 1)
03:47clojurebot#<core$partial__5034$fn__5036 clojure.core$partial__5034$fn__5036@f74015>
03:47defn,((partial + 1) 1)
03:47clojurebot2
03:47kmurph79ya, i understand map. i was listening to rhickey's talk on clojure, and he was throwing around the 'map' term a lot, so that clears that up
03:48defn,(map #(+ 1 %) [1])
03:48clojurebot(2)
03:48defnkmurph79: stop me if im droning on :)
03:48kmurph79defn: no, it's much appreciated
03:50defnkmurph79: lots of functions will use partials like #(function %1 %2 %3)
03:50defn% is just a placeholder for the value it's taking from the collection you're applying the function to
03:51kmurph79understood
03:52defnspecicially %1 and %2 etc. are used when you have multiple collections
03:52defnlike:
03:52defn,(map #(+ %1 %2) [1 2 3] [4 5 6])
03:52clojurebot(5 7 9)
03:54kmurph79yeah, i digested the map function awhile ago
03:55Chousukedefn: (map + ...) is enough :)
03:55defnChousuke: sure -- I think they both demonstrate different things
03:55kmurph79so, a hash-map is just more efficient than a hash?
03:55Chousukenot really.
03:56defnone of them demonstrates #(fn %) (that syntax)
03:56defnthe other demonstrates to pay attention to functions which takes multiple args
03:56defntake*
03:56ChousukeBut #(+ %1 %2) is completely redundant since + already takes multiple parameters
03:56defnright, but the + in that example is completely unimportant
03:57defnChousuke: i see what you're saying, though
03:59Chousukemore accurately, the %n symbol just refers to the nth parameter of the function, and map just feeds the function as many parameters as there are collections to map over.
04:00defnChousuke: you're more right than me, but that doesn't stop me from being right as well
04:00ChousukeI thought you just made it sounds more complicated than it is :)
04:00Chousukesound*
04:01defni always feel like my explanations are pretty stupid sounding
04:02defnim a very visual learner though -- i learned #(fn %) before i learned how partials worked, because i thought partials seemed sort of scary at first
04:02defnthen i learned they're the same thing -- then i learned how fns which take multiple args work in partials
04:03kmurph79is #() a partial?
04:03Chousukethe #() syntax is one way to construct a partial but it's not so limited. also, #() always creates a new function
04:03Chousukea new Class, I should say
04:03Chousukea call to partial does not.
04:05ChousukeI think the most common use for #() is (map #(.javaMethod %) ...)
04:05Chousukeor filter
04:06defnwhat about remove?
04:06Chousukeconsider map a representative of the whole class of functions :)
04:06defnah nvm, you said most common
04:06defnmorning cgrand-rec
04:07ChousukeHowever, with clojure functions, #(foo %) is an anti-idiom because it creates a function that is pretty much equivalent to foo.
04:07Chousukebut if you need to fixate one of multiple args, #(foo % bar) or #(foo bar %) is pretty common as well
04:07defnfixate?
04:08defnto place within the context of a function's arguments? to place in a specific argument position?
04:08defnis that a fair definition?
04:08ChousukeI meant just "predetermine"
04:09Chousukeie, make a "partial"
04:09defnah ok
04:09ChousukeI guess just "fix" would have been more correct :P
04:09defnChousuke: as long as I've got you in M-x teach-mode, could I ask for some help with refs, atoms, agents?
04:10ChousukeSure. :P
04:10defnI understand (i think) how refs work, but there is a disconnect for me between real world application and what they are capable of
04:11defndo you have any examples for refs, atoms, or agents in a very simple real world context?
04:11ChousukeHeh. They are the construct you're supposed to use to make clojure to do real-world things. :)
04:11defnhaha -- I realize what i'm saying is flawed as I'm saying it -- let me just shut up and say: "I don't really get refs/atoms/agents. Can you help me understand them better?"
04:12Chousukeif ignoring java interop, Clojure is purely functional and without refs, you *can't* mutate anything. You can't have state.
04:12Chousukeand most interesting programs require some state
04:12Chousukeso, Clojure provides you with managed constructs for it.
04:13defni've heard the term mutate, and im not sure what that means in this discussion
04:13defn(sorry if this is remedial)
04:14Chousukedefn: Well, the reference types are really mutable. You can change them, unlike vectors or maps, which are values.
04:14Chousukeunlike traditional variables, however, the mutation semantics are well-defined
04:15defnso is my ref like my "int x=4;"?
04:15defnand then "print x" => 4, is that sort of like dereferencing?
04:15Chousukeit's closer to int *x = &four; where four is immutable
04:15defnah-ha!
04:17Chousukeof course, C pointers have no concurrency semantics for mutation, which is the point of all the different ref types in Clojure.
04:17defn,(def x (ref 4))
04:17clojurebotDENIED
04:17defn:( clojurebot, be nice to me!
04:18piccolinoIs there some easy way to take a Java Map<k,v> and turn it into a Clojure map? I must be missing something.
04:19Chousukedefn: atoms are uncoordinated but synchronous and mutable accross threads, while refs are coordinated and mutable accross threads. Agents are asynchronous, and Vars are only thread-locally mutable.
04:19Chousukeacross*
04:19Chousukemeh, I'm making many mistakes today :P
04:19Chousukepiccolino: I think just (into {} java-map) should work
04:20piccolinoAha!
04:20piccolinoNever thought to look for that.
04:20defnChousuke: do you know of a good set of examples for each ref type?
04:20Chousukehmm, not really.
04:20defnim just looking for something barebones which gets the point across
04:20defndamn..
04:21defnwanna write a few for me? ;)
04:21defn,(ref x)
04:21clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
04:21Chousukedefn: there's this though http://github.com/technomancy/mire
04:21defnoh right -- i forgot about that...
04:22zabAnyone here successfully deployed a Compojure app to App Engine? I am about to give up. :/
04:22defnzab: not to app engine, sorry
04:23Chousukewell, atoms are simple: (def x (atom 1)); @x -> 1; (swap! x inc) -> 2; @x -> most likely 2, unless some other thread changed the atom between the swap! and deref
04:24ChousukeI think You might use an atom for eg. game state in a single-threaded game.
04:25defnChousuke: if it was (def x (ref 1)); @x -> 1; (swap! x inc) -> 2; we could be sure that it is 2, simply because we used a coordinated mutable state reftype?
04:25Chousukedefn: refs don't support swap! at all. :)
04:25defnd'oh
04:25defnis swap part of the new transients stuff or am i way off?
04:26Chousukenah, swap! is an atom thing
04:26defn,(doc swap)
04:26clojurebotPardon?
04:26defn,(doc swap!)
04:26clojurebot"([atom f] [atom f x] [atom f x y] [atom f x y & args]); Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called multiple times, and thus should be free of side effects. Returns the value that was swapped in."
04:26defnthat sounds kind of like reduce?
04:27ChousukeIt's nothing like reduce :/
04:27Chousukeit just changes the value of the atom
04:27Chousukeby applying a function to its current value
04:27Chousukethere's also reset! which sets an atom to a given value
04:29ChousukeWith refs you would have a (def x (ref 1)) (dosync (let [a (ensure x)] (if (= a 1) (alter x inc) (ref-set! a 2))))
04:30Chousukethat would ensure that @x is 2 at the end of the transaction
04:30Chousukeoops. ref-set! x, not a.
04:31Chousukeusing ensure instead of @ is probably not necessary in this case but it shouldn't hurt either
04:33Chousukeit's basically saying "I depend on the value of x in the transaction" so the transaction will restart if other transactions that have touched x finish first.
04:37defnsorry, stepped away for a second
04:37defndamned telcos...
05:46djanatynUmm, sorry if I already said this, but does anybody know how to install clojure on Debian?
06:06hoeckdjanatyn: I don't think its worth installing clojure via apt, as clojure consists only of a single jar, but it seems that there is a clojure.deb available
06:11djanatynAh.
06:11djanatynThanks.
06:23zabI have a question related to VimClojure. When I send my current file to the Clojure server, the preview buffer displays a list of all the defined macros.
06:24zabThen when I visit the locally running web server in my browser, my request times out and nailgun reports java.lang.OutOfMemoryError almost instantly.
06:30cgranddefn: morning :-)
06:31zabOh right. I think it's because I don't know how to serve my servlet as a War file?
06:33zabHmm. Confused. This is an App Engine app. How do people develop GAE apps without recompiling everytime?
06:39konrWhat do you use to generate pdf files?
07:03LauJensenClojure has been #1 on DZone this morning, currently #2 :)
07:05zabLauJensen: Heh, your post is also on the front page of HN
07:05LauJensenaah right, cool
07:13hoeckkonr: you can use iText (http://itextpdf.com/), but you basically have to buy a book describing it and author your documents in a pdf-oriented way
07:14hoeckkonr: or use http://www.allcolor.org/YaHPConverter, a java-based html2pdf renderer and use some html-templating language from clojure
07:16hoeckkonr: and then there are lots of other libs which let you basically write pdf source in java
07:17StartsWithKand batik can convert svg to pdf using apache fop
07:21bsteuberI used iText for some small project, you can more or less do it without a book if you're willing to google around and have a look at the javadocs
07:22bsteuberactually, I have built a small clojure wrapper around it for my purposes
07:24hoeckbsteuber: yes, I wouldn't mind buying the book, but at the time I looked at it there was only a book about an old iText version available :/
07:24bsteuberhm, then maybe it wasn't so bad I just used online resources
07:52konrhoeck: thanks! haha that's what I was considering too... the pdf libraries are so insanely verbose, that it's better to write html and convert
08:16scodetechnomancy|away: I'm looking at making leiningen support system dependencies. Do you have any opinions on how? Mainly I'm considering having :jar-dependencies, but otherwise supporting some different syntax to :dependencies, such as "[:system name path/to/file". The latter seems cleaner.
09:13yuukiCan *in* be rebound with dynamic scope?
09:20StartsWithKyuuki, yes; see with-in-str or you can do it with binding
09:21yuukisweet, with-bindings is what I was looking for
09:55qedIs there any interest in Clojure being a mentoring organization in the Google Summer of Code?
09:57konrit would be awesome
09:59qedthe only thing I have to worry about is how many people want to play with clojure who beat me with their proposals
10:04no_mindqed, you will be surprised how many people lurk for GSoC
10:07qedno_mind: in here?
10:07no_mindqed yes, let google announce the names of organizations
10:08no_mindqed, I had been GSoC mentor twice and and both times more than one kid has beaten my expectation
10:09qedno_mind: so you think there's a good chance for Clojure in the GSoC this year?
10:10no_mindqed, clojure is getting popular and there is no restrictions on number of students. To start with you can take only one or two students for first year
10:10no_minderr
10:10no_mindI mean no restriction on the minimum number of students an organization intakes
10:11qedno_mind: well, I certainly hope clojure is one of the organizations. I'd kill to write Clojure for the summer.
10:12no_mindqed, sure. So who is going to be the admin ?
10:12no_mindqed, also Google has changed the format for organization signup this year. They are asking more questions upfront
10:12qedno_mind: i have no idea -- i think it's time to post to the list
10:13no_mindqed, yeah and if we want to be in GSoC we have to create an ideas page before applying
10:13qedif everyone puts their heads together in a few threads on the list I bet we could get it done
10:14no_mindqed, sure
10:14qedno_mind: since you've been a mentor you probably know a lot more than me. would you post something to the list about it?
10:14qedill do anything i can to help
10:14no_mindqed, you start the thread and I will follow
10:14qedk
10:15no_mindqed, firs thing we have to decide is, whether we want to accept proposals for core clojure or for clojure contribs
10:20qedno_mind: I tossed something very basic up there to gauge interest. Feel free to reply with any information you might have on the topic.
10:20no_mindsure
10:22no_mindqed, which mailing list you had posted to ? google group ?
10:23pdkare gsoc applications open yet
10:24qedno_mind: yes the clojure google group
10:24qedpdk: mentoring organizations can apply Mar 8th => 12th
10:25pdkand students apply after then?
10:25no_mindpdk, no
10:26no_mindpdk, once google announces the list of orgs, there will be a 2 week period for students to interact with orgs
10:26no_mindthen student applications open on march 29th
10:28no_mindqed, I dont see the post yet
10:37triyoLauJensen: you there?
10:40triyoYour post "My tribute to Steve Ballmer" was the best one so far. I used it to produce a ascii art of pic of "my wife, daughter and I" and got a nice frame to go with it and gave it to my wife for Valentines. ;-) thx for the idea. All that weighing in at $8 with pic frame.
10:56LauJensentrio - I'm glad you liked it - Hope the Mrs. and the little one are pleased :)
11:00triyoLauJensen: yup, indeed. Had to go with something different than the generic valentines gifts. On the serious note, good article. Keep it up.
11:00qedditto. thanks Lau
11:04LauJensennp guys - great with some positive feedback, thanks
11:06LauJensenits actually been overwhelming well received, I thought I'd get some sucker punches because of the association with MS, but its been on the frontpage of HN all day, top of DZone and it just his reddit/r/programming/new
11:06triyoLauJensen: here is the result btw: https://dl.dropbox.com/u/2146210/aisha_and_alen_ascii_art.html
11:06LauJensenThats great :)
11:06triyoLauJensen: this is fine, just don't do "x" VS "y" ;-)
11:07triyothen you get flamed
11:08LauJensentriyo, after I did the Ruby Scala post, Rich said "Its time to kick butt and chew bubble gum, and I'm aaallll outta gum", then I knew it was time to quit
11:08triyoLauJensen: the ascii pic came out nicely to on the actual print too
11:08LauJensencool - Though I feel a little cheated that you didn't give her a picture of Steve Ballmer :)
11:09LauJensen(kidding)
11:09triyohehehe, well if I wanted to share the shit our of my wife, it would have been my first choice
11:10triyo*share=scrar
11:10triyoe
11:10triyoscare
11:10triyo;)
11:11triyoOh btw, anyone in the mood for a "your mother is so fat" joke? CS style that is?
11:11LauJensenalright - I gotta jet I'm in the middle of a very complicated project, so catch you all later and again, thanks for the feedback
11:11triyocool
11:11triyohttp://i.imgur.com/pPw3p.jpg
12:33technomancyhow do you check for OS X in a shell script?
12:33triyoone sec I have it somewhere
12:34triyoI think I checked darwin on uname or something..
12:34triyoone sec
12:36technomancyanyone know what might be causing this kind of error when using Xbootclasspath on OS X? http://gist.github.com/303481
12:36technomancyputting clojure.jar on Xbootclasspath works great on Linux, but it bails when running tests on OS X
12:36triyoecho $OSTYPE
12:37technomancytriyo: what's that value on OS X?
12:37technomancywhich makes debugging that much more annoying
12:37triyoif [[ $OSTYPE == 'darwin10.0' ]]; then
12:37triyo:)
12:38triyonot exactly perfect though... I'm trying to find my script that I have that actually only checks part of it as far as I can recall
12:39triyoactually its better to check on uname
12:40triyolike so:
12:40triyouname=`uname`
12:40technomancyyeah, so that should be "Darwin"
12:40technomancy?
12:40triyoif [[ "$uname" == 'Darwin ]]; then
12:40triyoalways
12:40technomancycool
12:40technomancythanks
12:40triyonp
12:41triyothen you can have your elif's for "Linux" "Cygwin", etc.
12:49dabdhow do you refer to a Java inner class? I am trying Class$InnerClass but it is not working
12:55chouserdabd: that should work, but note you have to import that whole name
12:55chouser(import 'the.package.Class$InnerClass) ...then you can use just Class$InnerClass
12:55dabdchouser: I was just about to try that
14:14rrc7cz-hmwhat's the best way to recursively search a nested map structure? I know clojure.walk does something similar, but it appears to be more like a recursive map. I don't want to replace anything, just return the first matching node. Basically like seq-utils/find-first but recursive
14:19hiredmanyou can use find-first with tree-seq
14:20hiredman,(doc tree-seq)
14:20clojurebot"([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree."
14:20hiredman,(tree-seq map? vals {:a {:b :c}})
14:20clojurebot({:a {:b :c}} {:b :c} :c)
14:25rrc7cz-hmhiredman: thanks, I'm playing with it now. In reality I have something like [{:a {:b :c}} {:a {:b :c}} {:a {:b :c}}
14:27hiredmanrrc7cz-hm: output from clojure.xml/parse?
14:28rrc7cz-hmhiredman: when I find a match, I actually have to return a sibling's value. For example, if I search for :id=3, then [{:a {:b 1 :c 2 :id 3}} {:a {:b :c}} {:a {:b :c}}] should return let's say the value of :c, or 2
14:29hiredmanthat is a very differnt kettle of fish, you want to search keys and values
14:29rrc7cz-hmhiredman: correct, I think I screwed up my initial question
14:30rrc7cz-hmI'm searching for the first value match of a specific key, then returning a specific sibling's value
14:30hiredmanhave you looked at clojure.zip yet?
14:31rrc7cz-hmI believe I used it for some xml parsing a while ago, but I'll take another look at it
14:51raekfor storing dates (no conversions or anything calculating-ish), is it worth it to use java Dates?
14:51raek...or should I just use a map?
14:52arohnerraek: java Dates are fine
14:52arohnerbut as soon as you start calculating or converting, use Joda
14:53raekI want to parse "2009-02-13T19:52:12Z" into some internal representation and be able to format it back to the same format
14:53raekjava uses year - 1900, right?
14:53arohnerjava uses unix time
14:56raek,(str (java.util.Date 2009 02 13))
14:56clojurebotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
14:56raek,(str (java.util.Date. 2009 02 13))
14:56clojurebot"Sat Mar 13 00:00:00 PST 3909"
14:56raekhmm, yeah
14:57raekPST? how do I tell it that my datetime is in UTC?
15:02arohnerraek: looks like you don't, from the java constructor
15:02arohnerincanter has a wrapper lib around joda
15:02arohnerit's nice
15:05raekthat constructor has been deprecated since JDK 1.1, anyway..
15:05arohnerraek: http://liebke.github.com/incanter/chrono-api.html
15:05raekarohner: ah, thanks!
15:08arohneris there a function that does conj, but if both items are not collections, makes a new collection?
15:10raekarohner: how do you mean? my intuitive interpretation of conj is "to collection X, add element Y"
15:11raekwith maps, though, "Y" can be a map too
15:12raekmaybe the source code for "->" has some interesting bits
15:12raekas -> turns the arguments into lists if they aren't
15:14arohnerright, #(if (seq? %1) (conj %1 %2) (conj [] %1 %2)) works just fine
15:15arohnerand I'm surprised I'm the only one with this problem. in clojure, that's usually an indication you're not doing things the right way
15:15Chousukeyou might want to use coll? instead of seq?
15:15Chousuke,(seq? [])
15:15clojurebotfalse
16:40avarushi!
16:40jimtgood morning!
16:41avarusheh, almost :)
16:42avarusI'm having a problem with data types and jdbc it seems
16:43avarusI play around with contrib.sql and my pgsql server and I struggle with strange error messages about wrong types
16:43avarusfirst I had the problem with timestamps, now with boolean :)
16:43avaruswhen I want to update or insert a boolean type contrib.sql spits out an error or does nothing
16:43avaruseven doesn't hit the database at all
16:43avarusthat's really odd
16:44avarusI tried to do something like (boolean true) e.g. and I got one run where it worked
16:44avarusbut the same app, still running doesn't work anymore :P
16:44avarusso after I googled the java guys use something like "java.sql.Types.BOOLEAN"
16:45avarusbut how can I do it in clojure?
16:45LauJensen~clojureql
16:45clojurebotclojureql is http://gitorious.org/clojureql
16:46avarusI check it out, thx
16:49avaruslooks interesting :)
16:50avarusI'll try it
16:50kevin_lmHi! Any enlive users out there know how if it is possible to specify an adjacent selector. i.e. [E + F]?
16:52LeafwI am getting a very weird error: I import one class, but clojure complains about some other class not being found (?) which I never use or import in this code. What sense does that make?
16:52Leafwfrom the interpreter.
16:53Leafwrepl
16:53avaruswhich is?
16:53avarusthe error I mean
16:53Leafw(and, in any case, that other class is in a jar in the classpath anyway)
16:53Leafwjava.lang.NoClassDefFoundError: mpicbg/models/CoordinateTransform (FFT_frequency_range_to_stack.clj:56)
16:54LeafwI never import or use that class in my code.
16:54avaruswhat libs are you using?
16:54Leafwour own lib: imglib.jar
16:54Leafwthe class that it "cannot find" is in the mpicbg_.jar, which has classes that also start with "mpicbg.*"
16:55Leafwboth jars in classpath. But I cna't see how it should matter
16:55Leafwthis error is total astroturf, like C going over an array limit and complaining later about something else
16:55avarushehe
16:55Leafwnot a good thing.
16:57Leafwif anybody has seen import-related errors like this, let me know what can cure clojure of this total mishap
16:57avarusLauJensen: I guess selecting from my own server-stored pgsql functions just works, right? :)
16:58avarusLeafw: are you building the final jar or what?
16:58Leafwavarus: no, just running a script with load-file
16:59avarusand I guess the line number it tells you is utterly useless
16:59Leafwputting the imports under the ns declaration at the top also incurs in the same error
16:59Leafwno, that line number is where the import was.
16:59avarusook
17:00Leafwthe import for that *other* class, which is unrelated except for having the same "mpicbg.*" start of the qualified name
17:00LauJensenavarus: I hope so :)
17:00avarusoh oh :)
17:01LeafwI donn't understand what the import function or macro is doing, but it's doing the wrong thing when there are classes with same start of package name, stored in different jar files.
17:02guille_hi
17:02raekis there a simple way to filter the keys of a map?
17:02Leafwimporting the class that "can't be found" (I never imported nor needed it) directly works.
17:03avarusperhaps you found a bug
17:03Leafwraek: (filter <pred> (keys somemap)) ?
17:03raeki want a function that returns a map, which keys are the union of some "allowed" keys and the actual keys
17:03Leafwmore than a bug, this is a calamity. A total show stopper.
17:04Leafwimports are so much unlike the rest of clojure.
17:05guille_raek: maybe http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/disj ?
17:05raekmaybe (into {} (filter #(#{:a :b :c} (key %)) somemap))
17:06raekI want to remove all bindings in a map, except those whose keys are in a set
17:06chouser,(select-keys {:a 1, :b 2, :c 3} [:a :b])
17:06clojurebot{:b 2, :a 1}
17:07raekchouser: perfect! thanks...
17:13avarusLauJensen: so I installed gradle and clojuresque and cloned the clojureql repository, now what? :) the readme.markdown says something aboyt ivy a, not gradle
17:13avarus-a
17:14avarussame as in clojuresque? gradle build?
17:14avarusI'll try
17:14avarusna, that fails, mhh...reading again, I must have missed something
17:15LauJensenavarus: http://www.bestinclass.dk/index.php/2009/12/clojureql-where-are-we-going/
17:15LauJensenThere's a section on building
17:17avarusya, "Building the thing"
17:19avarus"Gradle will handle that automatically once you build ClojureQL." but then there is already "In closing" :)
17:19avarusor perhaps I misunderstood the part that gradle needs the jar clojuresque jar :)
17:20avarusya, ok, "gradle build" is all I need regarding tghe mailinglist
17:23avarusbut it fails with this: http://pastie.org/823735
17:24avarussettings.gradle only contains "rootProject.name = clojureql"
17:25LauJensenDid you see both ENV vars correctly ?
17:25avarushttp://pastie.org/823736 <-- verbose
17:25avarusyes, I do
17:25avarusbin of gradle is in the path and GRADLE_HOME shows the home dir of gradle
17:26LauJensenIf PATH contains the bin, and GRADLE_HOM points to the Gradle root, then enter your newly cloned clojureql root dir and hit 'gradle build', thats it
17:26LauJensenNo need to install clojuresque since the build script declares it as a dependency
17:26avarusya, too late :) I followed your instructions and then read it's not needed :P
17:26LauJensenSorry - I will practice blogging more
17:27avarusbut that's not the problem here, I think
17:30avarusorg.gradle.api.GradleScriptException: Settings file '/Users/andreas/clojure/clojureql/settings.gradle' line: 1
17:30avarusit sounds quite obvious to me but I don't know what's being expected there in line 1
17:31LauJensenDid you clone the main repo ?
17:32avarusgit clone git://gitorious.org/clojureql/clojureql.git <-- is that the main repo?
17:32LauJensenyes
17:32LauJensenhttp://gitorious.org/clojureql/clojureql/blobs/master/settings.gradle
17:32avarussame content as here :)
17:33LauJensenok- please delete that file locally, try again
17:34avarusdid it! :)
17:35r0man,(= #"" #"")
17:35clojurebotfalse
17:35r0man, (= (str #"") (str #""))
17:35clojurebottrue
17:35r0manhello #clojure, i'm wondering about regex equality. why is this? because of java interop?
17:37r0man,[(= #"" #"") (= (str #"") (str #""))]
17:37clojurebot[false true]
17:37LauJensenI apologize for the trouble
17:38avaruslol! np :). I am the one thanking you if that piece of software is helping me on my way to the millions of dollars I dream of :P
17:39LauJensenI strongly recommend not dreaming about money
17:39avarusok, I'll earn it :)
17:54raekis there a simple way to do a map (function) like thing, but on the values of a map (data structure) instead of on a seq?
17:55raekif I had made it, I'd call it map-val
17:56raekhmm, clojure.contrib.datalog.util/map-values
17:57LauJensen(map f (vals m))
18:06raekwell, I want the result to be a map too...
18:06raekhere's my solution:
18:06raek(defn map-vals [f m] (into (empty m) (for [[k v] m] [k (f v)])))
18:24JonSmithIf i'm using fleetdb, can I just run it in my existing clojure image instead of using the client library?
18:26arohnerJonSmith: I don't know, but I'd be surprised if you can't
18:33JonSmithokay
18:33JonSmithwell i will try and see
19:55jwhitlarkso, 0xFF in the repl gives me 255, but (byte 0xFF) gives me -1. Any suggestions on how to get a byte with all the bits set?
19:55gstratton(and (byte 0xff)
19:56raekjwhitlark: I think you got it
19:56_atojava byets are signed
19:56jwhitlark(and (byte 0xff))
19:56jwhitlarkoops.
19:56raek,(and (byte 0xff))
19:56clojurebot-1
19:56raek(and (byte 0xff) (byte 0xab))
19:56raek,(and (byte 0xff) (byte 0xab))
19:56clojurebot-85
19:57_ato-1 = 11111111 in two's complement
19:57_atohttp://en.wikipedia.org/wiki/Two%27s_complement
19:57_ato,Byte/MAX_VALUE
19:57clojurebot127
19:58raekjava doesn't have any unsigned values at all, right?
19:58jwhitlarkok. I'm trying to construct a magic packet for wake on lan, I was using (repeat 6 (byte 0xff)), the (into-array (Byte/TYPE)) xxxx) on the result.
19:59raek,(format "%x" (byte 0xff))
19:59clojurebot"ff"
19:59_atothat should work
20:00jwhitlark_ato: the code I have should work?
20:00jwhitlarkI must be doing something else wrong.
20:00_atoyes, signed -1 = unsigned 255, so the network card will interpret it has 0xff
20:01_atoI'd use a packet sniffer and compare what your code is sending to some other implementation and see if there's a difference
20:01raek(byte-array 6 (repeat 6 (byte 0xFF)))
20:03raekdoes the array from into-array get its size from the seq?
20:03jwhitlarkI thought so.
20:04_ato,(count (into-array Integer/TYPE [1, 2, 3]))
20:04clojurebot3
20:04jwhitlarkI'm passing the length in later, so as long as the data is there, (and I checked with aget), it should work...)
20:04avarushas anyone ever experimented a bit with contrib.sql and pgsql? :(
20:04raekah, ok. nevermind... :)
20:04jwhitlarkI'll try wireshark
20:09avarusI'm having a problem updating simple data by id which is a number
20:09avarusI get an exception because pgsql fired an error due to type mismatch
20:10avarusor I get no exception but nothing has changed
20:10avarusno data being affected
20:10avaruscontrib.sql is not hitting the db then
20:13tolstoyThere's no official clojure 1.1 jars at clojars for leiningen to grab?
20:16_atoit's here http://build.clojure.org/releases/
20:16_atobuild.clojure.org/snapshots is in lein's default repo list but not releases
20:16_atoguess I should mirror them on clojars too
20:16_atohmm
20:17danlarkinbuild.clojure.org is stable
20:17tolstoylein has a default project file it builds.
20:17tolstoyI've not problem finding clojure and clojure contrib.
20:17tolstoyWas just curious to have lein find them as part of its deps.
20:18tolstoyThe default project file has 1.1.0-alpha-SNAPSHOT for clojure, and "1.0-SNAPSHOT" for contrib.
20:20tolstoyThat would be cool! ;)
20:21tolstoyI've developed a couple of little projects in clojure but didn't use lein. And now I'm trying it, and feel stymied right at the start! :)
20:24_atook done. give [org.clojure/clojure "1.1.0"] a try
20:25tolstoyAh! Will, do.
20:25tolstoyIs there any more documentation on lein than the github readme?
20:26tolstoy_ato: That works well. Thanks!
20:26_atonot official documentation, there's a couple of random tutorials, just google: leingingen tutorial
20:26tolstoyOkay. Yeah, for instance, how do you make your uberjar know where the main class is? Stuff like that.
20:27tolstoyah, lein help jar gives me the details. phew!
20:27_atoyep, and the README does mention briefly: :main - specify a namespace to use as main for an executable jar
20:27tolstoyGotcha.
20:42jwhitlarkah. I got it. I was parsing the mac address wrong.
20:42jwhitlark(map #(byte (Integer/parseInt % 16)) (re-split #"\:" mac)) works properly.
20:42jwhitlarkthanks for the help.
20:48tolstoyHm. I want a "lein swank". ;) And a "lein run".
20:49_atohttp://github.com/technomancy/leiningen/tree/master/lein-swank
20:50_atohttp://github.com/ericlavigne/leiningen-run
20:51tolstoyNice!
21:00tolstoyHm. leiningen run requires all those jars?
21:03_atoodd, looks like it pulls in maven-ant-tasks by mistake
21:04tolstoyThat's a mistake? I was just looking at that project.clj
21:04_atowell it doesn't seem to use it
21:05tolstoyMaybe the "exclude" thing will help?
21:06tolstoyHm. That didn't work.
21:06_atocould do, 'fraid I haven't used excludes or that leiningen run. I either use SLIME or bite the bullet and do the full: java -cp 'src:lib/*:classes' clojure.main -e "(use 'something)(-main)"
21:06_atoguess I should turn that into a shell alias or script to save typing it out all the time
21:07tolstoyYeah, I'm okay with that sort of thing to. Nice custom "run" and "swank" scripts.
21:07sethslein run is awesome
21:08sethsat least it makes me happy :-)
21:08tolstoyseths: Yeah, but it seems to require 23 jars.
21:08tolstoylein exclusions work only for dependencies, not dev-dependencies, it seems.
21:14tolstoylooks like exclusions don't work at all. maybe the readme is wrong, or that's not in the stable version
21:15sethstolstoy: as long as you lein clean before uberjar, it's not an ongoing annoyance
21:15tolstoyI spose.
21:15sethsnot ideal mind you
21:15sethsI'd love it to be part of lein
21:15seths(just a happy user of both)
21:17tolstoyI don't understand why lein-run requires maven-ant-tasks.
21:19tolstoyFor instance, if I delete all those extra dependencies, lein run still works.
21:20sethsheh
21:23tolstoylein-swank includes them too!
21:23sethsanother plugin I'd like to see in core
21:24sethslein 1.1 should be coming out soon I think. After that might be a good time to fork & issue pull requests on github
21:24sethsI'm trying to figure out why putting clojure.jar in -Xbootclasspath:/a causes lein test to get all grumpy
21:24tolstoyHm.
21:25sethsnot on Linux, only on Mac so far
21:25tolstoyEach of them (swank and run) seem to require maven because they don't really run in the same context as leiningen.
21:27tolstoyAll this would be okay of :exclusions worked.
21:27avarusno! it was a fucking simple typecast!
21:27sethsrofl
21:27sethsIRC is great at random times
21:28avaruscan't believe it was so simple
21:30avarusnow, god, please rewind the last 6 hours of my live, please!
21:30avaruslife :>
21:30avarusnarf
21:39JonSmith,0xFF
21:39clojurebot255
21:41tolstoyAh hah. Leiningen stable doesn't have the exclusion stuff.
21:50avarusguys...I have to sleep! :P
21:50avarusgood night
22:03JonSmithis there a good filesystem ultilities library yet
22:03JonSmith?
22:03JonSmithlike
22:03JonSmithfiles in a directory, navigate up and down etc.
22:16mattrepltolstoy: get :exclusions issues worked out?
22:17tolstoyYep.
22:17tolstoyTurns out the "stable" version didn't have that feature.
22:26DrakesonIn the ns macro, how can I :require or :use a namespace that only differs in its last term (after the last .), with the current namespace? (IOW, a namespace relative to the current one)
22:28tolstoyDrakeson: You don't just use the fully qualified name?
22:30Drakesonsometimes it is a bit cumbersome
22:30tolstoyIndeed.
22:30Drakesonespecially when you want to move/rename things around
22:31tolstoyI think the names spaces translate to java packages, and they're all relative to the classpath, not the place where the file actually is.
22:31tolstoyYeah.
22:31_atoyeah there's no relative imports
22:31tolstoyIn Java, you don't have to import class that are in the same package, but it's still a problem to move things from package to package.
22:31tolstoyThus, Eclipse and the like.
22:35tolstoyCan you splice arrays outside of a macro? `@list, or something like that?
22:37_ato,(let [stuff [1 2 3]] `["hi" ~@stuff "there"])
22:37clojurebot["hi" 1 2 3 "there"]
23:01JonSmithhm
23:01JonSmithi bet you could write an uber-ns macro that uses a heriarchy for require and use
23:20piccolinoDoes proxy invoke the compiler every time it's called?
23:24_atono, if I remember correctly it generates one class (per parent class + interfaces) at compile time with method stubs that just call a fn pointer, then each time you call proxy it just creates an instance of that class and plugs in your proxy functions.
23:26piccolinoOK, cool, thanks _ato.
23:29_ato,(class (proxy [Thread] []))
23:29clojurebotjava.lang.IllegalStateException: Var null/null is unbound.
23:30_ato,Thread
23:30clojurebotjava.lang.Thread
23:30_atoguess clojurebot disallows it
23:30_atobut it evals to: clojure.proxy.java.lang.Thread
23:30_atowhich is that one class that all proxies of Thread will be instances of
23:30piccolinoYeah, I just tried it in the repl.
23:34piccolinoAnd there's no way to give a proxy object a member variable?
23:38tolstoypiccolino: The methods you override are full closures, so you could make use of that, maybe.
23:39tolstoy(let [instance-var (init)] (proxy ....... (some-fun [] (use instance-var) ....)) etc, etc.
23:39tolstoyPoor man's subclass?
23:40piccolinoHm, OK, thanks.
23:41tolstoypiccolino: All I know is that if you proxy a class that calls an abstract method in its constructor, you're screwed.
23:41piccolinoHeh, don't need that fortunately.
23:42tolstoyYeah. I learned that after many hours of dealing with code in which the dev seems to think the constructor was the place for 90% of the business logic.