#clojure log - Apr 07 2010

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

0:01 dnolen: what's the best strategy for making sure an agent isn't queueing up a whole bunch of actions?

0:07 _ato: not sure if there's a proper way to do it

0:07 maybe... (when (> (.getQueueCount my-agent) 10) (await my-agent))

0:13 konr: Why am I not being able to extend a particular class with proxy? I'm getting an "IllegalAcessError" with this class, but not with others

0:30 nteon: good evening

0:35 technomancy: TheBusby: hang on, you're saying (str "Main-Class: " (apply str (replace {\- \_} (str main)))) works but (str "Main-Class: " (.replaceAll (str main) "-" "_")) does not?

0:36 TheBusby: oh, never mind; looks like this was fixed in git already; heh

0:36 dcnstrct: hi. How do I serve a javascript file from my compojure app ? I want for this compojure app to run as a single jar file using jetty so I can't program in a path to read the .js file from.

0:37 I can't hard code a server path I mean..

0:37 can I serve the .js right out of the jar file somehow ?

0:38 metronome: dcnstrct: you can use a .war container for that

0:38 dcnstrct: so far I have done (def javascript "all my js lives in here") and then served that... but I'm tired of escaping quotes

0:39 if I use a .war then I need a java application server to deploy to

0:39 I want to make a single jar file that you run and it starts a server on 8080 completely self contained

0:39 I'm going to wrap it in a .exe and ship it to a windows user to run on his desktop

0:40 so I can't tell him "go setup a java application server"

0:40 _ato: dcnstrct: if you include the js file in the jar then you can get at it via getResourceInputStream or something... let me find the exact method..

0:40 metronome: then why not just bundle the .js files with the exe?

0:40 dcnstrct: sweet

0:41 metronome, that might work too

0:41 another problem though is that I want it to still work when I'm running it in a slime

0:41 during testing

0:41 but I guess I can handle that as a seperate issue

0:41 you can't always have your cake and eat it too

0:42 metronome: I guess you could do what _ato says then

0:42 * technomancy votes for resources as well

0:42 technomancy: though M-x swank-clojure-project hasn't had a stable release that honors them yet

0:43 _ato: I think it should be just something like: (.getResourceAsStream (clojure.lang.RT/baseLoader) "foo/bar/myfile.js")

0:43 dcnstrct: great, I'll give it a shot. thnx

0:44 _ato: I wonder...

0:44 ,(.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/xml.clj")

0:44 clojurebot: nil

0:44 _ato: hmm

0:44 ah

0:44 works in my repl, must be a sandbox thing

0:47 dcnstrct: it works! gracias

0:48 now can anyone think of an easy way to tell it to render from an absolute path when running inside slime and from the jar any other time ?

0:48 I bet swank-clojure-project sets some kind of variable I can use

0:48 TheBusby: technomancy: the fix in git works fine. I was simply provding the fix I used against 1.1.0. DLing the latest lein now ;)

0:48 technomancy: great

0:49 dcnstrct: if you use lein swank it will be able to load from the resources directory

0:49 dcnstrct: HRMMm ok thnx I'll get it if I'm not already using it.

0:51 TheBusby: technomancy: so I guess I'll need to wait for 1.2.0 before a stable version is out with the bug fix? (raw/stable pulls for 1.1.0 and doesn't appear to include that fix...)

0:51 dcnstrct: you're right it just works

0:51 technomancy: TheBusby: yeah, I haven't backported any fixes so far

0:51 TheBusby: using the version from git shouldn't be too bad though; let me know if you run into problems

0:51 TheBusby: that's fine. I'll just stick with my hand fixed one until 1.2.0 and then switch back

0:52 need to keep a bunch of machines in sync, so I'd prefer to stick to a label/tagged version.

0:53 technomancy: ok... not sure how far 1.2.0 is.

0:53 it's not just around the corner

0:53 TheBusby: well other than this tiny issue, lein has been working great ;) No hurry

0:54 peregrine81: I cannot get vimclojure (probably vim) to work correctly..

0:54 trying to open a new reply using \sr and it just puts me in insert mode

0:55 bmason: technomancy: thanks for making Lein! it has really eased my linking pain

0:56 peregrine81: how do I use vimclojure? The doc says type <LocalLeader>sr to open a new repl

0:57 I've got ng running

0:57 technomancy: bmason: cool!

0:58 bmason: we were having a chat the other day about features to add to lein... I don't know if anyone went and did anything about it though

0:59 mikem: peregrine81: have you opened a .clj file first?

1:00 peregrine81: mikem: yep, I've got the plugin installed, I can do completions, highlighting...

1:00 technomancy: bmason: remind me which features?

1:00 mikem: peregrine81: so what happens when you hit <LocalLeader>sr?

1:01 bmason: ah... three main ones that I can recall... being able to search repos, resolving dependencies, and having a default version (latest stable)

1:01 peregrine81: I am assuming my LocalLeader is \ cause I haven't changed it. Nothing happens, when I press s it puts me in insert

1:02 mikem: peregrine81: do you have the appropriate options set in ~/.vimrc? namely, clj_want_gorilla and vimclojure#NailgunClient?

1:02 btw, which version of VimClojure are you using?

1:03 technomancy: bmason: searching repos would need some server-side support

1:03 what do you mean by resolving dependencies?

1:03 peregrine81: mikem: 2.1.2

1:03 mikem: lemme check .vimrc

1:03 bmason: something that would probably also require some support outside lein :)

1:03 I mean resolving hierarchical deps

1:04 mikem: peregrine81: you may be interested in an alpha version of 2.2.0: http://groups.google.com/group/vimclojure/browse_thread/thread/d15b0174d2a1e51 -- but 2.1.2 should work also :)

1:04 bmason: e.g. I add 'cupboard' to my deps, it needs 'berkeleydb', which needs a couple other jars

1:04 peregrine81: the vimclojure#NailgunClient is not mentioned in the docs.. but I did not have gorilla I will add and retry

1:04 technomancy: bmason: if that's not working it's a pretty fundamental bug

1:05 bmason: really?

1:05 huh... didn't know it was supposed to

1:05 technomancy: yeah, that stuff is handled behind the scenes by maven

1:06 mikem: peregrine81: there is a README.txt that ships with the 2.1.2 files, as well as a clojure.txt in the doc/ folder. between the two files, all this stuff should be documented

1:06 _ato: Clojars is now providing the same search stuff maven central does (which eclipse etc use): http://clojars.org/repo/.index/

1:06 the zip is just a zipped up lucene index

1:07 technomancy: oh, cool

1:07 bmason: what do you mean about having a default version?

1:08 bmason: e.g. :dependencies [clojure], and it automatically uses the current stable release

1:09 technomancy: oh, yeah

1:09 bmason: none of this is really major

1:09 just stuff that would save steps for the developer

1:09 technomancy: the problem with that is it will cause code to break down the line even when your project hasn't changed

1:09 bmason: yeah

1:09 :)

1:09 technomancy: one day it works fine; the next it mysteriously doesn't

1:10 you still get this with snapshot deps, but you try to minimize those, and then you know what you're getting into... kind of a necessary evil

1:10 anyway using "lein new" should make it easier since that will leave you with the latest clojure at the time of the lein release

1:10 and having a search would make it even easier

1:10 bmason: true true

1:11 technomancy: I'd love to see something like "lein add cupboard" that could search clojars, maven central, etc, and add a dependency to your project.clj for you

1:11 bmason: yeah, really my biggest hurdle has just been trying to figure out *where* the jars I'm looking for are

1:11 technomancy: if you're looking for a fun project that would be my suggestion. =)

1:11 bmason: you know about jarvana.com?

1:11 bmason: jarvana doesn't cover all the repos

1:12 technomancy: true

1:12 bmason: whereas lein could hopefully tell you whether a package is in any of the repos that it's using

1:12 _ato: the starting point for anyone wanting to implement search would be to take a look at this: http://www.sonatype.com/people/2009/06/nexus-indexer-api-part-2/

1:13 that's what most maven repo search things are using underneath as far as I can tell

1:13 bmason: gotcha

1:15 technomancy: bmason: that would make a great plugin, but unfortunately there's no way right now to activate plugins on a user-wide basis

1:15 just on a per-project basis

1:15 it's on the list though; shouldn't be hard

1:17 bmason: is "the list" accessible to mere mortals?

1:18 _ato: bmason: http://github.com/technomancy/leiningen/raw/master/todo.org

1:18 technomancy: only to org-mode users, sorry =)

1:18 bmason: ok, good link

1:19 technomancy: I have it under "for later", but if I got a patch for it I would be happy to move it to 1.2.0. =)

1:19 bmason: no worries... I really just wanted to make sure the ideas we were discussing weren't getting lost

1:22 peregrine81: mikem: I probably couldn't be more frustrated by this... :/

1:22 bmason: well, good night guys

1:22 thanks for the information :)

1:26 mikem: peregrine81: still not working?

1:26 peregrine81: mikem: i cannot see why its not..

1:27 mikem: you said the nailgun server is up and running, right? did you start it with a classpath which includes the files you're opening in vim?

1:28 peregrine81: no....

1:28 i just used the command

1:28 mikem: starting to see like that nailgun is not worth all the work

1:28 /see/seem

1:29 mikem: peregrine81: well, it's working fine for me :)

1:29 peregrine81: mikem: why would it need to be in the classpath? ANd I have to run the java command everytime I need to edit some files?

1:30 mikem: so, to recap: I start nailgun with, I have the following two lines in my .vimrc: "let clj_want_gorilla = 1" and 'let vimclojure#NailgunClient = "/home/mike/src/clojure/vimclojure/ng"'

1:31 peregrine81: mikem: I have the lines in my .vimrc and I was under the impression I could start ng and forget it in a screen session

1:31 mikem: peregrine81: I think the files you're editing (and their dependencies) need to be in the classpath, because you end up sending some code to the nailgun server which then compiles and runs said code

1:32 my workflow is starting one ng server per coding session for the project I work on. I don't work for more than one project at one time

1:33 if you work on more than one project at any one time, I imagine it should be OK to launch the nailgun server with a classpath including all your dependencies

2:11 wooby: is there an easy way to write back out as xml the structure that clojure.xml/parse returns?

2:11 hiredman: there is a xml/emit

2:12 but, uh, it is not nice to use

2:14 wooby: hm, looks like it barfs to *out*

2:14 hiredman: right

2:15 wooby: best way to mitigate, run in binding?

