#clojure log - Aug 20 2010

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

0:00 patrickdlogan: yeah, it doesn't complain to add the metadata to Foo but a java Class does not retain metadata.

0:02 spewn: I suppose that makes sense. Thanks.

0:11 Shame that I can't carry over the docstrings from my defstructs though.

0:41 technomancy: Leiningen 1.3.0: http://tinyurl.com/2duzupg

0:41 I was thinking I'd be releasing Lein 1.2.0 on the same day as Clojure 1.2.0, but alas; didn't work out like that. =)

0:56 bortreb: what's the idiomatic way to filter a map by it's keys xor values, and return the whole map?

0:56 wwmorgan: bortreb: example input and output?

0:57 bmh: while where on the subject: is there a library function that will do [(filter f n) (remove f n)] in a single pass over n?

0:58 bortreb: (keys-filter even? {2 "two" 3 "three"}) would return {2 "two"}.

0:58 (vals-filter even? {"two" 2 "three" 3}) would return {"two" 2}

0:59 fight now I'm using zip-map akwardly but I was wondering if there was a better way?

1:04 because, filter returns a lazy sequence....

1:05 dnolen_: technomancy: nice! I guess you can no longer start a REPL w/o a project.clj. Also lein repl puts you in clojure.core, shouldn't it put you in user ?

1:07 wwmorgan: bortreb: here are two filter-keys implementations. I don't know if they're better- or worse-looking than what you have already :-p http://paste.lisp.org/display/113690

1:13 bortreb: wwmorgan: thanks for your help! of the two methods, the one that does not use threading seems to be slightly faster

1:14 although, I figured there was some mega-hash-map library somewhere that already had this which I had overlooked

1:21 wwmorgan: how about this one? http://paste.lisp.org/display/113690#1

1:23 wwmorgan: bortreb: that looks pretty optimal to me

1:27 bortreb: and I guess filter-vals looks prettiest as (defn filter-vals [fun m] (into {} (filter (comp fun last) m))) ? or can it be even prettier?

1:28 wwmorgan: I'd use val instead of last to make it clearer

1:28 bortreb: wwmorgan: ooohhh that's a good one!

1:46 LauJensen: Good morning all

1:46 itistoday: LauJensen: Morning! and actually, good-night! I was just heading to sleep. :-)

1:47 LauJensen: ,UGT

1:47 clojurebot: java.lang.Exception: Unable to resolve symbol: UGT in this context

1:47 LauJensen: clojurebot: UGT

1:47 clojurebot: ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html

1:47 LauJensen: itistoday: sleep tight :)

1:47 itistoday: :-)

1:48 Raynes: Morning.

1:48 LauJensen: Raynes: pulling an all-nighter?

1:48 Raynes: LauJensen: I just woke up.

1:53 LauJensen: What time have you got ?

1:53 @ Raynes

1:54 Raynes: $time -5

1:54 sexpbot: Raynes: The time is now 2010-08-20T01:02:42Z

1:54 LauJensen: Nice

2:09 slyrus: technomancy: lein 1.2 or 1.3?

2:09 rdsr: I just noticed that there can be duplicate keys in literal maps

2:10 hiredman: ,{:a 1 :a 2}

2:10 clojurebot: Duplicate key: :a

2:11 rdsr: hiredman, which version of clojure u are using?

2:12 hiredman: ,*clojure-version*

2:12 clojurebot: {:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"}

2:14 rdsr: thks

2:15 hiredman: http://github.com/hiredman/Arkham/commit/f2dd23f554a676d2797da45929873a6a43068c73#L0L228 mmm

4:11 lenw: Hi

4:11 is the following code safe : http://gist.github.com/539866

4:12 or would the stack build up

4:12 ?

4:17 AWizzArd: lenw: no stack problem

4:18 lenw: AWizzArd: is that cause i am not passing anything through the recur ?

4:18 AWizzArd: just curious :)

4:19 Bjering: Can I use java objects as keys in clojure maps? What are the rules if I do?

4:19 LauJensen: lenw: yes. For the stack to blow you need to build the memory beyond what it can take

4:20 ,{(make-array Integer/TYPE 5) "hi"}

4:20 clojurebot: {#<int[] [I@5f45f1> "hi"}

4:22 LauJensen: Bjering: That means yes

4:24 zmila: ,(clojure-version)

4:24 clojurebot: "1.2.0-master-SNAPSHOT"

4:24 spariev: Bjering: re rules - from clojure.org/data_structures - Hash maps require keys that correctly support hashCode and equals

4:25 LauJensen: spariev: And I think also a 3.rd interface in the next release of Clojure, Rich mentioned that in here a couple of weeks ago

4:25 MapEqual or some such

4:27 Bjering: LauJensen and spariev, thank you. What if the java object changes values (and thus changes hash-code/equals) ?

4:28 AWizzArd: lenw: loop/recur is the plain old goto. There is no stack that can blow up.

4:29 Bjering: Well, my use-case is netty-channels as keys, they are not value-objects, they dont overload hashCode/equals, they are like the integer arrays LauJensen showed me works, id is their memory reference and isnt changing, seems it should be ok.

4:30 lenw: AWizzArd: that makes sense - and the "references" are rebound each time through

4:30 AWizzArd: yes

4:30 lenw: thanks

4:33 spariev: Bjering: I think it will be ok, as long as keys' hashcodes won't change

4:36 LauJensen: interesting, I didn't know that. Do you have any links on this ? haven't managed to find anything relevant in irc logs ...

4:36 LauJensen: spariev: I'll grep my log, gimme 10 secs

4:37 Raynes: lenw: Also, you don't even need the loop there at all. Just plain ol' recur ought to do it.

4:38 And I'm pretty sure you can't name something '1' ;)

4:38 -> (def 1)

4:38 sexpbot: java.lang.Exception: First argument to def must be a Symbol

4:39 LauJensen: About 20:53 CET, August 4 2010

4:39 <rhickey> got homemade IPersistentMaps? please try latest rev on github. Fixing

4:39 record equiality meant introducing a MapEquivalence marker class - you must

4:39 implement in order to be = to maps (APersistentMap does this)

4:39

4:40 spariev: LauJensen: big thanks

4:40 lenw: Raynes: updated the gist - like that ?

4:40 LauJensen: np

4:41 Raynes: lenw: Yep. But like I said, you can't name it '1'.

4:42 And, purely a style critique, you might consider setting tab width to 2 spaces.

4:42 It's usually two unless lining up function arguments.

4:42 s/function arguments/arguments/

4:43 sexpbot: It's usually two unless lining up arguments.

4:43 LauJensen: Raynes: As far as I know, most people go with 4

4:44 Raynes: LauJensen: Since when? ._.

4:44 LauJensen: Since last time I googled it :)

4:44 I grabbed it from a larger tabs/spaces discussion in an Emacs forum

4:44 Raynes: LauJensen: clojure-mode indents two. Everything I've ever heard was "two" for Lisp.

4:45 LauJensen: Really? Interesting

4:45 * Raynes consults core.clj

4:46 Raynes: Yup, that would be two.

4:48 LauJensen: Odd - My code does it as well, and Ive been staring a Clojure code for 3 years now and also remembered the number as '4' despite that fact thats its obviously 2 :)

4:48 (set! *memory-of-indentation* 2)

4:49 Raynes: :p

4:51 Oh cool. Clojure can destructure based on index now.

4:51 LauJensen: link?

4:51 clojurebot: your link is dead

4:52 Raynes: -> (let [{first-thing 0, last-thing 3} '[a b c d]] [first-thing last-thing])

4:52 sexpbot: => [a d]

4:52 Raynes: LauJensen: http://fogus.me/static/preso/clj1.2+/ Slide 9

4:52 LauJensen: nice

4:54 Raynes: A new clojure.java.browse namespace.

4:54 I've been totally kept out of the loop.

4:54 I'm pissed. ;)

4:55 LauJensen: btw Raynes, there was a murder in your state the other day, did you hear about that, some 18 year old kid got shot in his own home?

4:55 Raynes: LauJensen: There are plenty of murders.

4:55 LauJensen: oh

4:55 I assumed there wasn't, since I actually heard about that one

4:55 Raynes: Go visit Detroit Michigan. ._.

4:58 LauJensen: Raynes: Michael Moore said that the US has 11.500 yearly homocides, vs 350 in Canada

4:58 Raynes: Indeed.

5:01 spariev: you guys scare me. My gf have to visit Chicago in a couple of months

5:02 Raynes: spariev: Teach her to handle a .40.

5:02 LauJensen: spariev: Sorry

5:03 spariev: nevermind

5:04 Raynes: it's illegal to have firearm in Russia

5:04 you can only buy gas pistols etc

5:05 but we went way offtopic :)

5:43 Ankou: hi, is there a reason why http://clojure.org/downloads doesn't list clojure 1.1 under older releases anymore?

5:56 LauJensen: Ankou: I remember rhickey talking about wanting to see some downloads stats, which he could only do if the download was available from google code - I dont know if thats relevant to your question, but I haven't heard anything else

6:28 __debaser: hey, what is the best way to start a Clojure Repl with contrib and jline?

6:29 lein repl works but you have to create a project in order to use it

6:29 LauJensen: java -cp clojure.jar:jline.jar clojure.main ?

6:30 __debaser: that does not include Clojure-contrib

6:31 LauJensen: java -cp clojure.jar:jline.jar:contrib.jar clojure.main ?

6:31 Sorry, its fixed now :)

