#clojure log - Feb 13 2010

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

0:01 underdev: qed: do you have those clojure yasnippets?

0:20 joshua-choi: Question: I'm looking at some undocumented reader macros. What do #< and #= do?

0:30 qed: ,(doc #<)

0:30 clojurebot: Unreadable form

0:30 qed: ,(doc #=)

0:30 clojurebot: EvalReader not allowed when *read-eval* is false.

0:39 somnium: b

0:52 gstratton: How do I persuade Leiningen to use my version of a jar instead of downloading its own?

1:05 Ah, name it correctly

1:18 no_mind: how do I calculate the memory consumed by a clojure app

1:25 technomancy: no_mind: JMX is one way to do it

1:26 danlarkin: PIRANHAMOOOOOOOOOOOOOOOOOOOOOSE

1:27 qed: can anyone help me troubleshoot why my paredit is flaking out? I can't use C-) when I'm [|] to slurp

1:27 {} are behaving irregularly as well

1:34 *sigh* -- what could have changed to screw this up so badly?

1:34 * qed digs around

1:40 qed: i give up

1:51 piccolino: Is there some way to indicat directly that a function should be in a specific namespace?

2:53 LauJensen: Does 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

2:58 Nvm, faked it

3:33 defn: hello

3:33 kmurph79: how is a hash map different from a hash?

3:38 defn: a hash map refers to key/value pairs, whereas a hash generally refers to the value alone within the context of a hash map

3:39 err im sorry that's not right

3:39 well, it sort of is

3:41 kmurph79: does that make sense?

3:41 you 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

3:42 like :fred -> [Fred's phone number] -- The hash is Fred's phone number

3:42 kmurph79: yeah

3:43 noidi: that's not quite right

3:43 http://en.wikipedia.org/wiki/Hash_map

3:43 kmurph79: and a hash-map would the value and the number?

3:43 defn: yes

3:43 errr, the key and the number

3:43 kmurph79: yeah

3:43 defn: :a -> "A", :b -> "B", and so on

3:43 :a is a key, "A" is a value

3:44 "A" is the hash, the whole thing is a hash map

3:44 morphling: kmurph79: do you come from ruby? they use "hash" short for hash map

3:44 defn: yes i was just going to say, many people use the two terms interchangeably

3:44 kmurph79: morphling: yes :)

3:44 defn: kmurph79: you may also hear someone talking about a "map" -- which can often refer to a hash map

3:45 in clojure "map" could also refer to (map #(+ 1 %) [1 2 3])

3:45 namely, the function map

3:45 ,(doc map)

3:45 clojurebot: "([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."

3:46 defn: thats a whole lot of mumbo jumbo which means you apply some partial function to each element in a collection

3:47 kmurph79: in clojure there are two ways that i know of to represent "partials" -- think of partials like half a function

3:47 ,(partial + 1)

3:47 clojurebot: #<core$partial__5034$fn__5036 clojure.core$partial__5034$fn__5036@f74015>

3:47 defn: ,((partial + 1) 1)

3:47 clojurebot: 2

3:47 kmurph79: ya, 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

3:48 defn: ,(map #(+ 1 %) [1])

3:48 clojurebot: (2)

3:48 defn: kmurph79: stop me if im droning on :)

3:48 kmurph79: defn: no, it's much appreciated

3:50 defn: kmurph79: lots of functions will use partials like #(function %1 %2 %3)

3:50 % is just a placeholder for the value it's taking from the collection you're applying the function to

3:51 kmurph79: understood

3:52 defn: specicially %1 and %2 etc. are used when you have multiple collections

3:52 like:

3:52 ,(map #(+ %1 %2) [1 2 3] [4 5 6])

3:52 clojurebot: (5 7 9)

3:54 kmurph79: yeah, i digested the map function awhile ago

3:55 Chousuke: defn: (map + ...) is enough :)

3:55 defn: Chousuke: sure -- I think they both demonstrate different things

3:55 kmurph79: so, a hash-map is just more efficient than a hash?

3:55 Chousuke: not really.

3:56 defn: one of them demonstrates #(fn %) (that syntax)

3:56 the other demonstrates to pay attention to functions which takes multiple args

3:56 take*

3:56 Chousuke: But #(+ %1 %2) is completely redundant since + already takes multiple parameters

3:56 defn: right, but the + in that example is completely unimportant

3:57 Chousuke: i see what you're saying, though

3:59 Chousuke: more 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.

4:00 defn: Chousuke: you're more right than me, but that doesn't stop me from being right as well

4:00 Chousuke: I thought you just made it sounds more complicated than it is :)

4:00 sound*

4:01 defn: i always feel like my explanations are pretty stupid sounding

4:01 * defn shrug

4:02 defn: im a very visual learner though -- i learned #(fn %) before i learned how partials worked, because i thought partials seemed sort of scary at first

4:02 then i learned they're the same thing -- then i learned how fns which take multiple args work in partials

4:03 kmurph79: is #() a partial?

4:03 Chousuke: the #() syntax is one way to construct a partial but it's not so limited. also, #() always creates a new function

4:03 a new Class, I should say

4:03 a call to partial does not.

4:05 I think the most common use for #() is (map #(.javaMethod %) ...)

4:05 or filter

4:06 defn: what about remove?

4:06 Chousuke: consider map a representative of the whole class of functions :)

4:06 defn: ah nvm, you said most common

4:06 morning cgrand-rec

4:07 Chousuke: However, with clojure functions, #(foo %) is an anti-idiom because it creates a function that is pretty much equivalent to foo.

4:07 but if you need to fixate one of multiple args, #(foo % bar) or #(foo bar %) is pretty common as well

4:07 defn: fixate?

4:08 to place within the context of a function's arguments? to place in a specific argument position?

4:08 is that a fair definition?

4:08 Chousuke: I meant just "predetermine"

4:09 ie, make a "partial"

4:09 defn: ah ok

4:09 Chousuke: I guess just "fix" would have been more correct :P

4:09 defn: Chousuke: as long as I've got you in M-x teach-mode, could I ask for some help with refs, atoms, agents?

4:10 Chousuke: Sure. :P

4:10 defn: I understand (i think) how refs work, but there is a disconnect for me between real world application and what they are capable of

4:11 do you have any examples for refs, atoms, or agents in a very simple real world context?

4:11 Chousuke: Heh. They are the construct you're supposed to use to make clojure to do real-world things. :)

4:11 defn: haha -- 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?"

4:12 Chousuke: if ignoring java interop, Clojure is purely functional and without refs, you *can't* mutate anything. You can't have state.

4:12 and most interesting programs require some state

4:12 so, Clojure provides you with managed constructs for it.

4:13 defn: i've heard the term mutate, and im not sure what that means in this discussion

4:13 (sorry if this is remedial)

4:14 Chousuke: defn: Well, the reference types are really mutable. You can change them, unlike vectors or maps, which are values.

4:14 unlike traditional variables, however, the mutation semantics are well-defined

4:15 defn: so is my ref like my "int x=4;"?

4:15 and then "print x" => 4, is that sort of like dereferencing?

4:15 Chousuke: it's closer to int *x = &four; where four is immutable

4:15 defn: ah-ha!

4:17 Chousuke: of course, C pointers have no concurrency semantics for mutation, which is the point of all the different ref types in Clojure.

4:17 defn: ,(def x (ref 4))

4:17 clojurebot: DENIED

4:17 defn: :( clojurebot, be nice to me!

4:18 piccolino: Is there some easy way to take a Java Map<k,v> and turn it into a Clojure map? I must be missing something.

4:19 Chousuke: defn: 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.

4:19 across*

4:19 meh, I'm making many mistakes today :P

4:19 piccolino: I think just (into {} java-map) should work

4:20 piccolino: Aha!

4:20 Never thought to look for that.

4:20 defn: Chousuke: do you know of a good set of examples for each ref type?

4:20 Chousuke: hmm, not really.

4:20 defn: im just looking for something barebones which gets the point across

4:20 damn..

4:21 wanna write a few for me? ;)

4:21 ,(ref x)

4:21 clojurebot: java.lang.Exception: Unable to resolve symbol: x in this context

4:21 Chousuke: defn: there's this though http://github.com/technomancy/mire

4:21 defn: oh right -- i forgot about that...

4:22 zab: Anyone here successfully deployed a Compojure app to App Engine? I am about to give up. :/

4:22 defn: zab: not to app engine, sorry

4:23 Chousuke: well, 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

4:24 I think You might use an atom for eg. game state in a single-threaded game.

4:25 defn: Chousuke: 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?

4:25 Chousuke: defn: refs don't support swap! at all. :)

4:25 defn: d'oh

4:25 is swap part of the new transients stuff or am i way off?

4:26 Chousuke: nah, swap! is an atom thing

4:26 defn: ,(doc swap)

4:26 clojurebot: Pardon?

4:26 defn: ,(doc swap!)

4:26 clojurebot: "([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."

4:26 defn: that sounds kind of like reduce?

4:27 Chousuke: It's nothing like reduce :/

4:27 it just changes the value of the atom

4:27 by applying a function to its current value

4:27 there's also reset! which sets an atom to a given value

4:29 With refs you would have a (def x (ref 1)) (dosync (let [a (ensure x)] (if (= a 1) (alter x inc) (ref-set! a 2))))

4:30 that would ensure that @x is 2 at the end of the transaction

4:30 oops. ref-set! x, not a.

4:31 using ensure instead of @ is probably not necessary in this case but it shouldn't hurt either

4:33 it'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.

4:37 defn: sorry, stepped away for a second

4:37 damned telcos...

5:46 djanatyn: Umm, sorry if I already said this, but does anybody know how to install clojure on Debian?

6:06 hoeck: djanatyn: 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

6:11 djanatyn: Ah.

6:11 Thanks.

6:23 zab: I 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.

6:24 Then when I visit the locally running web server in my browser, my request times out and nailgun reports java.lang.OutOfMemoryError almost instantly.

6:30 cgrand: defn: morning :-)