2:16 hiredman: ,(doc with-out-string)

2:16 clojurebot: Titim gan éirí ort.

2:17 hiredman: ,(doc with-out-str)

2:17 clojurebot: "([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."

2:17 wooby: oh awesome, thanks man

2:17 hiredman: :/

2:17 wooby: the good almost cancels out the bad

2:17 hiredman: I hope it works for you

2:18 wooby: thanks, about to give it a shot here

2:23 yup, we're cooking

2:23 thanks again

3:04 zmila: if (fun x) returns some transformation or false, is this idiomatic to recieve only not-falsy:

3:04 (filter #(identity %) (map fun some-seq))

3:04 or there is smth more elegant?

3:06 ,(filter #(identity %) (map #(if (even? %) (* % %) false) (range 1 10)))

3:06 clojurebot: (4 16 36 64)

3:08 hiredman: uh

3:08 just identity

3:08 Raynes: (filter identify ..)

3:09 hiredman: or, (remove false? ...)

3:10 zmila: yes! remove false? is the answer, thx hiredman

3:10 Raynes: ,(false? nil)

3:10 clojurebot: false

3:10 noidi: zmila, it's easier and faster to run the filter before the map

3:11 ,(map #(* % %) (filter even? (range 1 10)))

3:11 clojurebot: (4 16 36 64)

3:12 zmila: noidi, my example was wrong. I want to calculate fun x, then check if it is not false and collect only such results

3:12 noidi: ok

3:14 zmila: (remove false? (map #(let [x (* % %)] (if (even? x) x false)) (range 1 10)))

3:24 wooby: i found out about comp the other day, can be useful for stuff like that

3:24 (remove false? (map (comp even? #(* % %)) (range 10)))

3:25 hm, can i use proxy to implement a constructor?

3:27 nevermind

3:31 zmila: comp is good, i've to learn more. but in this example it returns seq of true's :) but not seq of squares

3:33 wooby: ah ;)

3:33 have you gotten into 'for' at all?

3:33 useful for same kinds of things also

3:37 zmila: yes, wooby, i know about (for ). i prefer to use filter/map in first turn, then for, lastly loop/recur :)

3:38 konr: Is there a tutorial or some other resource to shed some light on the error stack?

3:49 zmila: it's hard to read my own clojure code, written a month ago :(

3:50 * zmila is spending whole morning to write comments, arguments and return types, call usages for each function

3:52 esj: zmila - this is the main reason I write tests, so that I can understand later how I intended a function to used :)

3:53 zmila: it's myth about one-liners :)

3:54 one line: for the body, one-two lines: doc about params and return, and one-two more: test or example of use

3:54 esj: you're ahead though

3:54 _ato: yeah, having tests helps a lot. Someone was asking me the other day how some Java code I wrote 2 years ago was supposed to work, it would have taken much longer to figure out without the tests, they made it obvious

3:54 Raynes: Java code!?! Blasphemy.

3:55 _ato: Clojure barely existed at the time

3:57 tomoj: well, you should've simply written clojure yourself

3:57 _ato: having lots of really small functions rather than a few large functions seems to help a lot as well

3:57 zmila: in eclipse i can search for a method's references and see where and how it is used :) and method's signature helps to know what data gets in and out.

3:57 small clojure function is often equivalent to medium java function :)

3:58 esj: Yeah, I'm still getting my head around arranging them all so I don't up with some kinda function confetti

3:59 zmila: even in java i prefer not to write function with more then one cycle. but in clojure one-liner may have two or three map/filter/reduce :)

4:00 _ato: ->> is very nice for that

4:01 I also like to name the map/filter functions if they're any more complex than #(< % 5)

4:02 tomoj: I've noticed that sometimes I want a function that is just like take-while, except it takes one more element (i.e. the first one that doesn't satisfy the predicate)

4:02 or, it takes a predicate which identifies sentinels, then takes everything up to and including the first sentinel it sees

4:03 what I'm look at now is (concat (take-while #(not (= % sentinel)) s) [sentinel])

4:03 which is evil

4:04 esj: tomoj: I've been doing just that...

4:05 zmila: simplicity and conciseness are contagious :)

4:06 _ato: ,(concat (take-while (complement #{0}) [1 2 3 0 1 2 3]) [0])

4:06 clojurebot: (1 2 3 0)

4:06 _ato: hmm

4:15 doseq: _ato: I posted off my contrib agreement yesterday!

4:15 How exciting.

4:18 _ato: doseq: cool. :) now the waiting part. I think Rich checks his mailbox weekly or so. You'll know when he's received it as your name will get added to the contributors page on clojure.org

4:19 doseq: ha, there you are.

4:21 Raynes: I don't have a printer. :(

4:21 Somebody mail me the the CA. ;)

4:52 * raek looks up costs for sending mail to the US

5:23 Raynes: defn: ping

5:54 AWizzArd: ~max people

5:54 clojurebot: max people is 269

6:03 tomoj: it would be cool if we could automatically run the tests contained in old versions against the current version

6:05 e.g. I'm about to tag 1.3.0. the tests have changed a bit since 1.2.3, but the tests that were in 1.X.* for X<3 should still pass against the 1.3.0 src

6:07 bsteuber: tomoj: if you want your old tests to still work, why not leave them in?

6:07 tomoj: well, I probably would do so

6:07 but those tests might have slightly changed

6:08 for introducing new backwards-compatible functionality

6:08 if you always change the tests in such a way that the old behavior is still tested, there's no need, you're right

6:09 but it seems like it might be a valuable sanity check, just to make sure you haven't broken something? not sure

6:09 bsteuber: if you want to be backwards-compatible, it es part of your spec - so you should test it, I'd say

6:10 you can move it to a module like backward-tests

6:10 tomoj: that makes sense

6:11 having tests run that aren't actually in the source code but only in history does seem a bit crazy

6:11 bsteuber: :)

6:38 zmila: how to flatten result of (map fun seq) if fun may return nil, 1 item or list of items?

6:40 Chousuke: make it always return a list of items and use mapcat

6:40 (or nil, of course)

6:45 tomoj: there's a java class Coordinate with a constructor that takes two double arguments

6:46 (Coordinate. 1 1) works fine

6:46 how?

6:46 clojurebot: with style and grace

6:46 tomoj: yes indeed

6:46 clojure's java interop specially checks if a cast can be performed to make the signature match?

6:47 or is this a java thing I don't remember?

6:53 zmila: i'm afraid of mapcat - it seams to be slow

6:56 tomoj: well, it's not lazy, is it

6:56 are you mapping over a lazy seq?

7:00 zmila: i want to calculate count of unique results, so laziness will not help here, does it?

7:01 tomoj: nope

7:01 did you make the function always return a seq or nil? or still trying to find a way where it can return non-seqs?

7:03 I wonder how (apply concat) works

7:04 does it realize every mapped value and only then concat them?

7:05 _ato: ,(clojure.contrib.seq-utils/frequencies [:a :a :a :b :b :a :c])

7:05 clojurebot: {:c 1, :b 2, :a 4}

7:05 _ato: zmila: do you mean like that?

7:06 oh wait

7:06 would you answer be 3?

7:06 tomoj: using reduce instead of apply makes it 3.5 times slower for me

7:06 (mapcat, that is)

7:08 zmila: i'll try apply concat

7:08 tomoj: mapcat is apply concat

7:09 (mapcat f xs) == (apply concat (apply map f [xs]))

7:09 so you can save having to apply the map: (apply concat (map f xs)), but it doesn't seem any faster to me