6:32 __debaser: but personally what I do if Im just experiment, I hit M-x slime in Emacs, and that sets up a repl with contrib, penumbra, citerion and a host of other libs that I play with somewhat frequently

6:35 __debaser: LauJensen: strange, your version works just fine

6:35 tried the same yesterday and it didnt

6:35 so thanks a lot

6:36 LauJensen: np

6:41 __debaser: I am just getting accustomed to Vim, so switsching to emacs is not an option

6:42 and while the Clojure plugin for Vim is ver nice I find the repl in vim hard to use

6:44 LauJensen: __debaser: VimClojure?

6:45 __debaser: yes

6:45 LauJensen: You could talk to kotarak, the author, about it. He hangs out in here most nights (CET)

6:53 __debaser: nah, he did a good job on it, it's just not how I like to run it

6:53 LauJensen: ok

6:53 __debaser: java -cp ./clojure-1.2.0/clojure.jar:./jline-0.9.94/jline-0.9.94.jar:./clojure-contrib-1.2.0/target/clojure-contrib-1.2.0.jar jline.ConsoleRunner clojure.main works fine for me

6:54 LauJensen: __debaser: Thats crazy man, but different strokes for different folk I suppose

6:55 __debaser: hm, maybe i'll try it again, I never could figure out if I wanted to run the whole script or just the current line

6:56 LauJensen: Im just thinking, in Emacs you get tab completion, fuzzy completion, autodoc, code look up, object inspection, etc etc. With JLine you get zero. You're giving up 90% productivity to hang on to a fading editor. It just seems crazy to me

6:57 ordnungswidrig: you can user viper with emacs

7:01 Chousuke: You can, but it doesn't really work.

7:01 __debaser: well I disagree that Vim is inferior to Emacs and it is definitely not fading but I understand that Clojure support is better

7:03 Chousuke: __debaser: Don't take LauJensen too seriously when he says things like that. He has a tendency to say flamebaitish things :P

7:04 psykotic: on this point, though, he happens to be 100% right. :)

7:04 LauJensen: It wasn't a flamebait - I just felt bad for the guy sitting in a shell working with JLine, he's bound to have a tough time getting started

7:05 kensho: Hi. I'm looking for javadoc of the clojure API (on the java side, e.g. seqable interface etc.) but I can't find it?

7:05 Chousuke: kensho: It doesn't exist :Ö

7:05 :P even

7:05 kensho: oh :(

7:05 are there plans to make it available?

7:06 Chousuke: probably not, as many of the interfaces are going to be replaced eventually anyway

7:06 kensho: I see

7:06 Are there any examples where I can see how to implement them then? :)

7:07 Chousuke: in general though, if you need to implement the interfaces you should first see if you can extend any of the abstract base classes instead.

7:07 some of the interfaces (like IFn) are in fact generated code and implementing them fully manually is rather painful

7:08 so if you need to create a Clojure function from java, you should extend AFn instead

7:09 At least, as far as I know. I haven't had to worry about the Java side of Clojure much.

7:09 kensho: I see. Well I would like to make a w3c dom NodeList seqable, maybe something like that already exists?

7:09 it's a pain to work with in clojure otherwise

7:10 Chousuke: kensho: I think for now the easiest approach is to just make a function that returns a lazy seq made from the NodeList

7:11 not directly seqable but good enough most of the time.

7:11 kensho: Oh ok. I will try that then. Thanks

7:11 Chousuke: Of course you can go and look at ISeq and whatever other interfaces there are, but you'll pretty much need to figure them out the hard way :P

7:11 cemerick: there's plenty of precedent, especially if NodeList is mutable, e.g. enumeration-seq and iterator-seq

7:12 kensho: ^

7:13 kensho: Yeah well, maybe if performance is unacceptable I will look into it, I'll try the easy way for now :) thanks again

7:17 LauJensen: kensho: Dending on what you're doing with the w3m lib, you might want to check out Enlive

7:17 AWizzArd: this is a classic, but I enjoy to see this language comparison each and every time *lol* http://i.imgur.com/1gF1j.jpg

7:23 LauJensen: What the way to do a cross table filter select in mysql? "select * from x where y is not in (select * from z)"? basically, all items from x where some field isnt equal to a value from a field in z ?

7:24 bobo_: dont think your allowed to do that?

7:25 you have to specify column in z

7:26 LauJensen: bobo_: which is fine

7:26 bobo_: so select * from x where y not in (select w from z)

7:26 LauJensen: Yea Im quite sure Ive seen it done/done it before

7:26 bobo_: i do way to much sql

7:26 LauJensen: yea something like that

7:29 nice, that actually worked just as you would expect

7:32 metagov: That notice about clonebots makes me think of replicants from Blade Runner. I wonder if they can even test for the Nexus 6 clonebots...

7:32 LauJensen: metagov: they just inspect the meta data, its all there

7:37 metagov: LauJensen: Well, so long as clonebots still have a 4 year life span, I guess I won't worry too much ;-)

9:07 adityo: nipra

9:09 don333: Raynes: *clojure-version* gives "java.lang.SecurityException: Code did not pass sandbox guidelines", could you perhaps whitelist it?

9:10 I meant on try-clojure.org of course :)

9:10 Raynes: don333: Indeed. (clojure-version) might work though.

9:10 don333: I'll do that in a little while. I need to update it to 1.2 and stuff anyway.

9:11 * don333 feels dumb

9:12 don333: should have checked the fn before whining...

9:12 (clojure-version) works fine

9:12 Raynes: *clojure-version* should be whitelisted anyway. :p

9:13 So I very much appreciate your whining. :>

9:13 LauJensen: hehe

9:13 don333: heh

9:13 good luck on 1.2 update then

9:16 fbru02: hey guys i have a question , before protocols when you wanted to emulate objects , there was only hashes right ?

9:17 chouser: or gen-class, but yeah hashes+metadata+(perhaps)multimethods

9:24 fbru02: chouser: thanks !!

9:25 chouser: oh, so people like defstruct but those are really just somewhat optomized hashes

9:25 AWizzArd: Although Clojure 1.2 is now officially here, I must admit that I will be happily using what will be 1.3 one day (:

9:26 LauJensen: Statics?

9:27 AWizzArd: LauJensen: you mean me?

9:27 fbru02: AWizzArd: is there a roadmap for 1.3?

9:27 LauJensen: yea

9:27 AWizzArd: LauJensen: for example! Maybe also Pods.

9:27 LauJensen: AWizzArd: How much info do you have on Pods ?

9:27 AWizzArd: And I am looking forward to marker interfaces for Records.

9:27 LauJensen: mostly all info: Cells were renamed to Pods.

9:28 I am probably the only user of Cells :)

9:28 LauJensen: k

9:28 What do you use them for ?

9:28 AWizzArd: LauJensen: for Transactions in my DB system

9:28 LauJensen: really, got that public somewhere?

9:28 AWizzArd: Unfortunately I still can only say "soon".

9:29 But it will be available in source.

9:29 And really soon I wish :)

9:29 Currently I am at lightweight and efficient serialization/deserialization. And for that a marker interface for records would be great.

9:30 LauJensen: AWizzArd: Which limitations in Clojure drove you to Cells?

9:31 AWizzArd: LauJensen: not in Clojure, but in refs and agents. I won't call them limitations however. The challenge is to atomically update a collection multiple times *and* writing data to disk *within* the transaction.

9:31 refs can't do that for the side effect "writing to disk" part.

9:32 LauJensen: so you wrote a ref which hands respins somehow?