6:31 zab: Oh right. I think it's because I don't know how to serve my servlet as a War file?

6:33 Hmm. Confused. This is an App Engine app. How do people develop GAE apps without recompiling everytime?

6:39 konr: What do you use to generate pdf files?

7:03 LauJensen: Clojure has been #1 on DZone this morning, currently #2 :)

7:05 zab: LauJensen: Heh, your post is also on the front page of HN

7:05 LauJensen: aah right, cool

7:13 hoeck: konr: 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

7:14 konr: or use http://www.allcolor.org/YaHPConverter, a java-based html2pdf renderer and use some html-templating language from clojure

7:16 konr: and then there are lots of other libs which let you basically write pdf source in java

7:17 StartsWithK: and batik can convert svg to pdf using apache fop

7:21 bsteuber: I 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

7:22 actually, I have built a small clojure wrapper around it for my purposes

7:24 hoeck: bsteuber: 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 :/

7:24 bsteuber: hm, then maybe it wasn't so bad I just used online resources

7:52 konr: hoeck: 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

8:16 scode: technomancy|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.

9:13 yuuki: Can *in* be rebound with dynamic scope?

9:20 StartsWithK: yuuki, yes; see with-in-str or you can do it with binding

9:21 yuuki: sweet, with-bindings is what I was looking for