7:16 zmila: i must be ashemed :) just put (println xx) in several end-places, run all in repl, then captured result into text editor, find-removed braces, and put (into #{}), then call count

7:18 tomoj: oh, you wanted to collect it all into a set?

7:18 zmila: i want to calc (count distinct ...)

7:18 tomoj: yeah I think I understand now

7:19 zmila: i have to read some theoretical papers on func-programming with trees.

7:20 lists are ok. but trees - where I have two recursions ... weak point for me

7:21 tomoj: ,(require 'clojure.set)

7:21 clojurebot: nil

7:21 tomoj: ,(clojure.set/union [1 2 3] [3 4 5])

7:21 clojurebot: [1 2 3 3 4 5]

7:21 tomoj: weird

7:22 I wonder what the best way to add the elements of a coll into a set are

7:22 s/are/is/

7:23 ,(apply conj #{} [1 2 3])

7:23 clojurebot: #{1 2 3}

7:23 tomoj: ?

7:24 Chousuke: I'd prefer (into #{} [1 2 3])

7:25 it's shorter, and it uses transients :)

7:25 tomoj: ah, yes

7:26 (defn mapunion [f & colls] (reduce into (cons #{} (apply map f colls))))

7:26 doesn't seem to be much faster than mapcat

7:26 even though mapcat returns duplicates and all in one big seq

7:27 it's doing more work eliminating duplicates, I guess

7:27 Chousuke: I don't think you should use reduce with into

7:27 use apply instead

7:28 that will allow it to use a single transient for the whole operation

7:28 zmila: run time 58 sec, and answer is correct - so now i have 99 problems solved! :) one more until next level :)

7:28 tomoj: (into #{} (apply map f colls)) ?

7:29 er, no

7:29 Chousuke: ,(apply into #{} (map (comp map inc) [[1 2 3] [3 4 5]]))

7:29 clojurebot: java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number

7:29 Chousuke: HMM

7:29 oops

7:29 ,(apply into #{} (map (partial map inc) [[1 2 3] [3 4 5]]))

7:29 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$into

7:30 tomoj: yeah, couldn't figure out what you meant

7:30 Chousuke: oh, it doesn't support more than one collection? :/

7:30 that's a fault if you ask me

7:31 tomoj: we can always (into #{} (mapcat ...))

7:31 but that certainly won't be any faster than mapcat :)

7:31 Chousuke: mapcat shouldn't be slow

7:39 tomoj: https://gist.github.com/bf8f747e4ffa29591665

7:39 using a single transient set and conj! is about the same as mapcat

7:40 even if you call set on what you get back from mapcat

7:40 unless I screwed up

8:40 dgreensp: ,(prn 3)

8:41 clojurebot: 3

8:41 dgreensp: ,(first (for [i (range 10)] (prn i)))

8:41 clojurebot: 0 1 2 3 4 5 6 7 8 9

8:41 dgreensp: why is that not lazy? actually, it is, sometimes (on one machine) but not others, and not here

8:42 _ato: dgreensp: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/

8:42 zmila: ,(first (for [i (range 40)] (prn i)))

8:42 clojurebot: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

8:43 zmila: see chunk-size :)

8:45 dgreensp: ah, thanks; a little creepy but I can kind of see the trade-off

8:45 ,(first (for [i (take 10 (iterate inc 0))] (prn i)))

8:45 clojurebot: 0

8:45 dgreensp: is that guaranteed to work? or will "iterate" become chunked or something?

8:46 heh

8:47 licoresse: .

8:47 dgreensp: it's just that I'd rather not use the "unofficial" drop-into-Java solution from the blog post.

8:51 _ato: I'm not sure

8:51 looks like seq1 still hasn't yet been added to git :(

8:53 SynrG: i have meticulously documented the jline issue i mentioned with clojure-repl on linux the other day here: http://bugs.debian.org/576814

8:53 now, presumably this is an upstream issue and next, the debian maintainer forwards this upstream.

8:55 dgreensp: _ato: actually chunking will work fine here. good to know it's still lazy. thanks

8:56 LauJensen: Hi all - I'm fiddling with clojure.test and wondering about the convention. If I'm using namespace x.y.z, is putting test/x/y/z/test.clj sufficient for lein test to know what to do ? Provided that test.clj has the namespace x.y.z.test

8:57 tomoj: src/x/y/z.clj <-> test/x/y/test/z.clj

8:57 x.y.z <-> x.y.test.z

8:57 esj: yup

8:58 tomoj: that's clojure-test-mode's convention

8:58 _ato: SynrG: in the meantime use rlwrap instead?

8:58 SynrG: rlwrap?

8:58 tomoj: but `lein test` will just run ALL tests, I think

8:58 so you can, I think, use whatever convention you like

8:58 LauJensen: thanks tomoj I'll give it a whirl

8:58 SynrG: ah, a generic thing

8:59 _ato: yeah, uses readline (like bash etc) I think it provides more editing features than jline too

9:01 AWizzArd: When I want to inject some configuration info into my JVM in the call (in emacs) to clojure, should i then do this best via dynamic vars, with the "java -Dproperty=value" option?

9:01 LauJensen: tomoj: So the problem remains, that the test doesnt run - How do you troubleshoot that in a sane way ?

9:02 SynrG: _ato: reverse incremental search is one i rely on heavily

9:02 tomoj: how are you defining the tests?

9:02 _ato: rlwrap certainly does that

9:02 and history saving

9:02 LauJensen: tomoj: deftest/testing/is

9:02 chouser: and tab completion

9:03 tomoj: hmm.. deftest should certainly work

9:03 esj: LauJensen: the are macro is mega-useful

9:03 LauJensen: esj: Lets look into that once testing actually works/runs :)

9:03 tomoj: It just outputs Total: {}

9:04 SynrG: _ato: jline does history saving

9:04 tomoj: LauJensen: try running `lein test` on a `lein new` skeleton?

9:04 SynrG: tab-completion, ah, nice

9:04 _ato: AWizzArd: that'll only work if you're spawning java from inside emacs -- not when connecting to an remote swank server. But maybe that's okay for use-case?

9:04 your use-case*

9:04 SynrG: so i guess it has some language-awareness somehow?

9:04 AWizzArd: _ato: yes, but anyway, do you have another suggestion?

9:05 tomoj: `lein new foo && cd foo && lein deps && lein test` should give you 1 failure

9:05 AWizzArd: I would just like to inject information into a Clojure during start up.

9:05 LauJensen: tomoj: Runs fine

9:05 chouser: SynrG: well, you can teach it things -- give it a completion file and/or command line options for what defines a "word"

9:05 AWizzArd: In my .emacs I don’t see how I can add command line args, as in swank-clojure-command-line-args, so I thought I could add a -D to swank-clojure-extra-vm-args

9:05 _ato: AWizzArd: if it has to be during startup then yeah, that's probably the best way to do it

9:06 tomoj: LauJensen: hmm.. any weird deps in your project.clj? leiningen stuff maybe?

9:06 LauJensen: No - I'll fiddle, thanks for the help

9:06 chouser: SynrG: I haven't bothered to populate my completiong file yet, but within a single session it learns from expressions you enter and will complete those words later

9:06 tomoj: it should just find every test defined in any clj file under test/, I think

9:09 zakwilson: Haskell's Data.Map has union, intersection and difference functions. I don't see equivalents in the Clojure API. Are they there under different names? They're easy enough to write, but I see no point in reinventing the wheel without cause.

9:11 _ato: ,(clojure.set/union #{1 2} #{2 3})

9:11 clojurebot: #{1 2 3}

9:11 _ato: zakwilson: see http://richhickey.github.com/clojure/clojure.set-api.html

9:12 chouser: zakwilson: those sound like set ops, so I'm not sure how Haskell defines them on maps.

9:12 dgreensp: ,(into {:a 1 :b 2} {:c 3 :d 4})

9:12 clojurebot: {:a 1, :b 2, :c 3, :d 4}

9:12 chouser: ,(apply dissoc {:a 1, :b 2} (keys {:b 2, :c 3})) ; difference?

9:12 clojurebot: {:a 1}

9:12 chouser: ,(select-keys {:a 1, :b 2} (keys {:b 2, :c 3})) ; intersection?

9:12 clojurebot: {:b 2}

9:12 triyo: Whats the most idiomatic way to model data associations in Clojure?

9:12 _ato: ah map.. missed that

9:13 AWizzArd: Is there already a tool, possibly in Contrib, which helps to load config files? I am about to implement a little (load-config) or something like that which will load .clj files to configure computer specific settings.

9:13 tomoj: hmm, I'm confused

9:13 lein says it downloaded clojure-contrib-1.2.0-master-20100122.191106-1.jar from clojars

9:13 SynrG: chouser: ah, nice.

9:14 _ato: AWizzArd: what would such a tool do? isn't loading a clj as configuration just a matter of calling (read ..) on the file?

9:14 triyo: nested maps or some other better suited strategy?

9:14 tomoj: seems like clojars somehow forwards to http://build.clojure.org/releases/org/clojure/clojure-contrib/

9:14 SynrG: oh, and it does paren flashing. super!

9:14 tomoj: but there is no 1.2.0 there

9:14 zakwilson: chouser: they work like the set ops with respect to keys, and prefer the values from the first argument.

9:14 _ato: tomoj: clojars does even trickier stuff than that

9:14 SynrG: submitting this extra info on the bug to use rlwrap as a workaround. thanks, guys

9:15 _ato: it forwards snapshots to http://build.clojure.org/snapshots/

9:15 chouser: SynrG: it has a decent vi-bindings mode too. It's no vim, but better than nothing. :-)

9:15 tomoj: oh, I see

9:15 SynrG: chouser: sure :)

9:15 zakwilson: There are also union/intersection/difference With functions, that take a combination function (usually something like concatenation, addition or subtraction)

9:15 tomoj: I guess my question is then, why is the clojure-contrib snapshot so old?

9:15 chouser: zakwilson: so the expressions dgreensp and I pasted here should get you started

9:15 SynrG: there's a separate debian bug asking for clojure to Recommend jline, so i think I'll cross-reference this bug in that bug ... as this is clearly a superior solution

9:16 psykotic: zakwilson: there's merge, which is like haskell's data.map union. there's also merge-with, which lets you specify how to merge rather than preferring the first unconditionally.

9:16 AWizzArd: _ato: it would look up an environment variable, such as $CONFIG_ID which is maybe set to "ato" on *your* computer. Then when you include the com.company.server namespace in your project, it will have (def *port* 80) as default, but then after all the defs you place a (load-config). And then it looks up *your* specific config file from the repository, for exmaple /hg/clj/configs/ato/com/company/server.clj

9:16 zakwilson: chouser: Yep, those are about what I was looking for. I just wanted to know if I had to write them, or if they had different names.

9:16 AWizzArd: And in your config you have a (def *port* 8080) and other settings for your server, or whatever it is.

9:18 _ato: ah, so per-environment configuration? Ah no I don't think I've seen something that does that, shouldn't be hard to write though.

9:19 AWizzArd: _ato: yes, it’s a simple write

9:19 * fogus playing with jEdit Clojure support

9:19 triyo: ,*clojure-version*

9:19 clojurebot: {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}

9:21 dgreensp: zakwilson: it's kind of jarring coming from Haskell or Scala to find a collections library with no nouns, only verbs, and fewer of those :)

9:24 can I define my own ISeqs?

9:25 chouser: dgreensp: sure, a couple different ways

9:25 dgreensp: (clojure doesn't have interfaces, but doesn't really replace them either, except maybe with multimethods...)

9:25 tomoj: 1.2 does

9:26 chouser: dgreensp: clojure has interfaces, but they're less useful than protocols and multimethods

9:27 dgreensp: are protocols new? I'm working off of 1.1

9:27 chouser: dgreensp: probably the easiest way to provide your own behavior for an ISeq is with 'lazy-seq'

9:27 dgreensp: yes, protocols are in github master, not in an official release yet.

9:27 AWizzArd: dgreensp: https://www.assembla.com/wiki/show/clojure/Protocols

9:27 chouser: dgreensp: but even in 1.1, clojure fully supports Java interfaces

9:28 dgreensp: yeah, though Java interfaces should be treated as for interop only I assume

9:28 I guess ISeqs are a bad example, they are easy to build

9:29 zakwilson: dgreensp: I actually learned Clojure before Haskell, but I haven't used Clojure very much lately.

9:29 dgreensp: what about random-access seqs, like java.util.List or scala's "Seq" class, which have a size and an apply/get method?

9:29 chouser: well, as you say they're not really replaced by anything in 1.1, so they can be useful outside of interop

9:30 dgreensp: I'm actually making a random-access seq right now in some code with a custom backing

9:30 chouser: dgreensp: have you looked at 'proxy'?

9:30 dgreensp: yes, I know a bit about proxy; trying to be idiomatic I guess

9:31 chouser: proxy is the best way to implement interfaces in 1.1

9:31 and it's entirely idiomatic

9:31 dgreensp: ok, though the interface itself is always defined in Java code somewhere...

9:33 chouser: you can defined new interfaces using gen-interface, though you do need to AOT compile that.

9:33 dgreensp: heh, that's cool

9:33 clojure's interop has definitely been thought through

9:33 I'm having a great time with it

9:34 chouser: dgreensp: this story is dramatically improved now in what will become 1.2

9:34 protocols are awesome

9:34 dnolen: *dramatically*

9:37 * dnolen is amazed that his code made elegant with deftype and protocol map/filter is now only a couple of milliseconds slower than ugly type-hinted loop/recur java array crap.

9:44 dgreensp: sweet, looking forward to what's coming in 1.2.

9:48 my initial skepticism about clojure's potential for speed (I've written a lot of tight loops in Java) is subsiding

9:54 dnolen: so after 1 1/2 of Clojure I'm finally starting to look into agents :) So is the difference with send-off/send that send-off creates a thread per agent?

9:54 1 1/2 years

9:54 chouser: dnolen: not necessarily.

9:55 dnolen: the difference is that the number of threads in the send pool is bounded by the number of processor cores, the send-off pool is unbounded.

9:55 dnolen: chouser: I'm using send and it looks like sleeping the thread slows all other agents down.

9:56 chouser: dnolen: right, if your action is constrained by anything other than the CPU (sleeps, IO blocking, etc.) you should use send-off.

9:57 dnolen: chouser: so you're saying that send would use a thread send pool of 2 if I have two cores?

9:57 or just some optimal small number?

9:57 I have 150 agents

9:58 chouser: dnolen: the send pool currently has a max of cpus+2 threads, so 4 in your case. But that's of course an implementation detail that might change.

9:59 the number of agents doesn't matter

9:59 AWizzArd: ,do

9:59 clojurebot: java.lang.Exception: Unable to resolve symbol: do in this context

9:59 AWizzArd: ,(fn [a] do(* 2 a))

9:59 clojurebot: #<sandbox$eval__8370$fn__8372 sandbox$eval__8370$fn__8372@16e1533>

9:59 AWizzArd: ,((fn [a] do(* 2 a)) 100)

9:59 clojurebot: 200

9:59 AWizzArd: why can do be resolved here?

9:59 dnolen: chouser: thx, I now am a little bit closer to understanding agents :)

9:59 Chousuke: it's probably just ignored rather than resolved

10:00 chouser: what matters is what the agents are doing. if the action you want to send will block or sleep, use send-off. If it will just burn cpu (tight loops, math, etc.) use send.

10:00 Chousuke: ,(do do 2)

10:00 clojurebot: java.lang.Exception: Unable to resolve symbol: do in this context

10:00 carkh: ,((fn [a] interleave (*2 a) 100))

10:00 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--8382$fn

10:00 Chousuke: ,(fn [x] do 2)

10:00 clojurebot: #<sandbox$eval__8388$fn__8390 sandbox$eval__8388$fn__8390@218a7f>

10:00 Chousuke: ,(fn [x] foo 2)

10:00 clojurebot: java.lang.Exception: Unable to resolve symbol: foo in this context

10:00 Chousuke: hmm, interesting

10:01 chouser: ,(fn [] do)

10:01 clojurebot: #<sandbox$eval__8398$fn__8400 sandbox$eval__8398$fn__8400@c06cac>

10:01 chouser: ,(fn [] do do)

10:01 clojurebot: java.lang.Exception: Unable to resolve symbol: do in this context

10:01 Chousuke: what does that return?

10:01 ,((fn [] do))

10:01 clojurebot: nil

10:02 Chousuke: that's... rather weird.

10:02 carkh: it isn't

10:03 chouser: ,[do]

10:03 clojurebot: nil

10:03 carkh: special forms are special !

10:03 chouser: ,[do do]

10:03 clojurebot: java.lang.Exception: Unable to resolve symbol: do in this context

10:03 Chousuke: chouser: that definitely is weird

10:03 ,[do 2]

10:03 clojurebot: 2

10:04 Chousuke: :D

10:04 chouser: ha!

10:04 AWizzArd: so, um... don't do that.

10:06 well, there it is. if an "implicit do" starts with the symbol 'do', that symbol is ignored

10:06 stuartsierra: Does Incanter plotting work in headless mode? e.g., to generate PNGs

10:06 liebke: stuartsierra: yes, use the save function on the chart object

10:08 stuartsierra: ok

10:09 One of my students couldn't get it to run on a plain-text SSH session.

10:09 chouser: http://tinyurl.com/ycuz3z5/src/jvm/clojure/lang/Compiler.java#LID4622

10:11 liebke: stuartsierra: I have seen that issue before, when loading incanter.processing, but not with incanter.charts.

10:13 bsteuber: chouser: what is this good for, then?

10:13 stuartsierra: ok, might be because they're just running the uberjar

10:13 liebke: even that shouldn't be an issue, if they are not loading incanter.processing, unless they have a really old version

10:14 stuartsierra: if you use ssh -X when working with Processing, then it should load fine.

10:15 chouser: bsteuber: the 'do' thing? it's just an implementation detail leaking out.

10:15 not to be relied upon

10:16 and is only going to cause problems if you name your own things 'do', which you really really shouldn't do.

10:16 ,(let [do 5] do)

10:16 clojurebot: nil

10:16 stuartsierra: liebke: I told them to download 1.0.0

10:16 Chousuke: that really should fail :/

10:16 with an exception

10:16 chouser: ,(let [do 5] nil do) ; seriously, don't do this

10:16 clojurebot: 5

10:16 liebke: hmm, 1.0.0 shouldn't fail

10:17 bsteuber: chouser: sure, I was just curious :)

10:17 AWizzArd: re

10:17 wthidden: cgrand: thanks for your blog post about flattening reduces I had a chance to use such an idiom today.

10:17 chouser: bsteuber: me too :-)

10:17 AWizzArd: chouser: I don’t want to do that, but in #Clojure.de we just stumbled upon such a piece of code and I was curious why (do do(+ 1 2)) doesn’t work, but the same thing inside a fn does.

10:19 chouser: AWizzArd: well, I explained that. both are unsupported, but only one is caught by the current compiler.

10:19 * AWizzArd was gone for 15 minutes and has to read what was written so far.

10:20 chouser: AWizzArd: http://tinyurl.com/ycuz3z5/src/jvm/clojure/lang/Compiler.java#LID4622

10:20 AWizzArd: if an "implicit do" starts with the symbol 'do', that symbol is ignored

10:21 AWizzArd: chouser: oh good thanks, that is what I was looking for. So, it’s the compiler.

10:22 tomoj: ok, but what about [do 3] ?

10:23 chouser: heh, yeah that's probably something else.

10:23 AWizzArd: oh

10:24 tomoj: I mean, I'd expect [do 3] to be [3], not 3

10:25 Chousuke: it's because the compiler uses RT.first to check for the do symbol

10:25 chouser: or [nil 3] or an error, right.

10:25 Chousuke: ,#{do 3}

10:25 clojurebot: java.lang.Exception: Unable to resolve symbol: do in this context

10:25 Chousuke: ,#{'do 3}

10:25 clojurebot: #{3 do}

10:25 Chousuke: hmm

10:25 ,#{'do 2344}

10:25 clojurebot: #{2344 do}

10:26 Chousuke: ,#{do -1}

10:26 clojurebot: -1

10:26 Chousuke: :P

10:26 AWizzArd: strange

10:26 Chousuke: ,(seq #{do -1})

10:26 clojurebot: java.lang.Exception: Unable to resolve symbol: do in this context

10:26 Chousuke: ,(seq #{'do -1})

10:26 clojurebot: (do -1)

10:27 chouser: Chousuke: I think it's a different issue

10:27 [...] is not an "implicit do"

10:27 but still looking...

10:30 liebke: stuartsierra: I just tested version 1.0 with plain ssh (no -X option), and charts loaded without error (processing, of course, had the usual initialization error). So make sure your student isn't loading processing instead of charts (unless they use ssh -X).

10:33 tomoj: that negative thing is very very odd

10:33 ,#{do -9}

10:33 clojurebot: -9

10:33 tomoj: ,#{do -10}

10:33 clojurebot: -10

10:34 tomoj: actually

10:34 ,#{do -16}

10:34 clojurebot: -16

10:34 tomoj: ,#{do -17}

10:34 clojurebot: java.lang.Exception: Unable to resolve symbol: do in this context

10:34 tomoj: thought it only worked for one-digit negative integers, but no, even weirder...

10:35 npoektop: what's wrong with (:use [com.server.tests.testhelpers :only (run-these-tests)])? when i add this line to ns, it says "at com.server.tests.junit$runtests__1343.invoke(junit.clj:30) [java] at user$eval__1347.invoke(NO_SOURCE_FILE:1)"

10:36 Chousuke: tomoj: it's because the hash codes happen to decide the order

10:37 ,(map #(.hashCode %) '[-17 do -9])

10:37 clojurebot: (-17 -1640328432 -9)

10:37 Chousuke: I suppose that somehow decides the order :/

10:38 tomoj: ahh, I see

10:38 npoektop: and it says [java] Caused by: java.lang.NullPointerException

10:40 tomoj: npoektop: do you have something in testhelpers.clj that calls runtests?

10:41 if you put some code it testhelpers.clj at the top level (not inside defns/etc), it will be run when you try to use the namespace

10:44 npoektop: tomoj, even if i use :only?

10:44 tomoj: yeah, :only doesn't mattter

10:44 the file has to be loaded

10:45 npoektop: and no, no runtests in testhelpers.clj

10:45 tomoj: and when the file is loaded, any top-level code is run

10:45 oh, hmm

10:46 can you paste testhelpers.clj somewhere (e.g. paste.lisp.org)

10:47 AWizzArd: Still, it really does not seem very intuitive with its current behaviour.

10:52 npoektop: tomoj, http://pastebin.com/SJheevSF

10:54 tomoj: well, I don't see any bad toplevel code there

10:54 maybe in one of your other namespaces which is required by testhelpers?

10:55 npoektop: this error is happening when you try to load junit.clj?

11:16 konr: What's the direct translation of pen-width.valueChanged.connect(foo,"setPenWidth(int)")? (.connect (.valueChanged pen-width) foo "setPenWidth(int)")?

11:18 Chousuke: hmm

11:19 I would do (-> pen-width .valueChanged (.connect foo "setPenWidth(int)"))

11:24 konr: much nicer, Chousuke! These arrows seem to be always handy

11:31 shouldn't this thing have a method foo? http://pastebin.com/WHnG4D32

11:36 chouser: konr: proxy can only implement existing methods, not define new ones.

11:37 npoektop: how to splice a vector of args to another function's args? (defn foo [& args] (require _spliced_args_))

11:38 bsteuber: npoektop: apply

11:40 ,(let [myfun (fn [& args] (apply + args))] (myfun 1 2 3 4 5))

11:40 clojurebot: 15

11:41 npoektop: bsteuber, thank you. It's so obvious that i'm confused)

11:41 bsteuber: :)

11:42 stbgz: hello there anybody knows how to change the class path in swank-clojure?

11:43 liwp: stbgz: I just use the swank-clojure-project function and leiningen

11:44 stuartsierra: I use Maven and the clojure:swank goal

11:44 liwp: stbgz: or do you mean after you've launched slime?

11:45 bsteuber: stbgz: there are emacs vars called swank-clojure-classpath and swank-clojure-extra-classpath

11:46 stbgz: well I trying to add a jar to my project but after I run slime I get a ClassNotFound exception when trying to load the classes of the jar, I added swank-clojure-project to my .emacs and still no luck

11:47 bsteuber: swank-clojure-project doesn't belong in the .emacs

11:47 it is meant to be called by hand

11:47 carkh: so who was it that gave the advice to automatically delete trailing spaces when saving in emacs ? verrrrrry bad advice =)

11:48 i have this file with lots of database statements that update the database to match my program version

11:48 and lots of lines are ending with a ","

11:48 which i guess is considered as a white space by clojure mode

11:49 so when i save the file, all my trailing commas are deleted

11:49 stbgz: hmm so load slime and then run swank-clojure-projecct

11:49 ?

11:50 carkh: how would that help ?

11:50 anyways it's too late, i need to go back put all the commas in place and retest the whole thing ='(

11:51 stbgz: what about adding the swank-clojure-classpath and

11:51 swank-clojure-extra-classpath in my .emacs file?

11:51 liwp: stbgz: no, just do M-x swank-clojure-project (requires that you have a leiningen project.clj in your project directory)

11:52 carkh: stbgz: oh sorry i thought you were reacting to my crying

11:52 liwp: stbgz: swank-clojure-project will start slime for you

11:53 stbgz: using swank-clojure-(extra-)classpath is a real pain because you need to edit your .emacs when ever you change the clojure project that you're working with

11:53 carkh: ~seen technomancy

11:53 clojurebot: technomancy was last seen in #clojure, 634 minutes ago saying: I have it under "for later", but if I got a patch for it I would be happy to move it to 1.2.0. =)

11:54 stbgz: I see I was trying to do it without having leiningen around

11:54 bsteuber: stbgz: so swank-clojure-project finds all jar's in your project's lib subfolder

11:54 if you have clojure.jar etc. there, it's fine

11:55 I just set swank-clojure-classpath for setting the version slime uses without projects, when I just want a repl to play

11:55 liwp: stbgz: an alternative is to write a script that calls java for you with an appropriate classpath and then setup swank-clojure to call that script rather than java when you start slime

11:56 stbgz: if you google around for slime / clojure / start script you should be able to find some examples - I've seen some shell scripts and a ruby script IIRC

11:57 but leiningen and swank-clojure-project is definitely the easiest way to get going once you have leiningen running, i.e. you've downloaded all of Internet with maven etc.

11:57 stbgz: I see i was trying to modify the swank-clojure.el but that's not the best idea

11:57 liwp: nope :-)

11:58 stbgz: alright it seems like I'll have to install ant+mave+leinigen

11:58 :S

11:58 liwp: stbgz: enjoy :-/

11:58 stbgz: thanks guys

11:58 cheers

11:59 liwp: np

12:26 underdev: Is there an api index somewhere that has the clojure.core api indexed by... err.. how to say this.. what it's used for?

12:26 i would say function, but that wouldn't make sense in this context :)

12:27 ie namespace functions, collection functions, etc

12:30 ndimiduk: i get an exception when using `lein compile` from (gen-interface :name com.foo.IFoo :methods [[foo [String] "[Ljava.lang.String;"]]).

12:30 Exception in thread "main" java.lang.ClassFormatError: Method "foo"

12:30 in class com/foo/IFoo has illegal signature "L[Ljava/lang/String;;"

12:30 what am i doing wrong?

12:57 how do I specify a native array in a method signature within gen-interface?

12:58 kotarak: "[B;" or so

12:58 ,(class (into-array ["foo"]))

12:58 clojurebot: [Ljava.lang.String;

12:58 ndimiduk: I'd like to return a String[] and using "[Ljava.lang.String;" doesn't work

13:00 kotarak: ndimiduk: can you paste your code?

13:00 ndimiduk: so, I have (gen-interface :name com.foo.Foo :methods [[foo [String] "[Ljava.lang.String;"]])

13:00 kotarak: hmmm

13:00 seems right

13:01 ndimiduk: http://gist.github.com/359131

13:02 oops, that type is not what i ment

13:03 fixed

13:03 yeah, so this doesn't compile. i'm using leiningen

13:04 Exception in thread "main" java.lang.ClassFormatError: Method "foo" in class com/foo/IFoo has illegal signature "L[Ljava/

13:04 lang/String;;"

13:06 looks like clojure.asm.Type/getObjectType() always prepends 'L' and appends ';'

13:06 which is called from clojure.core/generate-interface

13:06 http://github.com/richhickey/clojure/blob/29389970bcd41998359681d9a4a20ee391a1e07c/src/jvm/clojure/asm/Type.java#L270

13:08 http://github.com/richhickey/clojure/blob/1.1.0/src/clj/clojure/genclass.clj#L614

13:08 dnolen: ndimiduk: because the JVM expects that

13:09 ndimiduk: dnolen: in addition to what's provided in "[Ljava.lang.String;"?

13:09 dnolen: because the compiler says "L[Ljava.lang.String;;" is not a valid type specifier

13:10 dnolen: oh, you just joined. the context is http://gist.github.com/359131 won't compile

13:10 dnolen: yeah, I was about to say I think I missed something

13:12 kotarak: ,(clojure.lang.RT/classForName "[Ljava.lang.String;")

13:12 clojurebot: [Ljava.lang.String;

13:12 kotarak: Hmm, it's not possible to inject class into gen-interface, no?

13:13 ndimiduk: kotarak: correct. I tried (type (into-array [""])) instead of the type string. doesn't work.

13:15 chouser: hm, you might try #=(java.lang.Class/forName "[Ljava.lang.String;")

13:16 kotarak: chouser: is there a reason gen-interface does things differently to gen-class?

13:16 ndimiduk: chouser: haha, that works

13:16 kotarak: chouser: the latter basically uses with RT/classForName.

13:17 chouser: sorry, I haven't really looked at this issue

13:17 RT/classForName should work as well. the key is #=()

13:18 kotarak: chouser: I meant that gen-class uses internally RT/classForName to resolve the classes, while gen-interface does not.

13:19 chouser: no, I have no idea.

13:20 kotarak: http://github.com/richhickey/clojure/blob/1.1.0/src/clj/clojure/genclass.clj#L83 vs. http://github.com/richhickey/clojure/blob/1.1.0/src/clj/clojure/genclass.clj#L599

13:20 Maybe this could be unified.

13:21 chouser: gen-interface is largely superceded by definterface

13:21 kotarak: k

13:21 * kotarak never heard of definterface before.

13:22 chouser: it has classloader magic that lets you redefine existing interfaces.

13:23 kotarak: oh, ah, "here be dragons"?

13:23 The-Kenny: Wasn't "here be dragons" the slogan of the latest chaos communication congress in berlin?

13:23 chouser: hm, pretty sure it's good magic

13:24 stuartsierra: What's the goal of definterface vis-a-vis defprotocol?

13:25 fogus: primitives

13:25 kotarak: I would suspect host interaction

13:25 chouser: you both beat me to it. I think those are the two benefits currently. Dunno how either of them stand up long-term

13:26 defprotocol already creates a same-named host interface if you AOT

13:26 and I imagine defprotocol eventually will support the same primitives supported by fn

13:28 ndimiduk: def{interface,protocol} are in 1.2, yes? should i be using that api instead?

13:28 i've been working with clojure-1.1.0 because contrib is stable along side it.

13:30 fogus: I know that Clojure macros tend to have implicit pairs (i.e. cond case etc...) and I know how to write a macro that handles them (i.e. partition 2) but what about on the other hand if we are writing a macro to build the implicit pairs? I currently have an aux function that returns ((:a 1) (:b 2)) and have only been able to have success doing ~@(flatten the-pairs). Seems like there is a better way

13:30 * fogus wonders if that makes any sense

13:31 chouser: I've used (apply concat the-pairs)

13:31 * fogus trying

13:32 kotarak: ,(apply concat [[1 2] [3 4]])

13:32 clojurebot: (1 2 3 4)

13:32 fogus: chouser: That's perfect! Now I can avoid defining flatten

13:33 kotarak: ,(mapcat identity [[1 2] [3 4]])

13:33 clojurebot: (1 2 3 4)

13:33 fogus: chouser: thanks. You should write a book or something

13:33 chouser: other times it's useful to treat the seq of firsts and seconds separately, in which case interleave is handy

13:34 fogus: you mean instead of frittering away my time answering questions here, don't you. ;-)

13:34 fogus: kotarak: Thanks.

13:35 dnolen: ndimiduk: I use clojure 1.2.0 and contrib 1.2.0 they "seem" ok . it's might be little a bit of a workflow hassle (if you use lein or something) but it's worth it I think.

13:35 kotarak: fogus: many ways to Rome - eh - flattened lists. ;)

13:36 fogus: chouser: Thanks. In this case the flatten is the answer, but what case do you see for treating them differently?

13:36 kotarak: Seems I need to study up on the fine art of flattening

13:37 kotarak: fogus: and then maybe write a book about it. ;)

13:37 * fogus ponders "The Joy of Flattening"

13:38 dakrone: "Flattening will get you everywhere"

13:39 oh wait, maybe that's Flattery

13:39 kotarak: Flatten in Action, Pragmatic Flattening, The Art of List Flattening (the 5 Volume version), ...

13:39 fogus: Head First Flattening

13:39 stuartsierra: fogus: I like Head First Flattening.

13:39 dakrone: Learn to Flatten in 21 days

13:39 kotarak: Touch yourself flattening in fixnum days

13:40 Teach

13:40 fogus: stuartsierra: sounds painful. ;-)

13:40 stuartsierra: yes

13:40 fogus: I've been waiting 2 days to say that

13:40 stuartsierra: :)