9:32 AWizzArd: instead of a ref I used a cell.

9:32 Now I can update it in the (with-cells [] ...) block, which is equivalent to dosync.

9:32 And still in the with-cells block I do IO.

9:32 This would not be allowed in refs.

9:33 And agents would run in a different thread - it is awkward to learn about errors in transactions.

9:33 I would have to pass in a promise into the agent and deref it outside.

9:34 LauJensen: Hmm, that sounds like a super subject for a blogpost

9:35 AWizzArd: Those posts will all come.

9:35 Until now Cells were highly alpha.

9:35 rhickey made a basic implementation and then concentrated on 1.2. But now he renamed them to Pods and will maybe change some aspects of them - we'll see.

9:37 LauJensen: Very interesting

9:37 What are your expectations for marker interfaces?

9:37 AWizzArd: This is https://www.assembla.com/spaces/clojure/tickets/394-add-marker-interfaces-for-defrecords-and-deftypes-plus-boolean-test-fns

9:38 For any Object x I want to be able to ask (record? x)

9:38 LauJensen: As yes I remember now

9:38 I think that has a pretty good chance of being implemented quite quickly

9:38 AWizzArd: Those can be serialized with a better strategy than unknown objects in general.

9:39 LauJensen: yes, in principle I could imagine that this is more or less an empty interface plus 2-3 LOC in defrecord / deftype

9:40 Btw, does the JVM support something such as "private interfaces"?

9:40 So that nobody could implement clojure.lang.Record in her classes, but only defrecord itself can do this?

9:41 LauJensen: It supports private interfaces if nested

9:41 AWizzArd: sounds good, thx

9:45 Anyone of the Maven experts here: does Maven support incremental builds? I have 30 .clj files in my build, and the produced .jar looks fine with the exception of small warts coming from 2 files. I change 5 LOS in two files. Do I now need to compile all 30 NS again or can it be done this time within a second (+ time for creating the .jar), cause only those two files will be recompiled?

9:46 LauJensen: AWizzArd: Im not sure cemerick or stuartsierra highlight on 'Maven expert' yet :)

9:47 spariev: AFAIK maven can sure do so with java files

9:47 cemerick: AWizzArd: That's a function of one's compiler, not the build tool.

9:47 in any case, for both java and clojure, if you don't clean first, running mvn compile and/or jar will only compile the files that have changed.

9:48 Or, more precisely, will only compile the files whose moddate is later than the corresponding classfile(s).

9:48 rrc7cz: my Monte Carlo calc of Pi isn't working too well (keeps returning ~3.6...) and I'm hoping somebody could help me spot the error: http://gist.github.com/540352

9:49 AWizzArd: cemerick: okay good, so this is implicitly present

9:49 cemerick: I thought the build tool is doing that job of checking the timestamps. Thanks for that update.

9:50 LauJensen: though those two may be some of the most experienced maven gurus in here (:

9:50 cemerick: AWizzArd: Neither ant nor maven handle that. I think make did? Totally not sure on that.

9:50 AWizzArd: k

9:51 cemerick: LauJensen: as long as you're johnny-on-the-spot with the mvn bat-signal, then I think myself or SS will be highlighted just fine ;-)

9:52 LauJensen: Yea I know - I usually go to people directly if I know somebody is likely to have the answer

10:07 slyrus: let's see if the old "go to sleep with a tricky problem and wake up and see the obvious easy solution" trick works again

10:07 Raynes: It works every time,.

10:07 time.*

10:12 LauJensen: That and a rubber plant

10:24 Scala_: Does clojure have any of those "get started" type packages that has a cli and an interpreter and everything you need to get going

10:24 nachtalp: rrc7cz: try (float (* 4 (/ in (+ in out)))) instead of (float (/ in out))

10:25 cemerick: Scala_: java -jar clojure.jar will get you a quick-n-dirty REPL.

10:25 Scala_: Note that clojure never interprets anything though -- everything is compiled.

10:26 rrc7cz: nachtalp: that did it

10:26 nachtalp: thank you. I understand the * 4 since I am only sampling a single quadrant

10:27 nachtalp: rrc7cz: see here: http://math.fullerton.edu/mathews/n2003/MonteCarloPiMod.html

10:28 slyrus: ,(apply hash-map (map identity {1 2 3 4}))

10:28 clojurebot: {[1 2] [3 4]}

10:28 slyrus: how do I map over a map and get back a map?

10:28 cemerick: chouser: don't let the power go to your head, 'kay? ;-)

10:28 dnolen_: Scala_: cljr, cake are nice if you want a decent REPL. I prefer cake for REPL'ing. Note that Clojure has no interpreter. The REPL compiles on the fly.

10:29 LauJensen: slyrus: Usually reduce is a better fit

10:29 Raynes: dnolen: I like how cake does multi-line stuff.

10:29 rrc7cz: nachtalp: that explains it, thanks

10:30 slyrus: LauJensen: yeah, I guess so...

10:30 LauJensen: ,(reduce (fn [a [k v]] (assoc a k (inc v))) {} {:a 1 :b 2 :c 3})

10:30 clojurebot: {:c 4, :b 3, :a 2}

10:30 LauJensen: replace inc with what you would have mapped for instance

10:31 slyrus: thanks

10:31 or the trivial example I was looking for:

10:31 (reduce conj {} {1 2 3 4})

10:31 ,(reduce conj {} {1 2 3 4})

10:31 clojurebot: {3 4, 1 2}

10:32 slyrus: I find myself wanting to conj map-entries into a map, instead of assoc'ing k/v pairs into a map. that's probably a mistake on my part.

10:33 LauJensen: Why do you want that?

10:33 slyrus: it's not that I particularly want that, it's just two ways of thinking about doing the same thing

10:34 and I'm thinking of the way that's a bit ... unnatural for clojure it seems

10:34 probably more CL-isms where cons is generally a lot easier to work with than make-hash-table, get-hash, etc...

10:35 and most things in clojure seem to work as I expect them to. except of course when they don't, like my repeated unwarranted expectation that #[...] will be #(vector ...)

10:36 LauJensen: hehe

10:37 chouser: slyrus: also be aware of zipmap

10:37 arkh: LauJensen, could you provide a translation to a quote in JoC? : "Wer nicht von dreitausend Jahren. Sich wei Rechenschaft zu geben, bleib im

10:37 Dunkeln unerfahren, mag von Tag zu Tag leben."

10:38 chouser: ,(into {} {1 2 3 4})

10:38 clojurebot: {1 2, 3 4}

10:38 chouser: ^^ more efficient than reduce

10:38 LauJensen: arkh: Sorry no, try AWizzArd :)

10:38 nachtalp: rrc7cz: np :)

10:38 slyrus: chouser: I want the three-arg function that takes a fn to call on the map entry before putting it in the map :)

10:38 arkh: k

10:39 chouser: slyrus: the whole entry? or each value?

10:39 arkh: AWizzArd: did you catch that?

10:39 slyrus: chouser: [k v]

10:39 chouser: (into {} (map f m))

10:39 slyrus: but, all of this is much nicer than (loop for x being the hash-keys of ...)

10:39 :)

10:39 LauJensen: arkh: according to Google

10:39 "Who does not of three thousand years. To give further accountability, stay in

10:39 Dark inexperienced, may live from day to day"

10:40 slyrus: or whatever the CL syntax for that is

10:40 Chousuke: slyrus: the CL loop macro is scary :P

10:40 LauJensen: arkh: And that matches how I read it (as a dane)

10:40 chouser: cemerick: the #clojure power?

10:40 cemerick: indeed

10:40 1. Gain op in #clojure.

10:40 2. ???

10:40 3. Profit!

10:40 nachtalp: arkh: that's a strange sentence...

10:41 LauJensen: nachtalp: probably something chouser wrote, americans love to show off their 'german' :)

10:41 Chousuke: I bet you could (loop through ideas in my head and select the best option)

10:41 chouser: cemerick: ??? = fees to /join

10:41 arkh: LauJensen: I tried that too but was hoping for a better translation. Maybe there really isn't one

10:41 LauJensen: I think its quite accurate

10:41 cemerick: chouser: too draconian. Fees to get voice. Let the lurkers lurk. It's called "freemium"!

10:41 chouser: ha!

10:41 arkh: nachtalp: page 278, JoC, author Johann Wolfgang von Goethe

10:42 LauJensen: sorry to confuse your dutch vs. german background, btw!

10:42 LauJensen: arkh: Dont be - You should be more sorry about confusing my Danish background with a dutch one