9:55 * qed wonders

9:55 qed: Is there any interest in Clojure being a mentoring organization in the Google Summer of Code?

9:57 konr: it would be awesome

9:59 qed: the only thing I have to worry about is how many people want to play with clojure who beat me with their proposals

10:04 no_mind: qed, you will be surprised how many people lurk for GSoC

10:07 qed: no_mind: in here?

10:07 no_mind: qed yes, let google announce the names of organizations

10:08 qed, I had been GSoC mentor twice and and both times more than one kid has beaten my expectation

10:09 qed: no_mind: so you think there's a good chance for Clojure in the GSoC this year?

10:10 no_mind: qed, 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:10 err

10:10 I mean no restriction on the minimum number of students an organization intakes

10:11 qed: no_mind: well, I certainly hope clojure is one of the organizations. I'd kill to write Clojure for the summer.

10:12 no_mind: qed, sure. So who is going to be the admin ?

10:12 qed, also Google has changed the format for organization signup this year. They are asking more questions upfront

10:12 qed: no_mind: i have no idea -- i think it's time to post to the list

10:13 no_mind: qed, yeah and if we want to be in GSoC we have to create an ideas page before applying

10:13 qed: if everyone puts their heads together in a few threads on the list I bet we could get it done

10:14 no_mind: qed, sure

10:14 qed: no_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:14 ill do anything i can to help

10:14 no_mind: qed, you start the thread and I will follow

10:14 qed: k

10:15 no_mind: qed, firs thing we have to decide is, whether we want to accept proposals for core clojure or for clojure contribs

10:20 qed: no_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:20 no_mind: sure

10:22 qed, which mailing list you had posted to ? google group ?