13:42 kotarak: If I set System.in to something else... will it automagically picked by

13:42 *in*?

13:42 stuartsierra: I don't think so

13:42 kotarak: geez

13:44 stuartsierra: *in* is a Var in its own right, not identical to System.in

13:44 fogus: Almost perfect... Just need to find a way to get rid of that ~~x

14:01 maacl: Is there an elegant way to interact with Java lists that only implement get() and size() methods?

14:02 kotarak: maacl: define a seq on them

14:03 maacl: So implement first rest and cons?

14:03 hiredman: how is that a list?

14:04 maacl: hiredman: It is quite strange but that is what several of the classes in the XOM library looks like.

14:04 They call them lists, but I would tend to agree with you.

14:05 hiredman: (map #(.get LIST %) (range (.size LIST)))

14:05 or (take (.size LIST) (repeatedly #(.get LIST)))

14:06 maacl: ah

14:06 chouser: I've used map like that a few times

14:06 slyphon: number of elements in a seq?

14:07 * slyphon is blanking

14:07 chouser: slyphon: count

14:07 slyphon: ty

14:07 chouser: but that's O(n) on a seq -- forces the whole thing

14:07 slyphon: yeah, that's ok in this situation

14:09 maacl: thanks - that will make it less painful

14:21 Licenser: doseq: I read about your idea I've something to look at for you

15:41 slyphon: is it possible to run a single deftest?

15:45 zaphar_ps: slyphon:in emacs M-x clojure-test-run-test while on the deftest form to run

15:45 slyphon: oh sweet

15:45 zaphar_ps: or is it clojure-test-runtest?

15:45 can't remember off hand

15:45 slyphon: hmm

15:46 that seems like it doesn't run fixtures

15:46 zaphar_ps: slyphon: yeah it probably doesn't

15:46 slyphon: eh, w/e

15:46 * slyphon will find some way around it

15:46 slyphon: zaphar_ps: thanks

15:47 zaphar_ps: there is a clojure.test/runtest also I believe haven't really used it though

15:47 slyphon: hrm

15:47 * slyphon looks

15:47 slyphon: i thought it was only "run-tests"

15:48 carkh: just run it as a function with no parameters

15:48 slyphon: run which?

15:48 the deftest?

15:48 carkh: yes

15:48 slyphon: oh

15:48 * slyphon tries that

15:48 carkh: (test-id-seq-update)

15:48 slyphon: oh, good call

15:48 zaphar_ps: carkh: does that run the fixtures as well?

15:48 slyphon: :)

15:49 yeah, apparently it does

15:49 oh wait

15:49 carkh: zaphar_ps: i really don't know =P

15:49 slyphon: no

15:49 it don't

15:49 zaphar_ps: cause I thought the emacs one just did that

15:49 slyphon: s'ok

15:49 zaphar_ps: yeah

15:49 you can always run the fixtures manually

15:49 slyphon: yeah, i have a macro i can wrap the body of the test with

16:05 * licoresse waiting, what feels like forever, on the MEAP update of Joy of Clojure

16:08 chouser: they say it's "in production", though I'm not exactly sure what that means.

16:09 LauJensen: chouser: That probably means that they are cleaning out your typos

16:09 chouser: hopefully

16:10 LauJensen: Did you write your part in Vim by any chance ? :)

16:10 chouser: of course

16:10 am writing

16:10 LauJensen: ok, and ehm.. I'm guessing no spelling correction in Vim?

16:10 carkh: ah damn you're not chouser anymore but c-houser =/

16:11 LauJensen: carkh: You thought he was chinese too ?

16:11 carkh: nah just thought he was very picky !

16:22 shales: hi, I'm trying to setup a google appengine project with clojure and maven

16:23 specifically trying to get the make changes <-> see results loop nice and tight

16:25 I've got the clj source files in layed out like a war and am running the appengine devserver directly from that so I can see changes by just reloading the browser

16:26 but for this to work, whenever I require a namespace it also needs to :reload

16:27 Is there a better way to handle this than putting :reload everywhere? Is having all of these reloads in a deployed app even a bad idea?

16:27 chouser: you can do a single :reload-all at the top

16:28 shales: oh, yeah. perfect. thanks!

16:29 I think I read that, but then totally forgot about it

16:31 slyphon: is there something in contrib that will diff two hashes?

16:31 er, hash-maps

16:31 and return just the differences?

16:32 chouser: just diffs among keys, or values also? recursively?

16:32 slyphon: well, in this case it's a flat hash-map

16:33 * slyphon starts over, describing the use-case

16:33 slyphon: in my code, i return a db row, and stash a copy of the original hash in the metadata, when that "row" is altered, and then used as the argument to my "update" function, i want to only update the cols that have changed

16:34 chouser: ah, so the keys are the same? you want a list of keys for which the values are different?

16:34 slyphon: yeah, that sounds right

16:36 i mean, i could probably write a for statement that does it, but i wanted to see if there were something clever that already existed

16:36 chouser: I don't know of such a thing.

16:36 slyphon: ok :)