10:43 mfex: I too failed to understand the german quote in joc

10:43 Chousuke: :P

10:43 nachtalp: arkh: ok, goethe, that explains why it sounds strange ;)

10:43 arkh: LauJensen: ... speaking to your language(s) background vs. your nationality :)

10:43 LauJensen: ... makes no difference :)

10:44 arkh: LauJensen: oh :(

10:45 LauJensen: can I claim typical american ignorance for foreign issues? :)

10:45 LauJensen: Sure

10:45 arkh: LauJensen: in all seriousness, I still with 'Danish'

10:45 s/still/stick

10:46 LauJensen: Danes are Danish and they speak Danish, People from Holland/Netherlands speak Dutch

10:46 And you guys owe us a lot of money. I think thats all you need to know about Europe

10:46 arkh: LauJensen: lol - thank you

10:46 Scala_: cemerick: Huh, surprising they don't have something readily-accessable like python/ruby where you install one thing and immediately can create/run/repl projects

10:47 dnolen_: ^

10:47 LauJensen: Scala_: Are you comfortable with Emacs and running a Linux system ?

10:47 Scala_: LauJensen: Personally vim, and yes

10:47 cemerick: Scala_: not sure what you mean -- like scaffolding or something?

10:47 LauJensen: Scala_: Okay, I dont think VimClojure is very easy to install, but the Emacs package is doable :)

10:48 Also there is something called Clojure In A Box I think

10:48 Scala_: LauJensen: Ah, similar to lisp in a box?

10:48 LauJensen: Yes

10:48 cemerick: Scala_: FYI: http://www.assembla.com/wiki/show/clojure/Getting_Started

10:49 Scala_: cemerick: When you isntall python for example, you have access to an interpreter and a repl right off the bat, and you can essentially do everything you want to do (without outside packages) immediately

10:49 cemerick: Scala_: not sure that's better than needing a single file and 'java -jar'ing it. *shrug*

10:50 rrc7cz: Scala_, LauJensen: Clojure Box does that. It was my first env. You literally run the installer and you're up and running, though it is Emacs so you might need to check up on key bindings

10:50 LauJensen: Cool

10:50 Scala_: rrc7cz: Nifty, though emacs :'(

10:51 cemerick: Maybe, but I've never used anything on the Java platform. I was hoping I could just "clojure helloworld.clj" and be ready to run

10:51 rrc7cz: Scala_: well, the easiest in the world would be: http://www.try-clojure.org/

10:51 chouser: A human translation of that Goethe quote: "He who cannot be farsighted / Nor three thousand years assay, / Inexperienced stays benighted

10:51 /Let him live from day to day"

10:52 LauJensen: rrc7cz: yea, though thats a little restricted and lacking a tutorial

10:52 Scala_: rrc7cz: That's neat, but you really can't do anything worthwhile there

10:52 cemerick: Scala_: It's really a difference of just a few characters, or a shell script. cljr looks very promising in terms of upping the bar in a command-line setting. *shrug*

10:53 e.g. running a helloworld.clj file would be `java -cp clojure.jar helloworld.clj`

10:53 LauJensen: chouser: I dont think you can get a german speaking person to confirm that

10:53 Scala_: cemerick: That's all and good if you know how java works already

10:53 dnolen_: Scala_: this issue comes up again and again. It's known. Perhaps 1.3 will have a solution for every OS. But not today. Do you have Java installed?

10:53 Scala_: dnolen_: Yes.

10:54 dnolen_: Scala_: do you installing something via Ruby?

10:54 do you mind I mean.

10:54 Scala_: I should be clear though that I'm not having any issues getting clojure set up the 'normal' way, I was more just curious if there was strides being made (or made already) to getting all-in-one setups for people new to clojure

10:54 chouser: LauJensen: do you mean you think that transaltion I pasted is inaccurate?

10:55 cemerick: Scala_: Clojure is a hosted language, so you'll have to be/become familiar with the host in question, whether that's the jvm or the CLR (js in the future and who knows what else).

10:55 LauJensen: chouser: Yes, I dont read it as such, I dont see the first sentence of yours in the german version at all

10:55 dnolen_: Scala_: cljr is pretty good. I 'sudo gem install cake', and I have a working setup immediately.

10:55 LauJensen: But Im not german, so Im just saying I think you should speak with someone who is

10:55 lightcatcher: i'm new to clojure and functional languages in general, having some problems with a simple function i'm trying to write

10:55 Scala_: dnolen_: Nice. I'll give that a shot

10:56 lightcatcher: if someone could recommend a pastebin, i'll put it up, and it would be great if someone could help me

10:56 Scala_: dnolen: Funny that you can install clojure through a gem of all things though, hah

10:56 I'd expect a deb or rpm :P

10:56 jkkramer: lightcatcher: a lot of people use gist.github.com

10:57 cemerick: java libs are unfortunately not handled well by system package managers in general

10:57 Chousuke: gist has good Clojure syntax highlighting

10:57 lightcatcher: thanks jkkramer, i didn't know of anywhere that has clojure hilighting

10:57 chouser: I'm not at all sure about "good", but it has some

10:57 Chousuke: chouser: better than paste.lisp.org :P

10:57 nachtalp: LauJensen: i don't see the 'farsighted' part either

10:57 chouser: :-)

10:58 lightcatcher: http://gist.github.com/540490 is my snippet

10:58 chouser: looks like that transaltion is trying hard to rhyme in English

10:58 lightcatcher: the goal is defined pretty well in the docstring imo

10:59 the code is working to provide an int in proper range, but the if statement to prevent forbidden doesn't seem to be working

10:59 nachtalp: chouser: yeah :)

10:59 chouser: lightcatcher: looks like perhaps you've used or are learning from scheme

10:59 Chousuke: lightcatcher: don't use def in functions. :)

10:59 nachtalp: chouser: but i'd say that the gist is the same in both the german version and the translation

10:59 lightcatcher: how should i save the random value then?

10:59 nachtalp: chouser: at least as far as that's possible for poetry...

10:59 Chousuke: lightcatcher: lightcatcher you'll need to use let

11:00 oops

11:00 chouser: nachtalp: ok, thanks

11:00 lightcatcher: thanks Chousuke

11:00 jkkramer: lightcatcher: (let [rval ...] ...)

11:00 Chousuke: lightcatcher: also use recur instead of calling the function recursively

11:00 lightcatcher: is the rest of the structure correct though?

11:00 Chousuke: lightcatcher: so that it doesn't waste stack space

11:00 lightcatcher: Chousuke, i also wanted to ask about that, it wasn't working when i did (recur lower upper forbid)

11:01 Chousuke: it should work just fine

11:01 lightcatcher: but i need to look back at the docs for recur

11:01 Chousuke: you're indenting a bit too much there btw.

11:01 two spaces is the standard indentation :P

11:02 (except when aligning parameters)

11:05 mrBliss: http://gist.github.com/540504

11:05 lightcatcher: thanks again Chousuke, i'm used to 4 with python

11:06 I completely forgot about the let statement. Functional programming is a bit of a paradigm shift

11:07 Chousuke: lightcatcher: Lisp code tends to get deeply nested so two spaces is kind of necessary.

11:07 otherwise your code will be dominated by indentation :P

11:07 lightcatcher: I should probably read a style guide before i get into bad habits

11:08 Chousuke: lightcatcher: There's no real Clojure style guide that I know of but a big chunk of this is applicable: http://mumble.net/~campbell/scheme/style.txt

11:09 lightcatcher: http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards contains good advice too

11:09 lightcatcher: thanks

11:09 i'm a notepad++ user (at least for just experimenting/learning), anyone know if there is a clojure plugin for that?

11:10 google couldn't find me one :(

11:13 LauJensen: lightcatcher: never heard of one

11:13 lightcatcher: but fortunately, Emacs runs on Windows as well so you can use that

11:14 lightcatcher: i could, but i'd rather keep my editor

11:14 LauJensen: k

11:15 lightcatcher: thanks though. notepad++ will still hilight the pairs of parentheses, and that seems to be the only "must have" syntax highlighing i need at the moment

11:15 LauJensen: I suffered in notepad++ because I couldnt get the indenting to work right

11:29 _fogus_: Anyone know what happened to Jeffrey Straszheim? Haven't heard a peep in quite a while

11:32 cemerick: _fogus_: he works @ akamai I think. Last seen posting job ads?

11:32 _fogus_: So he's still involved with Clojure then?

11:34 AWizzArd: arkh: sorry no