10:23 pdk: are gsoc applications open yet

10:24 qed: no_mind: yes the clojure google group

10:24 pdk: mentoring organizations can apply Mar 8th => 12th

10:25 pdk: and students apply after then?

10:25 no_mind: pdk, no

10:26 pdk, once google announces the list of orgs, there will be a 2 week period for students to interact with orgs

10:26 then student applications open on march 29th

10:28 qed, I dont see the post yet

10:37 triyo: LauJensen: you there?

10:40 Your 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:56 LauJensen: trio - I'm glad you liked it - Hope the Mrs. and the little one are pleased :)

11:00 triyo: LauJensen: yup, indeed. Had to go with something different than the generic valentines gifts. On the serious note, good article. Keep it up.

11:00 qed: ditto. thanks Lau

11:04 LauJensen: np guys - great with some positive feedback, thanks

11:06 its 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:06 triyo: LauJensen: here is the result btw: https://dl.dropbox.com/u/2146210/aisha_and_alen_ascii_art.html

11:06 LauJensen: Thats great :)

11:06 triyo: LauJensen: this is fine, just don't do "x" VS "y" ;-)

11:07 then you get flamed

11:08 LauJensen: triyo, 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:08 triyo: LauJensen: the ascii pic came out nicely to on the actual print too

11:08 LauJensen: cool - Though I feel a little cheated that you didn't give her a picture of Steve Ballmer :)

11:09 (kidding)

11:09 triyo: hehehe, well if I wanted to share the shit our of my wife, it would have been my first choice

11:10 *share=scrar

11:10 e

11:10 scare

11:10 ;)

11:11 Oh btw, anyone in the mood for a "your mother is so fat" joke? CS style that is?

11:11 LauJensen: alright - 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:11 triyo: cool

11:11 http://i.imgur.com/pPw3p.jpg

12:33 technomancy: how do you check for OS X in a shell script?

12:33 triyo: one sec I have it somewhere

12:34 I think I checked darwin on uname or something..

12:34 one sec

12:34 * technomancy grumbles at having to work around OS X bugs

12:36 technomancy: anyone know what might be causing this kind of error when using Xbootclasspath on OS X? http://gist.github.com/303481

12:36 putting clojure.jar on Xbootclasspath works great on Linux, but it bails when running tests on OS X

12:36 triyo: echo $OSTYPE

12:37 technomancy: triyo: what's that value on OS X?

12:37 * technomancy doesn't have a Mac box

12:37 technomancy: which makes debugging that much more annoying

12:37 triyo: if [[ $OSTYPE == 'darwin10.0' ]]; then

12:37 :)

12:38 not 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:39 actually its better to check on uname

12:40 like so:

12:40 uname=`uname`

12:40 technomancy: yeah, so that should be "Darwin"

12:40 ?