16:36 chouser: ,(let [oldm {:a 1 :b 2} newm {:a 1 :b 3}] (remove #(= (oldm %) (newm %)) (keys oldm)))

16:36 clojurebot: (:b)

16:36 slyphon: oooh

16:36 nice

16:36 chouser: ty

16:49 hrm

16:49 if-let would be more useful it seems if it had an alternative 'else' value

16:57 kotarak: slyphon: like (let [foo (or if-let-clause else-value)] ....)?

16:57 drewr: ,(deftype Foo [] IPersistentMap) (merge {} (Foo))

16:57 clojurebot: DENIED

16:57 slyphon: kotarak: something like that

16:58 i guess it's intended to be used in specific situations

16:59 it'd kind of behave like 'get' with the alternative value

17:00 kotarak: slyphon: it's called "or", no?

17:00 slyphon: heh, i guess it is

17:00 Borkdude: if you would have kotarak's one, why not just use an if inside a let?

17:00 slyphon: well, that's what i've been doing

17:01 kotarak: slyphon: (if-let [foo (bla) hypothetical-else] ...) <=> (let [foo (or (bla) not-so-hypothetical-else)] ...)

17:01 slyphon: yeah, i guess i wasn't thinking very creatively about it

17:04 kotarak: i guess it's that if say, i'm using if-let to avoid some computation in the case that the test is logical false, then the (or) doesn't really help me, as the body of the if-let will still be evaluated

17:04 it's more (or (if-let [...) alternative)

17:05 kotarak: slyphon: ??? I don't get what you want to do. (or (if-let ...) alternative) is equivalent to (if-let [..] (bla) alternative)

17:06 slyphon: more or less

17:06 slyphon: maybe i don't understand if-let

17:07 the first binding *is* the test, no?

17:07 oh, hrm

17:08 kotarak: slyphon: (if-let [local (test)] (logical-true-branch might use local) (logical-false-branch))

17:08 slyphon: kotarak: ok, i didn't know there were two forms

17:08 like with 'if'

17:08 kotarak: slyphon: well, it's called if

17:08 slyphon: hah

17:08 true

17:08 kotarak: slyphon: there is also when-let

17:08 Borkdude: ,(doc if-let)

17:08 clojurebot: "([bindings then] [bindings then else & oldform]); bindings => binding-form test If test is true, evaluates then with binding-form bound to the value of test, if not, yields else"

17:08 Borkdude: might want to read that ;)

17:08 kotarak: slyphon: which is called when

17:09 slyphon: i need toi-let

17:09 slyphon_away: ;)