11:35 arkh: I will now scroll up and read what you wrote.

11:35 cemerick: _fogus_: AFAIK, yes

11:35 _fogus_: ok. Hopefully a flood of datalog changes are forthcoming now that 1.2 is out. :-)

11:38 AWizzArd: arkh: Hmm, that is german but is not exactly correct. One could translate it this way, and yeah, it looks very strange: "Who not from three thousand years. Oneself how to give account, stay in the dark, unexperienced, may live from day to day."

11:39 chouser: AWizzArd: is the first sentence perhaps just the second half of a correct sentence?

11:40 AWizzArd: chouser: I am not sure. This IS however the translation and probably matches the effect that I had when I read the german version. One understands the words, but some context and grammar is missing.

11:49 dnolen: rhickey: I'm curious. I know protocols are the new cool, but is there any interest in improving the performance of multimethods? I find that they're fantastic for coarse grained tasks, but being an more than an order of magnitude slower makes them less than ideal for certain things (even tho I would prefer to use them)

11:49 slower than regular fns I mean

11:52 Chousuke: Do you have an idea for an improvement?

11:53 dnolen: Chousuke: not immediately, but I was perusing the Chambers/Chen predicate dispatch stuff, and was curious if baking that in more directly could improve performance

11:54 Chousuke: reading over those papers also seems like predicate dispatch gives some of the guarantees people like about type systems.

11:55 mattrepl: maybe squashing all methods defined at compile time into a single function with conditional branches for implementations

11:56 maybe that's already done, I'm not familiar with the current impl

11:57 dnolen: mattrepl: there's a dispatch table of values that are matched against

11:58 mattrepl: yes, so removing that lookup and have a sequence of conditional branches with the corresponding method implementation inlined in the branches

11:58 no map lookup, no extra function invocation

11:59 * mattrepl has no clue where the slowdown is, just thinking out loud

11:59 AWizzArd: Though I am sceptical that it can gain a significant amount of extra performance.

12:00 arkh: AWizzArd: I know very little german but it still seemed odd to me, too.

12:00 AWizzArd: arkh: then you already have a good feeling/pattern matching for german texts.

12:01 mfex: dnolen: what kind of usages do you have for multimethods? what do you dispatch on?

12:01 arkh: AWizzArd: well, the first sentence is obviously only a sentence fragment. But then the rest ... I don't know. I probably don't know enough to comment :)

12:02 mfex: arkh, AWizzArd: I think there should be no period after jahren so the first two sentences are combined and there is no sz-as-B in my JoC version

12:03 AWizzArd: Btw, some german users in here might be interested that there is also a #Clojure.de channel, and a german google group.

12:04 dnolen: mfex: multimethods let you dispatch on things other than just type.

12:05 mfex: they are also "open" other people can easily provide new dispatch possibilities.

12:05 mfex: one problem I find tho is that the dispatch function is hard coded, that isn't open.

12:06 * AWizzArd would be interested in native pattern matching in Clojure :)

12:06 mfex: dnolen: yes, I was wondering what kind of dispatch function, ie a vector of keywords as a result may perhaps allow for a quicker lookup scheme for the lookup table

12:06 AWizzArd: That seems to be more flexible that multimethods and will also typically be much more terse.

12:08 mfex: dnolen: when you need the openess of multimethods, a specialized lookup table will require the possibility of new lookup paths, a simple table allows for this but is not as optimized/quick as you would like?

12:10 dnolen: AWizzard: rhickey has said he doesn't like pattern matching because it is also closed and forces an ordering (?)

12:10 AWizzArd: Yes, I know. Though the defpattern form could install its patterns and their respective body globally.

12:11 One could add pattern/body at runtime, or remove some.

12:12 dnolen: mfex: well I only have the current implementation to compare. To be honest it's plenty fast for things like modeling the usual DB record in a web application. But it would be nice if we could get you know with 2X of regular fns instead of >10X

12:18 mfex: dnolen: do you use multimethods with hierarchies/isa/derive?

12:18 dnolen: mfex: yes

12:19 I suppose rchickey's interest in datalog could improve the perf of dispatching? avoid fn calls altogether and just using rules?

12:20 Licenser: I has the impression clojure 1.2 was supposed to be non breaking the old contrib libs did that change again?

12:54 slyrus: this feels ... wrong: (defn replace-val [m old new] (reduce (fn [m [k v]] (if (= v old) (assoc m k new) (assoc m k v))) m m))

12:55 well, I can get rid of the second assoc, but still..

12:57 and with that bit of hackery I can properly compute the tetrahedral orientations of the neighbors of a chiral atom with a ring opening. yay.

12:59 rhudson: slyrus: how is that different from (replace {old new} m) ?

13:01 slyrus: ,(replace {'foo 'bar} {1 'foo 2 'moose})

13:01 clojurebot: ([1 foo] [2 moose])

13:01 slyrus: I want {1 'bar 2 'moose}

13:01 rhudson: ah

13:10 mebaran151: I'm having trouble getting deftype definitions to reload in the repl. I'm trying to use the swank.core/break debugger, which is pretty convenient, but I can't seem to change type definitions in the repl

13:11 tomoj: slyrus: what's wrong about it?

13:11 slyrus: tomoj: it just feels a little dirty that's all... but I think it's ok.

13:11 tomoj: is something like (defn replace-val [m old new] (into {} (for [[k v] m] (if (= v old) [k new] [k v])))) also dirty?

13:11 mebaran151: the methods stay with their original forms

13:11 slyrus: more so :)

13:12 rhudson: or (defn replace-val [m old new] (let [[ks vs] ((juxt keys values) m)] (zipmap ks (replace {old new} vs)))

13:13 Bahman: Hi all!

13:17 mebaran151: any links about classloading issues and deftype that might be able to shine some light on my situation

13:19 tomoj: I wish I better understood elegance

13:32 chouser: tomoj: what an interesting thing to say!

13:34 psykotic: the word doesn't mean anything objective. something so elusive cannot be understood. i once heard someone refer to axion (an rdbms written in java) as the most elegant program he'd seen.

13:36 tomoj: I don't wish I had a program that would accept a program as input and output its elegance

13:36 psykotic: hehe

13:37 tomoj: maybe s/understood/grok/

13:37 er, grokked

13:39 psykotic: one problem with common notions of elegance is that it is so constraining that no useful program can be elegantly written.

13:39 so, if you make that your standard of excellence, you are making it harder for yourself to write useful programs.

13:39 most useful programs solve messy problems, in other words.

13:40 technomancy: did slurp* get renamed in clojure.java.io?

13:41 I hope it didn't get dropped just because it had a bad name; it's really useful

13:48 bpsm: stuartsierra: clojure contrib: 4e5d98a broke the repl-utils build.

13:49 fixed here: http://github.com/bpsm/clojure-contrib/commit/11ab6908882684e980640cfde0eb47efe3a8bd33

13:49 stuartsierra: bpsm: I reverted that, it broke too many things

13:50 bpsm: stuartsierra: ok. gotcha.

13:54 technomancy: stuartsierra: I've got a couple ideas for clojure.test in 1.3

13:55 stuartsierra: clojure.test is dead, long live Lazytest

13:55 technomancy: 0) have the testing macro print the string it's given when the tests are run based on a var

13:55 uh dude...

13:55 it has hundreds of users, and these are trivial additions

13:55 stuartsierra: I know, I'm kidding

13:55 technomancy: gotcha

13:56 I'm just a bit bummed out how long trivial additions can linger in the issue tracker =\

13:56 stuartsierra: Stu H. has been working really hard on that

13:56 technomancy: adding more committers hasn't seemed to fix the problem, but I'm hoping that's just due to the feature freeze

13:56 right-o

13:56 stuartsierra: there actually are still only 3 committers to Clojure

13:57 technomancy: oh, still?

13:57 =\

13:57 stuartsierra: contrib has more, but clojure.test isn't in contrib any more

13:59 but there are improvements to be made in clojure.test for sure

13:59 technomancy: I also monkeypatched it to spit out dots for each passing "is", which is nice for longer suites so you can tell that progress is happening

14:00 would be nice to be able to do that without monkeying

14:00 I meant to ask you before implementing and submitting them as patches, but I guess you still don't have any control or say in what goes in. =\

14:01 stuartsierra: I have a say, but no direct control

14:01 patches have to go through the mailing list and Assembla, like everything else

14:02 technomancy: of course

14:03 I'd like to think patches that the original author of the lib thinks are a good idea could be fast-tracked.

14:04 stuartsierra: somewhat