12:40 triyo: if [[ "$uname" == 'Darwin ]]; then

12:40 always

12:40 technomancy: cool

12:40 thanks

12:40 triyo: np

12:41 then you can have your elif's for "Linux" "Cygwin", etc.

12:49 dabd: how do you refer to a Java inner class? I am trying Class$InnerClass but it is not working

12:55 chouser: dabd: that should work, but note you have to import that whole name

12:55 (import 'the.package.Class$InnerClass) ...then you can use just Class$InnerClass

12:55 dabd: chouser: I was just about to try that

14:14 rrc7cz-hm: what'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:19 hiredman: you can use find-first with tree-seq

14:20 ,(doc tree-seq)

14:20 clojurebot: "([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:20 hiredman: ,(tree-seq map? vals {:a {:b :c}})

14:20 clojurebot: ({:a {:b :c}} {:b :c} :c)

14:25 rrc7cz-hm: hiredman: thanks, I'm playing with it now. In reality I have something like [{:a {:b :c}} {:a {:b :c}} {:a {:b :c}}

14:27 hiredman: rrc7cz-hm: output from clojure.xml/parse?

14:28 rrc7cz-hm: hiredman: 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:29 hiredman: that is a very differnt kettle of fish, you want to search keys and values

14:29 rrc7cz-hm: hiredman: correct, I think I screwed up my initial question

14:30 I'm searching for the first value match of a specific key, then returning a specific sibling's value

14:30 hiredman: have you looked at clojure.zip yet?

14:31 rrc7cz-hm: I believe I used it for some xml parsing a while ago, but I'll take another look at it

14:51 raek: for storing dates (no conversions or anything calculating-ish), is it worth it to use java Dates?

14:51 ...or should I just use a map?

14:52 arohner: raek: java Dates are fine

14:52 but as soon as you start calculating or converting, use Joda

14:53 raek: I want to parse "2009-02-13T19:52:12Z" into some internal representation and be able to format it back to the same format

14:53 java uses year - 1900, right?

14:53 arohner: java uses unix time

14:56 raek: ,(str (java.util.Date 2009 02 13))

14:56 clojurebot: java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn

14:56 raek: ,(str (java.util.Date. 2009 02 13))

14:56 clojurebot: "Sat Mar 13 00:00:00 PST 3909"

14:56 raek: hmm, yeah

14:57 PST? how do I tell it that my datetime is in UTC?

15:02 arohner: raek: looks like you don't, from the java constructor

15:02 incanter has a wrapper lib around joda

15:02 it's nice

15:05 raek: that constructor has been deprecated since JDK 1.1, anyway..

15:05 arohner: raek: http://liebke.github.com/incanter/chrono-api.html

15:05 raek: arohner: ah, thanks!

15:08 arohner: is there a function that does conj, but if both items are not collections, makes a new collection?

15:10 raek: arohner: how do you mean? my intuitive interpretation of conj is "to collection X, add element Y"

15:11 with maps, though, "Y" can be a map too

15:12 maybe the source code for "->" has some interesting bits

15:12 as -> turns the arguments into lists if they aren't

15:14 arohner: right, #(if (seq? %1) (conj %1 %2) (conj [] %1 %2)) works just fine

15:15 and 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:15 Chousuke: you might want to use coll? instead of seq?

15:15 ,(seq? [])

15:15 clojurebot: false

16:40 avarus: hi!

16:40 jimt: good morning!

16:41 avarus: heh, almost :)

16:42 I'm having a problem with data types and jdbc it seems

16:43 I play around with contrib.sql and my pgsql server and I struggle with strange error messages about wrong types

16:43 first I had the problem with timestamps, now with boolean :)

16:43 when I want to update or insert a boolean type contrib.sql spits out an error or does nothing

16:43 even doesn't hit the database at all

16:43 that's really odd

16:44 I tried to do something like (boolean true) e.g. and I got one run where it worked

16:44 but the same app, still running doesn't work anymore :P

16:44 so after I googled the java guys use something like "java.sql.Types.BOOLEAN"

16:45 but how can I do it in clojure?

16:45 LauJensen: ~clojureql

16:45 clojurebot: clojureql is http://gitorious.org/clojureql

16:46 avarus: I check it out, thx

16:49 looks interesting :)

16:50 I'll try it

16:50 kevin_lm: Hi! Any enlive users out there know how if it is possible to specify an adjacent selector. i.e. [E + F]?

16:52 Leafw: I 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:52 from the interpreter.

16:53 repl

16:53 avarus: which is?

16:53 the error I mean

16:53 Leafw: (and, in any case, that other class is in a jar in the classpath anyway)

16:53 java.lang.NoClassDefFoundError: mpicbg/models/CoordinateTransform (FFT_frequency_range_to_stack.clj:56)

16:54 I never import or use that class in my code.

16:54 avarus: what libs are you using?

16:54 Leafw: our own lib: imglib.jar

16:54 the class that it "cannot find" is in the mpicbg_.jar, which has classes that also start with "mpicbg.*"

16:55 both jars in classpath. But I cna't see how it should matter

16:55 this error is total astroturf, like C going over an array limit and complaining later about something else

16:55 avarus: hehe

16:55 Leafw: not a good thing.

16:57 if anybody has seen import-related errors like this, let me know what can cure clojure of this total mishap

16:57 avarus: LauJensen: I guess selecting from my own server-stored pgsql functions just works, right? :)

16:58 Leafw: are you building the final jar or what?

16:58 Leafw: avarus: no, just running a script with load-file

16:59 avarus: and I guess the line number it tells you is utterly useless

16:59 Leafw: putting the imports under the ns declaration at the top also incurs in the same error

16:59 no, that line number is where the import was.

16:59 avarus: ook

17:00 Leafw: the import for that *other* class, which is unrelated except for having the same "mpicbg.*" start of the qualified name

17:00 LauJensen: avarus: I hope so :)

17:00 avarus: oh oh :)