17:12 bitti: hm

17:12 (defn hash-map

17:12 "keyval => key val

17:12 Returns a new hash map with supplied mappings."

17:12 ([] {})

17:13 ([& keyvals]

17:13 (. clojure.lang.PersistentHashMap (create keyvals))))

17:13

17:13 (defn hash-set

17:13 "Returns a new hash set with supplied keys."

17:13 ([] #{})

17:13 ([& keys]

17:13 (clojure.lang.PersistentHashSet/create keys)))

17:13 why sometimes the . syntax and then the / syntax for static method calls are employed?

17:13 just a inconsistence?

17:14 kotarak: bitti: old code is not changed. only in case of a patch. new code uses / syntax

17:14 _ato: / is newer and didn't used to exist

17:14 bitti: ic

17:15 but a patch has to be a fix? there are no consistency patches?

17:16 kotarak: bitti: yes. only fixes. consistency patches don't help anything, just bear the risk of introducing new bugs.

17:17 The-Kenny: Isn't / just for static methods and . for "methods"?

17:18 bitti: kotarak: yeah, that's why many projects never get refactored...

17:18 kotarak: bitti: consistency != refactoring

17:18 The-Kenny: (. SomeClass (staticMethod)) is the ancient way

17:19 The-Kenny: kotarak: Oh ok

17:19 Borkdude: The-Kenny, in the first example create is also a static method

17:21 bitti: kotarak: yeah it isn't refactoring, it's a kind of refactoring.

17:21 even a simple thing like rename is a kind of refactoring

17:24 * avar posted how to get slime + clojure to work without elpa: http://avar.posterous.com/ (also on the list)

17:26 lancepantz: is it possible to destructure mutlidimensional data structures?

17:26 like {:foo {:bar "a" :baz "b"}}, can i bind to baz?

17:27 kotarak: ,(let [[[a b] c] [[1 2] 3]] (vector a b c))

17:27 clojurebot: [1 2 3]

17:28 lancepantz: what about with maps?

17:28 kotarak: hmm let's see

17:29 ,(let [{:a {:b b :c c} :d d} {:a {:b 1 :c 2} :d 3}] (vector b c d))

17:29 clojurebot: java.lang.Exception: Unsupported binding form: :a

17:31 kotarak: ,(let [{{b :b c :c} :a d :d} {:a {:b 1 2} :d 3}] (vector b c d))

17:31 clojurebot: 3

17:31 kotarak: 3?

17:31 lancepantz: hahaha

17:31 that's what i said

17:31 drewr: I thought this was supposed to be working now http://gist.github.com/359487

17:31 hiredman: ,(let [{{baz :baz} :foo} {:foo {:bar "a" :baz "b"}}] baz)

17:31 clojurebot: "b"

17:32 lancepantz: there we go

17:32 thanks hiredman

17:32 kotarak: ,(let [{{b :b c :c} :a d :d} {:a {:b 1 :c 2} :d 3}] (vector b c d))

17:32 clojurebot: [1 2 3]

17:32 kotarak: Stupid cut'n'paste bug.

17:32 lancepantz: that helps, thanks guys

17:33 i think we're kinda thin on destructuring documentation

17:33 kotarak: lancepantz: well the recursive thing is described on clojure.org/special_forms

17:34 Borkdude: it would be useful if the api had examples

17:34 bitti: surely lot's of irc/erc users here. no?

17:34 who do you avoid smiley parsing in s-expr?

17:35 s/who/how/

17:35 licoresse: in colloquy?

17:36 Borkdude: smiley parsing? the repl isn't an instant messaging program? ;)

17:37 bitti: Borkdude: sure, but this channel has a lot of s-expr

17:37 Borkdude: bitti: clojurebot is activated by a preceding comma

17:37 licoresse: bitti: check with your client

17:37 Borkdude: ah you mean that

17:37 gtg

17:38 bitti: seems he didn't know a solution...

17:38 _ato: bitti: simply don't enable the erc smiley module?

17:38 it's off by default isn't it?

17:38 licoresse: so bitti is using erc

17:39 bitti: I just try. I used to use irc, was enough for me

17:44 carkh: bitti: emacs currently comes with rcirc, very easy to use

17:47 bitti: carkh: yeah, that's what i meant, irc is just an alias for rcirc in emacs

17:48 carkh: but no matter how easy it is, I need my smileys, but not in s-expr

17:48 carkh: the smiley thing doesn't come preconfigure, you probably added a script to your .emacs

17:48 ohhh i see

17:49 well you need to check your added script and modify it =P

17:50 tho smiling sexps must be sexxy =)