14:07 problem is, so many people have monkeypatched 'report' for different purposes that it can't change without breaking them

14:08 * technomancy whistles innocently

14:08 technomancy: yeah, I need to find a better way to do that.

14:09 mebaran151: is it possible to C-c C-k new method definitions with deftype

14:09 tomoj: yeah

14:09 mebaran151: currently, I can't seem to edit my definitions, replace them etc.

14:11 tomoj: hmm

14:11 hiredman: chouser: how does most of syntax-quote live in clojure.core?

14:11 last I checked it had a huge gnarly section in LispReader

14:12 mebaran151: my deftypes can only reflect the first definition

14:12 despite compiling and reloading

14:12 if it helps, I just tried moving to Clojure 1.2.0 final

14:14 tomoj: mebaran151: are you AOT compiling?

14:14 KirinDave: Wow.

14:14 I learned something valuable today.

14:14 If you are a lisper, you cannot work in banking. QED.

14:14 Lisp, I'm told, treats negative numbers as s-expressions.

14:14 mebaran151: tomoj, I'm just using swank server

14:14 tomoj: hmm.. I only see that behavior when AOT compiling

14:15 mfex: KirinDave: lol

14:15 KirinDave: You may require proof: http://news.ycombinator.com/item?id=1619516

14:15 mebaran151: wrote a new file, trying to ctrl-c ctrl-k it

14:15 * KirinDave sighs.

14:15 KirinDave: This is gonna be another one of those high profile gigs.

14:15 stuartsierra: mebaran151: if you've AOT-compiled the file containing the deftype, the compiled version may take precedence

14:16 mebaran151: how would I know that?

14:16 should I try a lein clean I see if I avoid it?

14:16 tomoj: look in classes/ for YourType.class

14:18 mebaran151: hmmm

14:18 a lein clean seemed to fix it

14:18 _fogus_: "Persistence ... completely breaks when you leave the machine you’re running on."

14:18 Interesting perspective

14:18 :p

14:19 mebaran151: so everytime I kill swank, I have lein clean, or else deftype will just silently reuse the old class files, think they were statically compiled on purpose?

14:20 hmmm, seems to be working now

14:21 I should always clean before I go nuts

14:21 tomoj: weird

14:21 I only get class files when aot compiling

14:21 mebaran151: oh I don't have classes now

14:21 maybe I ran a lein compile and forgot about it

14:25 oh this is interesting

14:25 I think deftype must make new class names under the hood on recompile or something, because the interface's changes are not propogated once I include my Java RPC library

14:26 (it takes the instance as an argument)

14:27 there must be some magic caching going on...

14:27 stuartsierra: only AOT-compiled deftypes give you stable class names for Java interop

14:28 mebaran151: oh I see, that's good to know

14:28 it's a nice design for an RPC library, but a bad fit for clojure

14:29 essentially, you can pass the RPC Server an object, and it will use reflection to match up the methods

14:29 would be very easy to use in Java, but it's a little trickier from clojure

14:29 chouser: stuartsierra: I don't think that's true anymore

14:30 I think clojure now uses classloader trickery to create new classes with the same name when you redefine a type or record

14:31 but it is actually a different class, so existing instances will remain instances of the old class

14:31 stuartsierra: oh ok

14:36 mebaran151: classloader stuff always makes my head spin; it feels like it shouldn't be that hard

14:38 kensho: _fogus_: are you referring to http://beust.com/weblog/2010/08/19/clojure-concurrency-and-silver-bullets/#comment-8475? That guy's either mind-boggling stupid or a troll imo. The blog post is pretty dumb as well imo. I would've expected better from the TestNG developer.

14:39 _fogus_: kensho: I'm sure there was something that the poster was trying to say, but I think he worded it poorly. The post itself is what it is -- Beust doesn't find locking difficult. That's great!

14:40 kensho: _fogus_: hehe. good for him

14:40 ryanf: I think I am misunderstanding reduce somehow. why doesn't this work? http://pastebin.com/sh9GFGVF

14:40 technomancy: "guys, it's not that hard. you just have to be awesome. like me."

14:41 _fogus_: technomancy: Something to strive for

14:42 arkh: is the best way to have optional, named arguments in a function to provide them with default values (zero?) and then test the value in the body of the function or is there a better way?

14:45 tomoj: -> ((fn [x y & {:keys [a b c] :or {b 5}}] [x y a b c]) 1 2 :c 3)

14:45 sexpbot: => [1 2 nil 5 3]

14:45 tomoj: does that help? didn't really understand the question

14:49 ryanf: (#(+ (Character/getNumericValue %1) %2) \7 1)

14:49 whoops wrong window

14:50 for real though, does anyone know why (reduce #(+ (Character/getNumericValue %1) %2) 0 "1234") givse a cast error?

14:50 isn't it supposed to start with 0 as the accumulator?

14:50 *gives

14:50 mebaran151: arkh, do you mean named as in key value style arguments, or named arguments by position?

14:50 chouser: ryanf: you just got your args swapped

14:51 ,(reduce #(+ (Character/getNumericValue %2) %1) 0 "1234")

14:51 clojurebot: 10

14:51 ryanf: shiiiit

14:51 I was thinking it could be that a minute ago, but I thought it said the second arg was the accumulator

14:51 thanks

14:52 arkh: tomoj: that's a good example of default values when arguments are not supplied, but I think I found the answer to my own question with just writing different implementations based on arity ... or something

14:53 mebaran151: key value style arguments with some of the keys being optional

14:56 tomoj: I don't understand how your question is different

14:57 kv args are optional using map destructuring

14:57 you mean that some of the kv args should be required?

14:59 arkh: tomoj: for the function I want to write most arguments (keys, in this case) are required but a couple aren't. Any recommendations? Sorry if my phrasing has been unclear.

15:01 I guess I should be saying "function parameters"; I don't see "arguments" used in clojure function terminology so far

15:03 hiredman: argument and parameter have specific formal meanings which I always get reversed

15:03 tomoj: wikipedia seems to suggest that the parameter is the variable, the argument the value

15:03 hiredman: one is the value passed to a function and the other is more or less the name the value gets bound to

15:03 "variable"

15:03 pah

15:04 arkh: "symbol" ;)

15:04 er .. maybe not

15:04 technomancy: parameter has more to do with definition, argument has to do with the function actually running

15:05 being/becoming, etc

15:05 tomoj: arkh: I can't think of any good way at all to require some kv args

15:06 arkh: tomoj: yeah, that's the thing - function dispatch can happen based on arity and multimethods can be dispatched based on type, but I can't see a way to require some key/value params and make others optional

15:06 tomoj: the way is to check in the function, I guess, but I didn't consider that "good" :)

15:06 technomancy: "bless me, it's all in Plato. what ever do they teach in schools these days?"</lewis>

15:07 mebaran151: I've become addicted to use the slime feature where it shows the function arguments in the bottom (minor?) bar. Is there anyway to extend this to tell me the functions for a Java constructor?

15:07 tomoj: technomancy: heh, I assumed david lewis and was confused

15:09 arkh: tomoj: I don't think I'd normally need to write a function like that but it's for some java interop

15:12 mebaran151: arkh: is there anything wrong with just mergining in a hash-map of defaults?

15:15 arkh: mebaran151: I can do that - I wanted to make sure there wasn't a better way, though. Having a default value be special (even if it's nil) seems more cumbersome than what clojure could (should?) offer

15:16 with clojure, when I find I'm writing something inelegant, I've usually been able to discover it's a lack of understanding on my part ;)

15:27 rhudson: Basically you want to check that the set of required keys is a subset of the set of supplied keys

15:28 kiemdoder: what is the difference between "if" and "cond"?

15:30 tomoj: oh, so maybe :as will help?

15:31 yeah, with :as you could check the keys and not have any magic values

15:32 mefesto: kiemdoder: "if" has a form for the true condition and optional a form for the false. cond lets you perform any number of conditional tests

15:32 "if" ... and an optional form for the false condition... is what i meant to say :)

15:33 tomoj: -> ((fn [x y & {:keys [a b c] :or {a 5} :as m}] (if (every? (set (keys m)) [:b :c]) [x y a b c m] "error")) 1 2 :c 3)

15:33 sexpbot: => "error"

15:33 tomoj: -> ((fn [x y & {:keys [a b c] :or {a 5} :as m}] (if (every? (set (keys m)) [:b :c]) [x y a b c m] "error")) 1 2 :c 3 :b 6)

15:33 sexpbot: => [1 2 5 6 3 {:c 3, :b 6}]