17:01 Leafw: I 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:02 guille_: hi

17:02 raek: is there a simple way to filter the keys of a map?

17:02 Leafw: importing the class that "can't be found" (I never imported nor needed it) directly works.

17:03 avarus: perhaps you found a bug

17:03 Leafw: raek: (filter <pred> (keys somemap)) ?

17:03 raek: i want a function that returns a map, which keys are the union of some "allowed" keys and the actual keys

17:03 Leafw: more than a bug, this is a calamity. A total show stopper.

17:04 imports are so much unlike the rest of clojure.

17:05 guille_: raek: maybe http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/disj ?

17:05 raek: maybe (into {} (filter #(#{:a :b :c} (key %)) somemap))

17:06 I want to remove all bindings in a map, except those whose keys are in a set

17:06 chouser: ,(select-keys {:a 1, :b 2, :c 3} [:a :b])

17:06 clojurebot: {:b 2, :a 1}

17:07 raek: chouser: perfect! thanks...

17:13 avarus: LauJensen: so I installed gradle and clojuresque and cloned the clojureql repository, now what? :) the readme.markdown says something aboyt ivy a, not gradle

17:13 -a

17:14 same as in clojuresque? gradle build?

17:14 I'll try

17:14 na, that fails, mhh...reading again, I must have missed something

17:15 LauJensen: avarus: http://www.bestinclass.dk/index.php/2009/12/clojureql-where-are-we-going/

17:15 There's a section on building

17:17 avarus: ya, "Building the thing"

17:19 "Gradle will handle that automatically once you build ClojureQL." but then there is already "In closing" :)

17:19 or perhaps I misunderstood the part that gradle needs the jar clojuresque jar :)

17:20 ya, ok, "gradle build" is all I need regarding tghe mailinglist

17:23 but it fails with this: http://pastie.org/823735

17:24 settings.gradle only contains "rootProject.name = clojureql"

17:25 LauJensen: Did you see both ENV vars correctly ?

17:25 avarus: http://pastie.org/823736 <-- verbose

17:25 yes, I do

17:25 bin of gradle is in the path and GRADLE_HOME shows the home dir of gradle

17:26 LauJensen: If 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:26 No need to install clojuresque since the build script declares it as a dependency

17:26 avarus: ya, too late :) I followed your instructions and then read it's not needed :P

17:26 LauJensen: Sorry - I will practice blogging more

17:27 avarus: but that's not the problem here, I think

17:30 org.gradle.api.GradleScriptException: Settings file '/Users/andreas/clojure/clojureql/settings.gradle' line: 1

17:30 it sounds quite obvious to me but I don't know what's being expected there in line 1

17:31 LauJensen: Did you clone the main repo ?

17:32 avarus: git clone git://gitorious.org/clojureql/clojureql.git <-- is that the main repo?

17:32 LauJensen: yes

17:32 http://gitorious.org/clojureql/clojureql/blobs/master/settings.gradle

17:32 avarus: same content as here :)

17:33 LauJensen: ok- please delete that file locally, try again

17:34 avarus: did it! :)