17:50 bitti: ok, I may try to adopt all the smiley regexps :/

17:51 carkh: clojurebot: clojure is also making your sexp smile

17:51 clojurebot: You don't have to tell me twice.

17:57 brian__: noob question> I want to send a number value in a multimethod, something like (defmethod count-cat [:toys :set] [category action value] (prn value))

17:58 then (count-cat {:category :toys} {:action :set} 10) , but doesnt work

17:59 carkh: what's your defmulti looking like ?

18:00 brian__: (defmulti count-cat (fn [c a v] [(:category c)(:action a)(v)]))

18:01 carkh: remove the (v) from the body

18:01 brian__: ok

18:02 whats the body?

18:02 carkh: make it look like that : (defmulti count-cat (fn [c a v] [(:category c)(:action a)]))

18:03 brian__: ok, thnks

18:03 carkh: don't forget to recompile the defmethod after this

18:03 brian__: ok

18:04 dakrone: alright, need some parsing advice

18:04 what would be the best way to accomplish this transformation: http://pastebin.com/f5gX4TbZ

18:04 keeping a stack seems like a reasonable way, but not easy to do in Clojure

18:06 tomoj: how would you generate matrices like [[1 2 3] [8 9 4] [7 6 5]] (i.e. (iterate inc 1) spiraling around the matrix) in clojure?

18:06 carkh: dakrone: can't you just use the normal call stack you get when calling functions ?

18:06 licoresse: partition?

18:06 tomoj: I can think of one way by threading a set through, but that seems too much like the imperative version to me :(

18:07 dakrone: carkh: what do you mean?

18:08 carkh: dakrone: just recursively call the same transforming function

18:08 when it's comes back from the recursive call, that's like a pop

18:08 dakrone: I'm just not really sure how to keep that all in a struct sort of structure

18:09 carkh: if the goal is only to make the transformation you're showing there, that's a very easy function to write

18:09 dakrone: tomoj: (map #(into [] %) (partition 3 (take 9 (iterate inc 1))))

18:09 ,(map #(into [] %) (partition 3 (take 9 (iterate inc 1))))

18:09 clojurebot: ([1 2 3] [4 5 6] [7 8 9])

18:10 tomoj: dyslexic? :P

18:10 dakrone: tomoj: ah yea, a bit :P

18:10 Chousuke: dakrone: map vec instead :P

18:11 tomoj: like this https://gist.github.com/c0657ce9ce2850c9bb25

18:13 dakrone: ahh yea, that's much more difficult

18:14 Raynes: Anyone have the link to that Clojure for Lisp programmers transcript handy?

18:17 carkh: dakrone: : check this http://pastebin.com/HPsRy8yu

18:18 not exactly what you asked, but pretty close

18:19 * dakrone tries to grok

18:20 dakrone: carkh: that's really cool, never used ` and ~ outside of a macro

18:20 carkh: ah my bad, makes it harder to understand =/

18:21 dakrone: it's not bad, it just never occurred to me to use them outside of a macro

18:22 carkh: i think you should use maps : instead of (:tag symbol :chunk ...) have {:tag symbol :chunk ..}

18:23 that's more clojuresque

18:23 also the chunk part should always be a sequence, not sometimes a sequence and other times the sub-chunk itself

18:25 dakrone: having a hard time trying to figure out how to get it run through the function, it comes out as a string "(TOP (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN sentence))) (. .)))"

18:26 (eval (str "(tb '" str ")")) doesn't do the trick

18:26 carkh: ,(read-string "(TOP (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN sentence))) (. .)))")

18:26 clojurebot: (TOP (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN sentence))) (. .)))

18:27 carkh: you're using some natural language processing library ?

18:27 dakrone: yes

18:27 opennlp

18:27 carkh: nice =)

18:27 dakrone: unfortunately they keep all the actual tree structure for this private, so instead I'm trying to parse the string output

18:28 ahh, there we go, (tr (read-string (.toString sb))) did the trick

18:28 carkh: nice =)

18:28 dakrone: that's awesome, thank you very much carkh :)

18:28 I'll credit you in the source

18:29 carkh: hehe no need

18:29 dakrone: on the same note, there isn't an easy way to bypass the private var restriction for java classes in clojure, is there?

18:30 that'd make this much better than attempting to parse a string

18:30 maxhodak: is it possible to access a password-protected maven repository using lein?

18:30 Chousuke: dakrone: make sure the string form of the structure always makes sense if parsed as a clojure structure.

18:31 dakrone: Chousuke: you mean, a valid s-exp?

18:31 Chousuke: dakrone: I guess so

18:31 dakrone: it does look like it's designed to be one

18:31 dakrone: yea, it does, but I'll write tests to make sure

18:32 maxhodak: technomancy|away:

18:32 Chousuke: things like apostrophes or double quotes could result in something unexpected

18:32 dakrone: hmm.. good point, that would throw things off

18:32 Chousuke: or the # character :P

18:34 carkh: ah true, you might want to use a real parser

18:35 like fnparse from joshua choi

18:36 Chousuke: in common lisp you'd probably customise the reader to treat ' as a symbol character and have it produce |it's| or something for things with apostrophes but Clojure unfortunately is not so flexible :P

18:37 carkh: well the parsed languae looks quite regular so it should be easy to parse

18:37 or you could search and replace special cases beforehand

18:37 Chousuke: though I'm sure no-one would mind an extensible reader, as long as it's done sanely.

18:38 carkh: Chousuke: you think CL's reader is not sane ?

18:38 Chousuke: carkh: well, reader macros don't compose very well

18:39 carkh: how would you do it so they're composable ? looks like a difficult task

18:39 Chousuke: indeed.

18:39 carkh: i used reader macros maybe twice

18:40 Chousuke: I kind of like the scheme approach to reader macros; at least as far as I understand it

18:40 carkh: ah i never played with any scheme

18:40 besides this one ><

18:40 Chousuke: At least PLT scheme has a #lang pragma that lets you change the language on the fly

18:41 between, say, various standard revisions or typed scheme for example

18:41 It's probably not ideal, or even a complete solution, but something similar could work

18:42 carkh: i guess reader macros would be saner with a lexical scope

18:42 Chousuke: perhaps

18:43 carkh: that would reove a whole bunch of composability issues

18:43 remove*

18:44 Chousuke: however, the bigger issue probably is that you could end up with everyone creating all kinds of weird mini languages bearing little resemblance to plain Clojure

18:44 carkh: ah true, i hated cl-sql for that

18:45 not quite sure on the name of that library anymore =/

18:45 dakrone: how badly-frowned-upon would be doing something like this: http://tutorials.jenkov.com/java-reflection/private-fields-and-methods.html ?

18:46 Chousuke: though I would err on the side of optimism in this case. ;P The Clojure community tends to listen to Rich and if he says people shouldn't go crazy with reader mods (assuming they become possible someday in the first place) then I think most people would listen

18:48 carkh: dakrone: in the long run i think you're better off doing the work to do thing the good way

18:49 dakrone: okay, I'll do it that way, I'll check out fnparse too

18:49 carkh: there might also be some other library that does parsing for you presenting a "DOM" of some kind

18:49 tomoj: Chousuke: weird mini-languages is an issue? :P

18:50 carkh: haha who doesn't love CL's loop macro ?

18:50 Chousuke: tomoj: I think fear of fragmentation and lack of composability are the primary reasons why Clojure's reader is not extensible.

18:50 and that it's written in Java, but that's another thing entirely. :P

18:51 dnolen: anyone know how to constrain the amount of RAM swank-clojure-project starts the REPL with?

18:51 Chousuke: there was some parameter to specify jvm args

18:51 The-Kenny: dnolen: There's some variable "swank-clojure-extra-jvm-args" or so in swank-clojure.el

18:52 Chousuke: pass -Xmx64m or something to the jvm

18:52 dnolen: The-Kenny: yeah I've set that doesn't seem to do any good.

18:52 Chousuke: mx is max heap and ms is minimum heap (initial allocation) I think

18:53 carkh: i found it pretty hard to change the startup of swank-clojure, eventually i set it to run a batch file, and create it on the fly before starting slime

18:53 The-Kenny: dnolen: After taking a look, setting "swank-clojure-extra-vm-args" to some list should work. It's used in swank-clojure-project

18:53 dnolen: lein swank works fine, the proper JVM settings. it's just swank-clojure-project that's giving me a headache.

18:54 Chousuke: swank-clojure-project might be overriding your settings ;P

19:07 tomoj: ,(class (rationalize 1))

19:07 clojurebot: java.lang.Integer

19:18 tomoj: ,(letfn [(ratio [x y] (clojure.lang.Ratio. (bigint x) (bigint y)))] (= (ratio 0 1) (ratio 0 2)))

19:18 clojurebot: false

19:18 tomoj: :D

19:19 hmm, that is strange

19:21 the identity on clojure.lang.Ratio under addition is not unique...

19:22 _ato: ,(= 0/1 0/2)

19:22 clojurebot: true

19:22 _ato: ,(class 0/1)

19:22 clojurebot: java.lang.Integer

19:22 _ato: ah

19:23 ,(= 1/3 9/3)

19:23 clojurebot: false

19:23 _ato: ,(= 1/3 3/9)