15:34 Raynes: sexpbot is so adorable when he doesn't break. <3

15:36 arkh: rhudson: nice

15:38 that wants to be a macro

15:39 rhudson: yeah, I can't offhand think of a one-liner to do it

15:40 * arkh hopes he can roll off proof of concept code as easily as tomoj someday ;)

15:43 kiemdoder: mefesto: what do you mean by "any number of conditional tests" for cond? Is it like "if cond1 and cond2 and cond3:" in python for instance?

15:43 _fogus_: ,((fn [x y & {:keys [a b c] :or {a 5} :as m}] {:pre [(:b m) (:c m)]} [x y a b c m]) 1 2 :c 3)

15:43 clojurebot: java.lang.AssertionError: Assert failed: (:b m)

15:43 _fogus_: arkh: ^^^

15:43 arkh: _fous_: is that a precondition?

15:44 _fogus_: yes

15:44 Raynes: kiemdoder: It's like a series of ifs, where each else is a new if.

15:44 arkh: sweet

15:44 Raynes: (cond (= 1 2) false (= 2 2) true) is like (if (= 1 2) false (if (= 2 2) true))

15:47 arkh: _fogus_: clojure elegance achieved. I love how a person knows they're going in the right direction with clojure if it's intuitively appealing

15:47 kiemdoder: thanks, Raynes

15:48 and Mefesto

15:49 holoway: sometimes it seems like when I use for(), it winds up being executed in parallel - is that normal behavior? if it is, how can I get it to be in order?

15:49 hiredman: ~for

15:49 clojurebot: for is not used often enough.

15:49 hiredman: ~for

15:49 clojurebot: for is not a loop