17:35 r0man: ,(= #"" #"")

17:35 clojurebot: false

17:35 r0man: , (= (str #"") (str #""))

17:35 clojurebot: true

17:35 r0man: hello #clojure, i'm wondering about regex equality. why is this? because of java interop?

17:37 ,[(= #"" #"") (= (str #"") (str #""))]

17:37 clojurebot: [false true]

17:37 LauJensen: I apologize for the trouble

17:38 avarus: lol! 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:39 LauJensen: I strongly recommend not dreaming about money

17:39 avarus: ok, I'll earn it :)

17:54 raek: is 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:55 if I had made it, I'd call it map-val

17:56 hmm, clojure.contrib.datalog.util/map-values

17:57 LauJensen: (map f (vals m))

18:06 raek: well, I want the result to be a map too...

18:06 here's my solution:

18:06 (defn map-vals [f m] (into (empty m) (for [[k v] m] [k (f v)])))

18:24 JonSmith: If i'm using fleetdb, can I just run it in my existing clojure image instead of using the client library?

18:26 arohner: JonSmith: I don't know, but I'd be surprised if you can't

18:33 JonSmith: okay

18:33 well i will try and see

19:55 jwhitlark: so, 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:55 gstratton: (and (byte 0xff)

19:56 raek: jwhitlark: I think you got it

19:56 _ato: java byets are signed

19:56 jwhitlark: (and (byte 0xff))

19:56 oops.

19:56 raek: ,(and (byte 0xff))

19:56 clojurebot: -1

19:56 raek: (and (byte 0xff) (byte 0xab))

19:56 ,(and (byte 0xff) (byte 0xab))

19:56 clojurebot: -85

19:57 _ato: -1 = 11111111 in two's complement

19:57 http://en.wikipedia.org/wiki/Two%27s_complement

19:57 ,Byte/MAX_VALUE

19:57 clojurebot: 127

19:58 raek: java doesn't have any unsigned values at all, right?

19:58 jwhitlark: ok. 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:59 raek: ,(format "%x" (byte 0xff))

19:59 clojurebot: "ff"

19:59 _ato: that should work

20:00 jwhitlark: _ato: the code I have should work?

20:00 I must be doing something else wrong.

20:00 _ato: yes, signed -1 = unsigned 255, so the network card will interpret it has 0xff

20:01 I'd use a packet sniffer and compare what your code is sending to some other implementation and see if there's a difference

20:01 raek: (byte-array 6 (repeat 6 (byte 0xFF)))

20:03 does the array from into-array get its size from the seq?

20:03 jwhitlark: I thought so.

20:04 _ato: ,(count (into-array Integer/TYPE [1, 2, 3]))

20:04 clojurebot: 3

20:04 jwhitlark: I'm passing the length in later, so as long as the data is there, (and I checked with aget), it should work...)

20:04 avarus: has anyone ever experimented a bit with contrib.sql and pgsql? :(

20:04 raek: ah, ok. nevermind... :)

20:04 jwhitlark: I'll try wireshark

20:09 avarus: I'm having a problem updating simple data by id which is a number

20:09 I get an exception because pgsql fired an error due to type mismatch

20:10 or I get no exception but nothing has changed

20:10 no data being affected

20:10 contrib.sql is not hitting the db then

20:13 tolstoy: There's no official clojure 1.1 jars at clojars for leiningen to grab?

20:16 _ato: it's here http://build.clojure.org/releases/

20:16 build.clojure.org/snapshots is in lein's default repo list but not releases

20:16 guess I should mirror them on clojars too

20:16 hmm

20:17 danlarkin: build.clojure.org is stable

20:17 tolstoy: lein has a default project file it builds.

20:17 I've not problem finding clojure and clojure contrib.

20:17 Was just curious to have lein find them as part of its deps.

20:18 The default project file has 1.1.0-alpha-SNAPSHOT for clojure, and "1.0-SNAPSHOT" for contrib.

20:20 * _ato considers url.redirect = ( "^/repo/org/clojure/(.*)" => "http://build.clojure.org/releases/org/clojure/$1" )

20:20 tolstoy: That would be cool! ;)

20:21 I'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 _ato: ok done. give [org.clojure/clojure "1.1.0"] a try

20:25 tolstoy: Ah! Will, do.

20:25 Is there any more documentation on lein than the github readme?

20:26 _ato: That works well. Thanks!

20:26 _ato: not official documentation, there's a couple of random tutorials, just google: leingingen tutorial

20:26 tolstoy: Okay. Yeah, for instance, how do you make your uberjar know where the main class is? Stuff like that.

20:27 ah, lein help jar gives me the details. phew!

20:27 _ato: yep, and the README does mention briefly: :main - specify a namespace to use as main for an executable jar

20:27 tolstoy: Gotcha.

20:42 jwhitlark: ah. I got it. I was parsing the mac address wrong.

20:42 (map #(byte (Integer/parseInt % 16)) (re-split #"\:" mac)) works properly.

20:42 thanks for the help.

20:48 tolstoy: Hm. I want a "lein swank". ;) And a "lein run".

20:49 _ato: http://github.com/technomancy/leiningen/tree/master/lein-swank

20:50 http://github.com/ericlavigne/leiningen-run

20:51 tolstoy: Nice!

21:00 Hm. leiningen run requires all those jars?

21:03 _ato: odd, looks like it pulls in maven-ant-tasks by mistake

21:04 tolstoy: That's a mistake? I was just looking at that project.clj

21:04 _ato: well it doesn't seem to use it

21:05 tolstoy: Maybe the "exclude" thing will help?

21:06 Hm. That didn't work.

21:06 _ato: could 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 guess I should turn that into a shell alias or script to save typing it out all the time

21:07 tolstoy: Yeah, I'm okay with that sort of thing to. Nice custom "run" and "swank" scripts.

21:07 seths: lein run is awesome

21:08 at least it makes me happy :-)

21:08 tolstoy: seths: Yeah, but it seems to require 23 jars.

21:08 lein exclusions work only for dependencies, not dev-dependencies, it seems.

21:14 looks like exclusions don't work at all. maybe the readme is wrong, or that's not in the stable version

21:15 seths: tolstoy: as long as you lein clean before uberjar, it's not an ongoing annoyance

21:15 tolstoy: I spose.

21:15 seths: not ideal mind you

21:15 I'd love it to be part of lein

21:15 (just a happy user of both)

21:17 tolstoy: I don't understand why lein-run requires maven-ant-tasks.

21:19 For instance, if I delete all those extra dependencies, lein run still works.

21:20 seths: heh

21:23 tolstoy: lein-swank includes them too!

21:23 seths: another plugin I'd like to see in core

21:24 lein 1.1 should be coming out soon I think. After that might be a good time to fork & issue pull requests on github

21:24 I'm trying to figure out why putting clojure.jar in -Xbootclasspath:/a causes lein test to get all grumpy

21:24 tolstoy: Hm.

21:25 seths: not on Linux, only on Mac so far

21:25 tolstoy: Each of them (swank and run) seem to require maven because they don't really run in the same context as leiningen.

21:27 All this would be okay of :exclusions worked.

21:27 avarus: no! it was a fucking simple typecast!

21:27 seths: rofl

21:27 IRC is great at random times

21:28 avarus: can't believe it was so simple

21:30 now, god, please rewind the last 6 hours of my live, please!

21:30 life :>

21:30 narf

21:39 JonSmith: ,0xFF

21:39 clojurebot: 255

21:41 tolstoy: Ah hah. Leiningen stable doesn't have the exclusion stuff.

21:50 avarus: guys...I have to sleep! :P

21:50 good night

22:03 JonSmith: is there a good filesystem ultilities library yet

22:03 ?

22:03 like

22:03 files in a directory, navigate up and down etc.

22:16 mattrepl: tolstoy: get :exclusions issues worked out?

22:17 tolstoy: Yep.

22:17 Turns out the "stable" version didn't have that feature.

22:26 Drakeson: In 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:28 tolstoy: Drakeson: You don't just use the fully qualified name?

22:30 Drakeson: sometimes it is a bit cumbersome

22:30 tolstoy: Indeed.

22:30 Drakeson: especially when you want to move/rename things around

22:31 tolstoy: I 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:31 Yeah.

22:31 _ato: yeah there's no relative imports

22:31 tolstoy: In 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:31 Thus, Eclipse and the like.

22:35 Can you splice arrays outside of a macro? `@list, or something like that?

22:37 _ato: ,(let [stuff [1 2 3]] `["hi" ~@stuff "there"])

22:37 clojurebot: ["hi" 1 2 3 "there"]

23:01 JonSmith: hm

23:01 i bet you could write an uber-ns macro that uses a heriarchy for require and use

23:20 piccolino: Does proxy invoke the compiler every time it's called?

23:24 _ato: no, 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:26 piccolino: OK, cool, thanks _ato.

23:29 _ato: ,(class (proxy [Thread] []))

23:29 clojurebot: java.lang.IllegalStateException: Var null/null is unbound.

23:30 _ato: ,Thread

23:30 clojurebot: java.lang.Thread

23:30 _ato: guess clojurebot disallows it

23:30 but it evals to: clojure.proxy.java.lang.Thread

23:30 which is that one class that all proxies of Thread will be instances of

23:30 piccolino: Yeah, I just tried it in the repl.

23:34 And there's no way to give a proxy object a member variable?

23:38 tolstoy: piccolino: The methods you override are full closures, so you could make use of that, maybe.

23:39 (let [instance-var (init)] (proxy ....... (some-fun [] (use instance-var) ....)) etc, etc.

23:39 Poor man's subclass?

23:40 piccolino: Hm, OK, thanks.

23:41 tolstoy: piccolino: All I know is that if you proxy a class that calls an abstract method in its constructor, you're screwed.

23:41 piccolino: Heh, don't need that fortunately.

23:42 tolstoy: Yeah. 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.

Logging service provided by n01se.net