19:23 clojurebot: true

19:23 tomoj: _ato: those Ratios aren't accessible with / or with the x/y syntax, it seems

19:23 just an oddity of the java class

19:24 _ato: ah

19:24 yeah

19:24 the constructor just sets the numerator and denominator, it doesn't do any normalisation

19:24 tomoj: challenge: create a lazy seq of all rational numbers in as few lines as possible

19:24 this is what I decided to do instead of real work

19:24 but I could only get it with 34 ugly lines

19:24 https://gist.github.com/f26c30ababa4437404ab

19:25 (I left out 0)

19:25 (and the negatives...)

19:25 _ato: ,(bigint (/ 1000000000000000000000000000 3))

19:25 clojurebot: java.lang.ExceptionInInitializerError

19:41 * slyphon mails the maven inventor a flaming-bag-of-dog-poop

19:45 slyphon: argh

19:46 can you publish multiple jars as part of a single pom.xml

19:46 ?

19:46 technomancy: slyphon: I think there's a plugin to do that

19:46 slyphon: yeah?

19:46 technomancy: the dog poop mailing, I mean

19:46 slyphon: hahahahaha

19:46 wow, leiningen is the answer to *everything*!

19:47 i'm trying to package up the redstone-xmlrpc lib, and i'm finding myself full of hate

19:49 carkh: technomancy: may i take a minute of your time ?

19:50 Licenser: _ato: clojurebot does not like big nubers

19:57 technomancy: carkh: sure; for something quick

19:58 carkh: ok quickly then : i think you'e maintaining clojure-mode right now, is that correct ?

19:59 i've been adding a hook to my .emcs to delete trailing white spaces from my saved files

19:59 and it looks like this removes commas from clojure files when saving

19:59 technomancy: yeah, that's a bug; not sure how to get it to preserve commas inside strings and comments

19:59 carkh: my guess is that clojure-mode somehow tells emacs that commas are white space as they are for clojure

19:59 technomancy: deleting trailing whitespace in a hook is pretty dangerous though

20:00 well dangerous is a strong word

20:00 but having changes applied to a file without your active involvement is iffy

20:00 slyphon: yeah

20:00 "WTF happened?!"

20:01 carkh: well i just wanted to make you aware of that, looks like you already know about it

20:03 technomancy: yeah, thanks

21:30 defn: Hey all

21:30 doseq: Hey.

21:30 defn: I have some thoughts on how I might achieve this but I thought I'd ask people smarter than me first:

21:31 Given: (some really long sexp (with nested (forms)))

21:31 How would you go about intelligently indenting that

21:31 programatically, I mean

21:32 regex? a parser? is there some easy logic I'm missing?

21:34 carkh: by using clojure.contrib.pprint maybe ?

21:34 defn: carkh: huh, didn't even consider that

21:34 that will print long sexps nicely?

21:34 carkh: it never is as nice as hand-crafted, but it does the job, yes

21:35 defn: carkh: im very grateful for the suggestion -- this looks like a "good enough" way to go for the time being

21:35 thank you

21:35 carkh: =)

21:45 Licenser: hi defn how is walton going?

21:45 defn: carkh: were you thinking pprint-simple-code-list?

21:46 carkh: was wondering if you had a pprint/* fn in mind

21:47 Raynes: Licenser: I added some new functions last night. Got A through C from the Clojure API. I'm getting there, slowly but surely. :p

21:47 Licenser: hi raek :)

21:47 erm Raynes narf, silly tab compleatiion. And yes i saw it, great work!

21:47 carkh: ,(clojure.contrib.pprint/pprint '(:a "blahblah"))

21:47 clojurebot: (:a "blahblah")

21:48 Raynes: Hehe.

21:53 tomoj: Raynes: what adding do you have to do?

21:53 I thought it was supposed to be automatic

21:54 Raynes: tomoj: clj-sandbox, not walton

21:54 Licenser: point of clj-snadbox is not being automatic ;)

21:54 tomoj: oh, I misread something someone said

21:54 have to go through and whitelist them?

21:54 Raynes: Indeed.

21:55 My goal is to go through the entire clojure core API.

21:55 Not that difficult.

21:55 Just lazy. :p

21:55 tomoj: sounds like a lot of work to me

21:55 would be cool if they were grouped

21:56 I mean presumably the whitelist will be configurable, right?

21:56 so you could group them into related sets and enable/disable certain chunks of clojure

21:56 _ato: tomoj: http://github.com/Licenser/clj-sandbox/blob/master/src/net/licenser/sandbox/safe_fns.clj

21:57 tomoj: awesome

21:58 Licenser: *snickers*

21:58 slyphon: hrm, is there some debugging hook on the server side for swank? evaluating a function consistently just aborts, but there's no error in the logs or on stdout or anything

21:59 defn: (inc Licenser)

21:59 Licenses: great now I've a silly name

21:59 slyphon: hah!

22:00 Licenses: cleva!

22:00 * Licenses bows

22:00 Licenses: I'm just glad that he didn't do something lie (sqrt defn)

22:00 slyphon: hahaha

22:00 Licenses: thatd'b e a pain!

22:00 slyphon: srsly

22:00 first you'd have to figure out what Locale he was in

22:01 Licenses: nah I go with ASCII

22:01 slyphon: :)

22:01 Licenses: so for defn it'd not eben be that hard I'ts only 4 byte

22:02 on the other hand it is more a logical problem then a mathematical one

22:02 since I would expect to work over the letters a-z and A-Z not over their number representations in the charset

22:02 slyphon: sure, just make it complicated

22:02 Licenses: nah it's not so complicated it is as complicated as binary

22:03 just a different base

22:03 defn: cleva?

22:03 slyphon: "clever"

22:03 but with a colloquial twang

22:03 defn: ah

22:03 sorry im lagging a bit

22:03 slyphon: heh

22:05 Licenses: hmm so base 51

22:06 defn: the best base I think

22:06 better than 47, anyway

22:06 carkh: the most natural for licenser incrementation

22:06 defn: incrimination or incrementation?

22:07 carkh: for basic incrimination we can go with all good base 47

22:07 we might get more digits that way =P

22:08 Raynes: Is there a function just for discarding output? Like, a function that takes anything and returns nil?

22:09 hiredman: ,((constantly nil) 1 2 3 4)

22:09 clojurebot: nil

22:09 Raynes: Thank you.

22:10 tomoj: 51?

22:10 your alphabet has 25.5 letters in it?

22:11 hiredman: j is barely even a letter

22:11 tomoj: oh, I see

22:12 wait, nevermind, I don't see

22:12 hiredman: http://en.wikipedia.org/wiki/J a johnny come lately to the alphabet

22:12 tomoj: base n has n different symbols

22:12 no?

22:13 _ato: ,(let [bb (java.nio.ByteBuffer/wrap (.getBytes "defn")), i (int (Math/sqrt (.getInt bb)))] (.clear bb)(.putInt bb i)(String. (.array bb) 2 2))

22:13 clojurebot: "�Q"

22:13 defn: how to convert "(1 2 3)" to '(1 2 3)?

22:13 hiredman:

22:14 defn: hiredman: silly questiopn?

22:14 _ato: ,(doc read-string)

22:14 clojurebot: "([s]); Reads one object from the string s"

22:14 defn: question*

22:14 hiredman: are you sure you want '(1 2 3)?

22:14 _ato: well he would have to cons 'quote on afterwards

22:14 defn: (1 2 3), i suppose

22:15 the ultimate destination would be the quoted form

22:15 but the intermediary step i guess is what i was looking for

22:15 _ato: ,(= (read-string "(1 2 3)") '(1 2 3))

22:15 clojurebot: true

22:15 hiredman: '(1 2 3) is an illusion

22:15 defn: _ato: thanks much

22:15 hiredman: ,(macroexpand ''(1 2 3))

22:15 clojurebot: (quote (1 2 3))

22:15 _ato: ,(read-string "'(1 2 3)")

22:15 clojurebot: (quote (1 2 3))

22:15 hiredman: well

22:15 ,''(1 2 3)

22:15 clojurebot: (quote (1 2 3))

22:25 dcnstrct: I can't figure it out... last night swank-clojure-project was respecting my (.getResourceAsStream (clojure.lang.RT/baseLoader) "src/myproj/whatever.js")

22:25 but tonight it stopped working

22:25 and no code has changed I simply restarte emacs

22:26 ,(.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/xml.clj")

22:29 _ato: dcnstrct: the path shouldn't start with src/ unless you have this file under myproj/src/src/myproj/whatever

22:30 dcnstrct: wow that was it

22:30 maybe last night I started swank-clojure-project in the wrong directory or something

22:30 who knows... but that works.. thanks

22:30 tomoj: I think you can put them in resources/ too?

22:30 dcnstrct: thats probably a much better idea actually.. keep it tidy

22:31 tomoj: I still don't really understand how to stick stuff in there and give http access to it without security problems

22:33 dcnstrct: (GET "/loading.gif" (.getResourceAsStream (clojure.lang.RT/baseLoader) "src/bots/pva/loading.gif"))

22:33 I don't care if hackers steal my loading indicator gif

22:35 hiredman: clojurebot: ping?

22:36 :(

22:36 clojurebot: ping?

22:36 clojurebot: PONG!

22:37 dcnstrct: I wonder if I broke him with that command earlier

22:37 ,(.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/xml.clj")

22:37 clojurebot: nil

22:40 hiredman: I was monkeying with internals

22:45 ct__: Jennifer Aniston likes Clojure: http://java.ociweb.com/mark/clojure/ (Sound Clip #1 at the bottom)

23:04 defn: heh

23:04 the inspiration for me buying getclojure.org/com

23:04 getclojure.org:8080/examples/function

23:14 dgreensp: can I type-hint the return value of a defmethod?

23:16 type-hinting the name of a defn works, right? what's the mechanism behind that?

23:16 and yes, I do need the speed :P

23:17 Apage43: no reason why it wouldn't work, i think.

23:25 dgreensp: oh, except having different type hints for different defmethods in the multimethod isn't really helpful at compile-time...

23:26 * dysinger is lazy - know of a way to use the repl (or socket repl) w/ no prompt ?

23:29 trptcolin: defn: that's pretty sweet

23:33 _ato: dysinger: look at the :prompt option of clojure.main/repl

23:34 or in fact :need-prompt

23:37 dysinger: _ato: thanks

23:59 slyphon: i'm confused about the "implicit this"

23:59 in proxy methods

Logging service provided by n01se.net