15:51 BrianForester: ,(map #(map (memfn toUpperCase) %) '(("and" "than" "day") ("plan" "minus" "divide"))))

15:51 clojurebot: (("AND" "THAN" "DAY") ("PLAN" "MINUS" "DIVIDE"))

15:52 arkh: holoway: for's comprehension is serial, in order "from right to left"

15:54 * Raynes is surprised memfn hasn't been removed yet.

15:55 BrianForester: raynes: what is the better option? looking for feedback here.

15:55 arkh: ,(for [third [5] second (range 2) first (range 3)] (str third \. second \. first))

15:55 clojurebot: ("5.0.0" "5.0.1" "5.0.2" "5.1.0" "5.1.1" "5.1.2")

15:58 Raynes: -> (map (fn [x] (map #(.toUpperCase %) x)) '(("and" "than" "day") ("plan" "minus" "divide")))

15:58 sexpbot: => (("AND" "THAN" "DAY") ("PLAN" "MINUS" "DIVIDE"))

15:58 Raynes: BrianForester: ^

15:58 Use an anonymous function instead. memfn was deprecated.

15:59 BrianForester: Sorry about that. I didn't realize you were looking for feedback! :)

15:59 wwmorgan: since when has memfn been deprecated?

16:00 BrianForester: raynes: thanks. ...is there a clojure opt to warn about deprecated functions?

16:01 Raynes: wwmorgan: memfn was before #(). It's been deprecated for quite a while.

16:02 BrianForester: You shouldn't have to worry about that much. There aren't many deprecated functions to step on.

16:02 But I don't think there is an option for that in any case.

16:02 BrianForester: raynes: K

16:02 kiemdoder: if I have a map m with that contains a key :a, (:a m) and (m :a) both give the the value at :a

16:02 rhudson: right

16:02 Raynes: However, if something is deprecated, it'll have :deprecated true in it's metadata map.

16:02 kiemdoder: are these two forms equivalent?

16:03 rhudson: A map is also defined to be a function of its keys

16:04 Raynes: Keywords are functions that look themselves up in a map, and maps are functions that look up whatever you pass it as a key inside itself.

16:04 rhudson: You should probably prefer the (:a m) form, if it's at all likely that you want to eventually have a record type for the map

16:04 Raynes: You can't do ("a" m), for example, and expect the value at the key "a" in the map to be returned.

16:04 _fogus_: ,(for [m '(("and" "than" "day") ("plan" "minus" "divide"))] (map #(.toUpperCase %) m))

16:04 clojurebot: (("AND" "THAN" "DAY") ("PLAN" "MINUS" "DIVIDE"))

16:14 fusss: "bordeaux-threads-test is broken because it uses FiveAM which depends on Arnesi which is broken on ABCL because the long form of DEFINE-METHOD-COMBINATION is not implemented" :-D

16:14 that should be the easiest fix to bring ~5 packages to abcl

16:14 sorry, wrong channel

16:14 sheesh

16:15 hey _fogus_ ; my HN buddy

16:16 actually, i am here to pick people's brains over java SSL libs and their proximity to OpenSSL. is it straightforward to wrap javax.net.SSL to give it a trivial libssl like interface, or am I in for a lot of pain?

16:17 dmiles_afk: lol fusss, i kept trying to flip between #abcl and #lisp to find what you saird.. and it was in #clojure :)

16:18 fusss: yeah, painfully embarrassing there

16:21 dmiles_afk: i routinely find myself reading an Elisp manual by accident, thinking it was the hyperspec. GNU content is very google friendly, and often formatted in various ways, some resembling cltl

16:23 dmiles_afk: ineed

16:23 my Secondlife bots are scripted in DotLisp (aka Clojure) .. though i been creating smoothing libraries in ABCL.. using jcall/jstatic/jfield

16:24 becasue clojres syntax for calling java is more elgant than allegros (that ABCL copied)

16:25 fusss: dmiles_afk: Hickey wrote a nice CL wrapper for interacting with java

16:25 dmiles_afk: *nod*

16:26 oh i wonder.. does ClojureCLR call events>

16:26 oh i wonder.. can ClojureCLR call events?

16:30 ineed/indeed

16:55 edbond: any clutch users?

16:56 is it possible to emit several docs from :map function? clojure view server

17:40 scottj: Is there a builtin for renaming keys in a map?

17:41 puredanger: I need something that takes a function and a seq and returns N partitions of the seq based on the result of applying the function. does this exist?

17:41 raek: scottj: clojure.set/rename-keys

17:42 oddly enough in clojure.set...

17:43 scottj: puredanger: group-by?

17:43 raek: thanks, that's the name I gave the version I wrote! :)

17:43 puredanger: that might work. returns a map but I can work with that probably

17:44 scottj: many thanks...

17:44 I'm hoping that the rate with which I learn the functions in core is greater than the rate at which they are being added :)

17:44 scottj: puredanger: there might be something closer in seq_utils

17:46 wwmorgan: puredanger: partition-by will do what you want, if all the elements you want grouped together are contiguous

17:47 puredanger: wwmorgan: yeah, that occurred to me, but they're not (and can't be without applying the function)

17:48 scottj: I think group-by + map destructuring on the result works

17:48 wwmorgan: puredanger: what about calling vals on the output of group-by?

17:49 puredanger: wwmorgan: I need to know which group is which I think

17:51 wwmorgan: puredanger: I see. something like (my-partition #(mod % 3) [1 2 3 4 5]) returns ((3) (1 4) (2 5))?

17:52 puredanger: wwmorgan: I think group-by is what I want

17:53 wwmorgan: OK

17:55 scottj: Anyone using camelCase keys in their clojure and nosql just so they convert easily to javascript? I'm wondering if I should make that switch so the keys are all the same.

17:56 fusss: scottj: the lispy way is to use strings

17:57 symbols shouldn't be camel-cased, even if your lisp-reader allows it

17:57 hiredman: fusss: what would you know about it?

17:58 fusss: hiredman: just project cl/scheme experience unto clj. camel case symbols are hardly used; even in SOAP and XML

17:59 kensho: fusss: Is there another reason except that it's not "lispy"? I prefer camelCase and I don't care if it's lispy or not.

17:59 patrickdlogan: fusss: yeah, scheme is case-insensitive and common lisp is kind of on the fence - case-sensitive but the reader may convert case for you.

17:59 fusss: kensho: sniff around clojure-contrib and see how they do things

18:00 patrickdlogan: but I am not sure what is "lispy" about this.

18:00 that's the kind of cruft that (some) people have wanted to clean up.

18:00 kensho: fusss: that's no really a reason. If everyone jumps off a bridge you do it too?

18:01 arkh: convention and consistency help readability (for yourself and others), fwiw

18:01 fusss: no, avoiding camelCase also helps your development tools. what if SLIME is case agnostic? would you suffer?

18:01 patrickdlogan: having said that I would not recommend having a lot of symbols differing only by case, but I don't want the reader to convert the case I choose in any situation.

18:02 kensho: fusss: i don't use slime and don't plan to

18:02 dmiles_afk: i am using IKVM so i run into alot of case importance since my objects have both ToString() and toString()

18:03 patrickdlogan: dmiles_afk: oh dear.

18:04 kensho: I'm all for consistency but I think it goes too far if the language dictates arbitrary naming conventions

18:06 fusss: the language doesn't dictate anything, that's why we're talking about it :-)

18:08 kensho: I'm just saying, just because contrib uses a specific style doesn't mean I have to follow it does it? If I'm contributing to contrib I will certainly use that style but for my own code I want to use what I like best.

18:10 fusss: maverick

18:11 technomancy: facepalm

18:14 slyrus: "if we're gonna have uniforms, maybe we should all get something different!"

18:44 mebaran151: is there a way to get all the function on a given type?

18:47 polypus: is the moderation lag on the google groups clojure mailing list really long? i've posted two messages today and they don't seem to have shown up.

18:47 scottj: mebaran151: how if it's dynamically typed?

18:47 hiredman: polypus: usually it's long for your first post

18:47 polypus: hiredman: k. ty

18:48 anybody using the new lein shell script feature yet? i can't get it to work properly

18:50 technomancy: polypus: custom script or default?

18:50 polypus: for the default, look at swank-clojure for an example

18:51 polypus: custom

18:51 mebaran151: scottj: I mean a given deftype

18:51 polypus: i have :shell-wrapper { :bin "resources/bin/caj" } in project, and it's being copied over to ~/.lein/bin, but %s is not being overwritten

18:51 on a lein install

18:52 technomancy: polypus: shouldn't need resources/; it should be classpath-relative

18:52 %s-interpolation should be happening at jar-time actually

18:52 polypus: little busy now; if you get stuck could you post an example to the lein mailing list?

18:54 polypus: technomancy: ok, ty. i posted to the clojure google group but i guess the moderators are taking their time. i'll look for the lein list

18:58 scottj: mebaran151: oh :) sorry I haven't used 1.2 features don't know

19:31 polypus: technomancy: ok, i did a few experiments with a new lein project and still no luck. either that or i'm just not getting something. i posted about it to the lein mailing list just now.

20:21 rlb: Does defn- even hide the def from code after an (in-ns ...)?

20:30 wooby: rlb: no

20:58 rlb: wooby: hmm, then I'm wondering what's happening -- with 1.2, (use 'clojure.java.shell) (in-ns 'clojure.java.shell) (prn as-env-string) fails, but at least in master, as-env-shell is in shell.clj.

20:59 wooby: strange

21:00 can you #'clojure.java.shell/as-env-string from some other ns and see it?

21:01 rlb: (Oh, and this is with the 1.2 zip.)

21:02 wooby: @#'clojure.java.shell/as-env-string rather

21:02 rlb: Fails -- can't find it.

21:02 But sh is fine.

21:03 Is there any chance the 1.2 version doesn't have it, but master does?

21:03 wooby: quite possible

21:03 rlb: I couldn't find a 1.2 branch or a 1.2 tag in the current repo.

21:03 wooby: rlb: http://github.com/clojure/clojure/tree/1.2.0

21:04 rlb: http://github.com/clojure/clojure/blob/1.2.0/src/clj/clojure/java/shell.clj#L52 maybe?

21:05 incandenza: isn't it as-env-strings ?

21:05 rlb: Ahh, I had git://github.com/richhickey/clojure.git

21:06 incandenza: looks like it in 1.2, but not in (richhickey's) mater.

21:06 that was the problem

21:06 thanks

22:02 slyrus: hmm... a couple things I miss from CL-land: 1) arrays of, say, (unsigned-byte 2) and 2) flexichain

22:02 I'm sure there must be a nice flexichain-like java package around. anything in clojure?

22:02 rlb: Is it possible to use apply with a method?

22:02 chouser: rlb: no

22:02 rlb: nm

22:03 OK -- just wanted to call Runtime exec with 1, 2, or 3 args, depending. I can always use cond.

22:03 pdk: java primitives are never unsigned

22:03 you can still do stuff like int-array byte-array etc for all the java primitive types

22:04 * slyrus pretends the java stuff doesn't really exist

22:26 slyrus: even though they're mutable, I'd like to see more CL-style array support in clojure

22:27 rhudson: why?

22:27 clojurebot: why not?

22:27 chouser: clojure supports java arrays. what's missing?

22:28 slyrus: chouser: well, for one thing, not having to use the interop syntax and, for another, support for types besides ints and bytes

22:29 hiredman: uh

22:29 ,(doc char-array)

22:29 clojurebot: "([size-or-seq] [size init-val-or-seq]); Creates an array of chars"

22:30 hiredman: ,(into-array [[1 2] [3 4]])

22:30 clojurebot: #<PersistentVector[] [Lclojure.lang.PersistentVector;@1d66cb3>

22:30 chouser: ,(let [a (to-array [1 "foo" (Object.)])] (aset a 1 "bar") (seq a))

22:30 clojurebot: (1 "bar" #<Object java.lang.Object@12f035c>)

22:30 hiredman: ,(aget (into-array [[1 2] [3 4]]) 0)

22:30 clojurebot: [1 2]

22:30 hiredman: you are obviously making things up

22:30 slyrus: or just wrong, but yeah

22:33 dcooper8: Hi, is nobody doing a Clojure presentation or paper at ILC 2010 in Reno?

23:02 hiredman: dcooper8: clojure conj calls

23:03 dcooper8: ok good.

23:04 hiredman: I mean clojure-conj is the 22nd and 23rd of october I believe, so most clojure people will be attending that

23:11 dcooper8: ah, pity.

23:11 the ILC is trying to get more inclusive for all Lisps, not just Common Lisp

23:11 so they were hoping for at least one or two clojure papers

23:12 but i guess the other lisps are not of much interest to clojure people

23:12 hiredman: this the first clojure-conj though

23:13 I would be interested in going to ILC, but I am already going to clojure-conj for work

23:14 (and, I can't lie, I want to go)

23:14 dcooper8: well please spread the word around, if anyone can submit a Clojure paper for ILC, the deadline is coming up...

23:15 i'm personally trying to urge the ALU/ILC to live more up to its name and truly include all Lisps instead of being a thinly-veiled Common Lisp old-boy club

23:15 ninjudd: is clojars down?

23:15 dcooper8: in the meantime I think CL needs its own specific foundation and meetings

23:15 rhudson: dcooper8: you might want to post something to the mailing list

23:16 dcooper8: the google group?

23:16 rhudson: that's what I meant

23:16 dcooper8: i'll ask Daniel Herring to do it, he's the publicity manager for ILC,

23:17 i'll be surprised if he hasn't already done it...

23:17 hiredman: the was at least one ilc email

23:17 rhudson: haven't noticed it, if he has

23:35 bortreb: How do I get a thread running off in it's own little world to print back to the main repl printWriter? I tried (let [temp *out*] (.start (Thread. (fn [] (do (set! *out* temp) (println "hi")))))) but that didn't work :(

23:37 pdk: (doc println)

23:37 clojurebot: "([& more]); Same as print followed by (newline)"

23:37 pdk: hmm

23:39 rhudson: bortreb: (.start (Thread. #(println "hi"))) works for me

23:40 bortreb: for me it prints to the terminal where I started swank

23:40 rhudson: mine was in a cljr repl

23:43 ninjudd: (let [temp *out*] (.start (Thread. (fn [] (binding [*out* temp] (println "hi"))))))

23:43 he's gone

23:44 rhudson: it works in cljr because there is only one repl thread

23:44 ihodes: does anyone know the reason why some function args in the clojure source start with & - eg &forms (not [& forms], [&forms])

23:45 ninjudd: ihodes: it means all subsequent args

23:45 hiredman: &env and maybe &form are special things passed into macros

23:45 ninjudd: he's not talking about vargs

23:46 ihodes: ah, i see. so when we're defining defmacro, those are args passed to the function defmacro is being assigned. what's going on there

23:46 hiredman: defmacro hides them, but before defmacro is def'ed in core.clj macros created manualing have to deal with the

23:46 them

23:47 http://github.com/Seajure/serializable-fn has an example usage

23:47 ninjudd: hiredman: right, i misread the question

23:48 ihodes: checking it out, thanks :)

23:52 phaer: How can i convert a record to a map?

Logging service provided by n01se.net