#clojure log - Jan 23 2010

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

0:17 DeusExPikachu: anyone know any libraries to communicate with web servers for the purpose of automating logging in and filling out forms?

0:25 hiredman: DeusExPikachu: htmlunit

0:26 DeusExPikachu: hiredman, thanks, checking it out

0:39 tomoj: DeusExPikachu: there's also webdriver

0:39 which can use htmlunit or real browsers, if that matters

0:40 DeusExPikachu: tomoj, interesting, thanks

5:46 esbena: I'm writing a plugin for Eclipse, but the plugin functionality could also be used in VisualStudio. Would it be an option to write the plugin backend in language neutral clojure, which is then capable of reading the plugin data-structures seamlessly as the backend could be either .NET or Java?

8:27 LauJensen: How many data visualization libs do we have yet? I need something quick and pretty for a chart rendering - dejartes perhaps?

8:35 chouser: LauJensen: have you looked at Incanter?

8:35 LauJensen: Yes - Need something else

8:35 chouser: oh

8:58 angerman: Hmm. Is there a lib that serializes/deserialized clojure data-structures? I know clojure can create a string-representation of an object (sans Java classes) that can be recreated by parsing it. But is there a libe that combines that with spit and slurp? E.g. given a structure and a file?

8:58 odrzut: I have problems with emacs 23 + swank-clojure-project - it doesn't add jars from project/lib to classpath

8:59 when I've changed elisp code in this function swank-clojure-project it prints classpath properly

9:00 but when I try from slime-repl (-> "java.class.path" System/getProperty (.split ,,, ":") seq) it return only standard jars

9:01 angerman: odrzut: even though what I'm about to suggest is not perfect, what I do is to use "lein swank" + slime-connect

9:01 the-kenny: odrzut: wait.. let me try your snippet

9:02 odrzut: hm.. can't reproduce. Are the jars in lib/? Where have you got swank-clojure? elpa?

9:03 odrzut: yes - I've installed from elpa

9:03 and when I try lein swank + slime-connect I have the same problem

9:03 the-kenny: that's really strange

9:04 odrzut: I've probabyl broken emacs configuration somehow

9:04 so it changes classpath after loading it by swank-clojure-project

9:08 here is my .emacs - I've fiddled with it a little trying to add native libs by hand

9:08 http://www.nopaste.pl/l9c

9:08 but I'm noob with elisp

9:11 the-kenny: odrzut: I'd try commenting out the swank-clojure-*-path stuff

9:11 You don't need this if you use leiningen and swank-clojure-project

9:13 If this doesn't work, you should double-check (or show us) the project you're using

9:17 jlb: angerman: You can do something like (with-in-str (slurp filename) (read)) or you could use with-in-reader from duck-streams

9:17 angerman: jlb: exactly. I was just wonderig if there was a library already that provided that functionallity out of the box

9:21 jlb: angerman: that is out of the box, IMO. :) If you want to process data structures as they come in, use with-in-reader. If you're just reading the whole file into a var, use the first form.

9:23 angerman: jlb: I do get your point. I guess I'll write my own wrappers. It's just like having (let [struct (read "file")]) (write "file" struct) were nice conviniences.

9:30 LauJensen: Can someone please explain this phenomena to me. When I start heavy computations single threadedly, core#1 goes to about 100% while core#2 idles at 20% presumable keeping the OS running. After about 120 seconds they switch, so c#2 goes to 100% while c#1 idles at 20% - They keep doing this at random intervals between 15 - 120 seconds throughout the computation

9:32 odrzut: maybe it's to keep temperatures more equal ?

9:34 LauJensen: So you suspect the OS is moving it ?

9:34 angerman: LauJensen: sure. It must be the os scheduler. I hadly think java's internal reach so far as to selec the cpu.

9:34 odrzut: I don't know how to move thread from one core to the other programmaticaly

9:35 the-kenny: I'd also blame the os.

9:35 LauJensen: Makes sense

9:35 the-kenny: You should try it with a similiar program in python or so

9:38 odrzut: thanks to all, my emacs saw the Classpath :)

9:38 I've removed everything except elpa stuff from .emacs, and tried with slime-connect

9:49 somejan: ,(. Short TYPE)

9:49 clojurebot: short

9:49 somejan: ,(let [t Short] (. Short TYPE))

9:49 clojurebot: short

9:49 somejan: ,(let [t Short] (. t TYPE))

9:49 clojurebot: java.lang.IllegalArgumentException: No matching field found: TYPE for class java.lang.Class

9:50 somejan: any way to make such a construction work? with the type passed in as an argument?

10:07 LauJensen: somejan: You're calling TYPE as if it were a method of Short, which its not, its a public static final field

10:07 I'm not sure if there's a way to alias that

10:08 krumholt: you could do (let [t Short] (Class/forName (.getName t)))

10:08 ,(let [t Short] (Class/forName (.getName t)))

10:08 clojurebot: java.lang.Short

10:09 somejan: ,(let [t Short] (. (Class/forName (.getName t)) TYPE))

10:09 clojurebot: java.lang.IllegalArgumentException: No matching field found: TYPE for class java.lang.Class

10:09 somejan: hmm

10:09 not yet

10:10 ,(Class/forName (.getName Short))

10:10 clojurebot: java.lang.Short

10:10 somejan: ,(Class/forName (.getName Short/TYPE))

10:10 clojurebot: java.lang.ClassNotFoundException: short

10:10 somejan: It doesnt seem to work with primitives

10:11 Any way to pass (some representation of) primitive types around in parameters?

10:14 the-kenny: I don't think so. As far as I know, parameters are always boxed

10:16 somejan: What I want is some kind of representation of the primitive type, so I can pass that to (make-array type [stuff])

10:17 the-kenny: Oh, you mean the class?

10:17 Try something like (make-array Integer/TYPE)

10:17 ,(class Integer/TYPE)

10:17 clojurebot: java.lang.Class

10:18 slava: ,(class (fn ()))

10:18 clojurebot: java.lang.NullPointerException

10:18 slava: ,(class (fn []))

10:18 clojurebot: sandbox$eval__5151$fn__5153

10:18 somejan: That's what I was trying, but can the class be passed in by a parameter?

10:18 the-kenny: somejan: Yes

10:20 hm.. wait

10:20 somejan: how? this doesn't work:

10:20 ,(let [t Integer/TYPE] (make-array t [1 2 3]))

10:20 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Character

10:21 somejan: ,(let [t Integer] (make-array (. t TYPE) [1 2 3]))

10:21 clojurebot: java.lang.IllegalArgumentException: No matching field found: TYPE for class java.lang.Class

10:23 krumholt: ,(let [t java.lang.Integer] (make-array t 10))

10:23 clojurebot: #<Integer[] [Ljava.lang.Integer;@1774e9>

10:24 krumholt: or also

10:24 ,(let [t Integer/TYPE] (make-array t 10))

10:24 clojurebot: #<int[] [I@c71b37>

10:24 the-kenny: somejan: there you are :)

10:24 somejan: thx

10:25 so

10:25 ,(let [t Integer/TYPE] (make-array t 10))

10:25 clojurebot: #<int[] [I@150c82>

10:25 somejan: works, but

10:25 ,(let [t Integer/TYPE] (make-array t [10 11 12]))

10:25 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Character

10:25 somejan: doesn't

10:25 ???

10:25 krumholt: because if you need more dimesnsion you need to do

10:26 somejan: no, i meant

10:26 krumholt: ,(let [t Integer/TYPE] (make-array t 10 11 12))

10:26 clojurebot: #<int[][][] [[[I@f1369f>

10:26 krumholt: make-array is not filling the array

10:26 it is just creating it

10:26 somejan: ah, wait

10:26 krumholt: ,(doc make-array)

10:26 clojurebot: "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."

10:26 somejan: im confusing make-array and into-array

10:27 ,(let [t Integer/TYPE] (into-array t [1 2 3]))

10:27 clojurebot: #<int[] [I@b053b>

10:37 tmountain: is there a way to alias a function to another name within the current namespace?

10:38 the-kenny: tmountain: There's def-alias in contrib?

10:38 Chousuke: (doc alias)

10:38 clojurebot: "([alias namespace-sym]); Add an alias in the current namespace to another namespace. Arguments are two symbols: the alias to be used, and the symbolic name of the target namespace. Use :as in the ns macro in preference to calling this directly."

10:38 Chousuke: hmm

10:38 tmountain: I'm familiar with the alias function, which aliases a namespace

10:38 the-kenny: ,(use 'clojure.contrib.def)

10:38 clojurebot: nil

10:38 the-kenny: ,(doc defalias)

10:38 clojurebot: "([name orig] [name orig doc]); Defines an alias for a var: a new var with the same root binding (if any) and similar metadata. The metadata of the alias is its initial metadata (as provided by def) merged into the metadata of the original."

10:39 tmountain: so defalias is the solution?

10:39 Chousuke: or just (def foo bar)

10:40 if you don't mind losing the metadata

10:40 tmountain: cool, thanks guys ;-)

10:41 should've thought of using def

10:41 Chousuke: it's not a true alias though. it creates a new var

10:41 tmountain: this is mainly for DSL purposes

10:41 Chousuke: should be fine then

10:41 tmountain: I want to duplicate a function with a couple of names that make sense for the context they're called in

10:42 have a nice weekend

10:45 datka: Does anyone know what this error means? java.lang.VerifyError: class clojure.contrib.duck_streams$loading__4757__auto____1893 overrides final method meta.()Lclojure/lang/IPersistentMap; (http.clj:1)

10:45 I'm trying to build a pom file for a library that doesn't have one

10:48 duck1123: my pom file is at http://gist.github.com/284653 if it helps

10:49 the-kenny: duck1123: ugh... why not use leiningen?

10:51 duck1123: I haven't really messed much with leiningen yet. This was someone elses project I wanted to play with, and I'm used to maven

10:53 does leiningen do swank servers yet?

10:54 the-kenny: "lein swank"?

10:54 Yes

10:54 You can also do M-x swank-clojure-project

13:22 tolstoy: If you have a raw form in your ns, like, say, (init), that'll get evaluated and run at compile time AND load time (in an AOT context), right?

13:23 Can you do something like (if-not *compile-files* (init)) so that it doesn't run during compilation, but have it still work when run after AOT compilation?

13:23 Chousuke: hmm

13:23 ,*compiling*

13:23 clojurebot: java.lang.Exception: Unable to resolve symbol: *compiling* in this context

13:24 Chousuke: some var like that exists but I don't remember what it was called

13:24 tolstoy: *compile-files*

13:24 *compile-files*

13:24 var

13:24 Set to true when compiling files, false otherwise.

13:24 Chousuke: ah, duh

13:25 tolstoy: I was just wondering if "loading" the code (when it's compiled into a jar) would actually do the init.

13:25 Chousuke: why don't you test? :/

13:25 tolstoy: I guess I can crank up this app and see. ;)

13:25 AndiXng: hi

13:26 sorry for this newbie question, but I could not find enough information: I am looking for a vector or list where it is possible to insert/remove elements in the middle

13:26 what is the best way to do that? zippers?

13:27 Chousuke: no efficient collection supporting that exists right now. :/

13:27 you might want to try using maps

13:27 AndiXng: hm

13:28 but with trees, this should be easy (O(log n) is ok for me)

13:29 do you know any clojure lib that provides structures with insert/remove?

13:29 Chousuke: well, maps are your best bet.

13:29 vectors are trees but they don't support efficient insertion in the middle

13:30 chouser is working on finger trees but I don't think it's ready yet :/

13:30 AndiXng: I don't understand yet, how to use maps. should I select indices "with gaps" and fill them over time, any, if necessary, recompute all keys?

13:31 -any +and

13:31 Chousuke: don't understand maps?

13:31 AndiXng: I understand maps

13:31 Chousuke: they're just, well, maps.

13:31 :P

13:32 AndiXng: but give me an example, please. let's say we have a list 1,2,4,5 and want to insert 3

13:32 Chousuke: you could emulate a vector with one by using integer keys

13:32 AndiXng: how to represent 1,2,4,5 as a map?

13:32 Chousuke: well, the map would be indexed of course

13:32 hmm

13:32 AndiXng: {0 1, 1 2, 2 4, 3 5}?

13:33 Chousuke: I suppose that wouldn't help /:

13:33 AndiXng: yeah

13:34 Chousuke: hm. I guess you're out of luck

13:34 AndiXng: i thought about using sorted-set with pair items: [position-information, content]

13:34 absolutely.

13:34 :-D

13:34 Chousuke: clojurebot: finger trees

13:34 clojurebot: Titim gan ��ir�� ort.

13:34 Chousuke: psh

13:36 http://github.com/Chouser/finger-tree apparently finger trees could be of use for you, but I don't know if chouser's implementation is at all ready for use yet (or even how to use it)

13:37 AndiXng: as already said, my idea would be to use a sorted-set with pair items [position-information, content]. i would use gaps inbetween and fill them over time, and when necessary, recompute all keys.

13:37 example: #{[0 1] [100 2] [200 4] [300 5]} . when 3 is added at position 2, then #{[0 1] [100 2] [150 3] [200 4] [300 5]}

13:37 I think this could be "ok"

13:37 but still O(n)

13:37 :-/

13:37 ok I'll have a look at finger trees, thanks

13:38 but I wonder why nobody else had this problem before... o_O

13:38 it's very common to insert and remove elements I think...

13:38 at least if you come from an imperative language

13:38 Chousuke: well, you're not the first one to have this problem, but it's apparently not common enough

13:39 otherwise Clojure would have some data structure for efficient insertion and removal from the middle I guess. :)

13:40 are you sure you can't come up with another algorithm that doesn't require insertions or removals? :/

13:42 AndiXng: well, that's part of the application domain

13:42 if I have a list where elements can be inserted and removed, I should implement this with a list where elments can be inserted and removed

13:43 I just found out how pcollections (Java persistent data structures lib) does it

13:43 logarithmic time, like in "Glasgow Haskell Compiler"

13:43 hm

13:43 probably I'll use that

13:44 I could also write a clojure lib with that algorithm

13:44 hmmmm

13:44 what do you think, would that be useful for anybody but me?

14:23 tolstoy: chouser: Yes, you can use *compile-files* to NOT evaluate forms when AOT compiling, but the forms DO get evaluated when the code is loaded.

14:24 LauJensen: Is that 'Practical Clojure' by Luke Vanderhart any good?

14:24 tolstoy: Now, if I can just figure out how to close a buffer in text-mode emacs....

14:25 LauJensen: M-x kill-buffer

14:25 tolstoy: Ah "kill" was the word.

14:25 C-x k seems to work, too.

14:49 When you access @atom, is that a synchronized read?

15:34 somejan: ,(def x 1)

15:34 clojurebot: DENIED

15:45 somejan: `{ ~@'(:a 1) }

15:45 ,`{ ~@'(:a 1) }

15:45 clojurebot: 1

15:46 somejan: ,`{ ~b }

15:46 clojurebot: 1

15:46 somejan: On my console that says "java.lang.ArrayIndexOutOfBoundsException: 1"

15:48 chouser: somejan: yeah, that's not really supported

15:49 somejan: ,{1}

15:49 clojurebot: java.lang.ArrayIndexOutOfBoundsException: 1

15:50 somejan: ,`{~b}

15:50 clojurebot: 1

15:54 dnolen: somejan: if you wan to splice into a hashmap in a macro use hash-map and not the literal syntax

15:54 somejan: Is the literal syntax supposed to not work in macros?

15:55 dnolen: somejan: I haven't been able to get it to work, but only when trying to splice in values, but perhaps someone else knows different

15:58 chouser: I think the problem is that we're forgetting this code is actually data

15:59 it doesn't quite work like this today, but `{~@b} could be read as (syntax-quote {(unquote-splice b)})

16:08 which means an outer list with two elements, the first the symbol syntax-quote, the second a map

16:08 but that map only has a single item in it, a list. That's not legal

16:09 Chousuke: I tried to implement syntax-quote like that.

16:09 I wasn't very succesfull :P

16:10 chouser: oh, yeah? I think rhickey wants it, or at least wanted to know if anyone knew if it was possible.

16:10 hm...

16:10 Chousuke: it's possible, but nesting and autogensyms complicate it a fair bit

16:11 chouser: ah, interesting.

16:11 Chousuke: and implementing the symbol resolution wasn't exactly pleasant either (I think I have working code for that, at least, but it's very ugly)

16:12 chouser: did you still try to do the autogensym at read time?

16:13 Chousuke: my current reader just runs the syntax-quote function at read-time

16:14 it works, as far as I can tell, but if I turn it into a macro I run into problems :/

16:15 as far as I can tell it works because running the function at read time expands the inner syntax quotes first,

16:16 chouser: I can certainly beilieve that it all gets very hairy very quickly.

16:16 how did you handle autogensym? b# reads as (autogensym b) or as b_123 ?

16:16 or just as b# ?

16:16 ,b#

16:16 clojurebot: java.lang.Exception: Unable to resolve symbol: b# in this context

16:17 chouser: ,'b#

16:17 clojurebot: b#

16:17 Chousuke: it expands to b_234, but only within `

16:17 ,'`f#

16:17 clojurebot: (quote f__5223__auto__)

16:17 Chousuke: I guess I should find some time to work on the reader again

16:17 chouser: ok, so you do it at read time like Clojure does now.

16:18 Chousuke: yeah

16:20 http://github.com/Chousuke/clojure/blob/new/clojure-reader/src/clj/clojure/lang/reader/internal.clj this is how it is at the moment

16:21 still uses the ^ reader macro, too :P

16:33 somejan: ,{:a}

16:33 clojurebot: java.lang.ArrayIndexOutOfBoundsException: 1

16:34 somejan: Is this supposed to be an IOBE instead of an IllegalArgumentException?

16:34 ,(hash-map :a)

16:34 clojurebot: java.lang.IllegalArgumentException: No value supplied for key: :a

16:36 somejan: The exception comes from PersistentArrayMap.java:217, where the code is actually trying to index an array

16:36 It looks like a bug to me, but maybe someone knows if it's a feature before I make an issue?

16:43 tolstoy: does defmacro actually pay attention to its attr-map?

16:43 As in, (defmacro name "doc" #{:private true}....)?

16:46 Ah, the arglist documentation for defmacro is wrong.

16:46 Chousuke: somejan: it's a "feature"

16:47 somejan: {:a} is not a valid literal in any case.

16:47 somejan: and it doesn't really matter what exception it generates :)

16:48 somejan: hmm, I'd say clojure also needs to give the right error messages

16:48 Chousuke: well, yeah

16:49 somejan: at the very least a descriptive message, instead of just "1"

16:49 Chousuke: I guess it's the "no-one wants to work on the compiler" excuse again :P

16:50 though this one is actually generated within the reader

16:50 somejan: ah, but then it is in fact a bug :)

16:50 and not a feature

16:51 So, is this the kind of thing that should go in the bugtracker?

16:59 hiredman: somejan: it's undefined behaviour

17:00 somejan: I didn't know Clojure had a language specification, even one which allows undefined behaviour :P

17:01 hiredman: ,{:a}

17:01 clojurebot: java.lang.ArrayIndexOutOfBoundsException: 1

17:01 somejan: But I still think undefined behaviour should produce a descriptive error message

17:01 hiredman: *shrug*

17:02 somejan: {:a} isn't a real problem, but when it is in a macro it can be hard to find

17:02 (which is where I first ran into this)

17:04 hiredman: sure, but how big of an issue?

17:04 clojurebot: ticket search ArrayIndexOutOfBoundsException

17:04 clojurebot: ()

17:04 hiredman: :|

17:05 clojurebot: ticket search map literal

17:05 clojurebot: ("#87: GC Issue 83: \t PersistentArrayMap trust the reader (map literals) too much")

17:05 hiredman: clojurebot: ticket #87

17:05 clojurebot: {:url http://tinyurl.com/y92lmv8, :summary "GC Issue 83: PersistentArrayMap trust the reader (map literals) too much", :status :new, :priority :low, :created-on "2009-06-17T20:36:09+00:00"}

17:33 alexyk: is there a method to get the number of day, whether in the year or Julian/Gregorian, from the old silly java.util.Date?

17:33 chouser: day of the year, or something else?

17:33 alexyk: and can somenody with the sysop please do -R on this channel?

17:33 chouser: day of year is a good start

17:34 Joda Time has dayOfYear, and with juDate I'm at a loss, some stupid calendar and <whatnot>

17:38 chouser: ,(.get (java.util.Calendar/getInstance) java.util.Calendar/DAY_OF_YEAR)

17:38 clojurebot: 23

17:38 alexyk: ok

17:42 hiredman: I have a patch for #87 and the {:a} issue: http://www.thelastcitadel.com/lab/map-literals-error.diff

17:43 chouser: maybe you could take a look at put it in assembla :)

17:44 chouser: hiredman: if it's a fix to an accepted bug, you should go ahead and attach it.

17:45 hiredman: I guess this is as good a time as any to send and email to ask to be allowed to do that sort of thing

17:47 I send an email to dev right?

17:50 alexyk: no car and cdr in core??

17:50 chouser: first rest

17:50 alexyk: chouser: yeah, but no car and cdr?! :)

17:51 chouser: nope

17:51 the-kenny: car and cdr is to old-school for a modern lisp

17:51 alexyk: well just as an homage to lisp they'd better be there

17:52 sounds like a bow to the general dumbing0down of the universe

17:52 to help Britney Spears learn a lisp

17:53 hiredman: car and cdr are the names of registers on machines no one uses anymore

17:53 krumholt_: it seems that with 1.1 "apply" has changed and i can no longer do (apply foo) but i have to do (apply foo nil) why is that?

17:54 hiredman: are you sure?

17:54 I don't think (apply foo) ever worked

17:54 krumholt_: it did

17:54 i used it a lot and now i have to change a lot :)

17:54 * alexyk considers for a moment an alternative universe where Britney Spears pops up in #clojure. "Baby baby map me one more time!"

17:56 alexyk: never mind...

17:56 hiredman: well I'll be damned

17:57 there is a commit that mentions apply back in august

17:58 krumholt_: well i haven't upated in a while :) i just see no reason to change the behaviour

17:58 hiredman: ok

17:58 alexyk: chouser: so you get day of year for a calendar, not an existing java.util.Date. Is one supposed to create a Calendar of juDate? Or get the Calendar from juDate?

17:58 chouser: actually, 'cdr' would be pretty misleading. Clojure's 'rest' is not the same thing

17:58 hiredman: apply got arity overloads, and has no arity for the zero arg case

17:59 krumholt_: could that be redone?

17:59 (apply foo) also seems even prettier then ((foo))

18:00 the-kenny: Isn't (apply foo) different to ((foo))?

18:00 alexyk: chouser: I just think that car and cdr may co-exist with first and rest, to claim the lisp's inheritance

18:00 the-kenny: Should be (apply (foo))

18:01 chouser: ,(.get (doto (java.util.Calendar/getInstance) (.setTime (java.util.Date.))) java.util.Calendar/DAY_OF_YEAR)

18:01 clojurebot: 23

18:01 hiredman: the-kenny: right (apply foo) would just be (foo)

18:02 http://github.com/richhickey/clojure/commit/5ca86e045bd5742566c647dcc46b8e546a6a7c06 is the commit

18:03 your best shot would be taking it to the mailing list since rhickey doesn't appear to be in

18:03 alexyk: chouser: right... Do you think that crating one instance and then setTime/get day of year for each of a gazillion juDate's is faster than converting each to a DateTime and calling getDayOfYear on each? I guess I'll have to benchmark.

18:03 chouser: beats me

18:04 alexyk: can't wait when they induct DateTime into core Java so we can forget the nightmarish juDate/Calendar crap

18:04 * chouser nods

18:15 the-kenny: Which contrib should I use with clojure 1.1.0 (leiningen)

18:15 +? :)

18:53 somejan: Is there a way to make compiled clojure code be in a specific package, so it can access protected methods on java classes in the package?

18:54 The :gen-class thing apparently just puts the stub class in the package, but not the real code

18:54 the-kenny: somejan: There's a hack in contrib: wall-hack-method

18:55 It uses reflection to call protected (or private) methods

18:55 somejan: ah, I'll have a look

18:55 the-kenny: I think it's in java-utils

19:07 somejan: It works, but only to read fields, not to write them. I don't see anything in that namespace that will write fields, so guess I'll have to hack it myself

19:14 tomoj: say you've got a big tsv file and you want to treat it as a lazy seq of structmaps

19:15 somnium: so, is there a standard way to load somefile.txt off the classpath? Ive only been able to get duckstreams to work with absolute paths/paths relative to pwd

19:15 tomoj: does writing a macro with-tsv which with-opens the file, binds the lazy seq of structmaps, then checks what the body returns and wraps a doall if it's a seq sound like a reasonable approach?

19:16 it seems kind of strange.. this macro must be used at the top level of whatever processing you're doing, to ensure the file doesn't close before you're done

19:16 read-lines is cool but what if we don't consume the entire seq? :/

19:17 somnium: you can make it a "resource"

19:18 somnium: tomoj: how to do that? (I only seem to find some java idiom (-> this .getClass .getClassLoader ...) on google)

19:18 tomoj: yep, that's what I meant

19:18 except

19:18 (.getResource (clojure.lang.RT/baseLoader) "foo.txt")

19:18 gives you a URL

19:19 somnium: ah, nice

19:19 thx!

19:19 tomoj: might be good to stuff everything into a resources/ subdir and add that to the classpath

19:19 if the paths are coming from users

19:20 I think lein adds resources/ to the classpath by default

19:20 krumholt_: anyone know where i can find some information on protocols? preferably a screencast

19:21 tomoj: if you find a screencast let me know!

19:21 I still don't understand them

19:25 AWizzArd: Currently Clojure has the EP License. Could Rich in principle change the license if he wanted without the agreement of other contributors?

19:26 hiredman: yes

19:26 the CA assigns joint copyright

19:26 AWizzArd: Is this because he is the initial contributor?

19:27 ah ok

19:27 Otherwise I would understand the EPL in such a way that as soon some other author publishes any code and the initial contributor includes this in his code base it would not be possible anymore to get rid of the EPL

19:30 hiredman: do you know if Rich used an existing license as his CA, or did he wrote it himself?

19:31 nevermind

19:31 just saw it at the bottom, that he used something that Suns lawyers wrote

19:40 hiredman: the ability to change licenses if needed is the whole point of the CA

19:54 alexyk: ,(let [{:keys [a b]} {:a 1}] (println a))

19:54 clojurebot: 1

19:54 alexyk: ,(let [{:keys ["a" b]} {"a" 1}] (println a))

19:54 clojurebot: java.lang.Exception: Unsupported binding form: a

19:54 * the-kenny loves destructuring

19:54 alexyk: ,(let [{:keys [a b]} {"a" 1}] (println a))

19:54 clojurebot: nil

19:54 alexyk: so, does :keys only support keywords?

19:55 the-kenny: alexyk: I think so

19:57 alexyk: is there a fascinating tour of data massage you can type into a repl before a group of noobs to bedazzle them?

20:00 the-kenny: Something with a lazy-seq would be cool

20:00 like (take 100 (small-function-for-calculating-fibonaccis)

20:00 +)

20:18 krumholt_: hi i created a simple protocol for a list. could someone take a look if thats how one would use a protocol? especially my use of new seems strange.

20:18 http://paste.lisp.org/display/93815

21:29 AWizzArd: when I have a sorted set of 1000 elements, can i then get a subset or subseq of the elements 450 to 500?

21:34 chouser: AWizzArd: put them in a sorted set (or map) and use 'subseq'

21:35 AWizzArd: they already are in a sorted set

21:35 chouser: there you go. subseq.

21:35 oh

21:35 subseq is based on the value, not the position

21:35 AWizzArd: yes

21:36 chouser: if you want position, I guess I'd put them in a vector and use subvec.

21:36 AWizzArd: probably

21:36 oki

21:45 blbrown_win: '

21:45 ,(/ 5 9)

21:45 clojurebot: 5/9

21:46 blbrown_win: ,(/ 5.0 9.0)

21:46 clojurebot: 0.5555555555555556

23:05 datka: If I invoke "lein swank" shouldn't my source code (or the jar) be on the classpath somewhere?

23:06 I'm printing out the urls in my classpath, and I'm seeing the root of the project, but not the src/ directory

23:09 tomoj: hmm, I wonder if we can deal with the no threads restriction on app engine :(

23:26 alexyk: chouser: check it out: http://paste.pocoo.org/show/169141/

23:28 datka: so does anyone uses leiningen with swank that knows what I might be doing wrong?

23:36 chouser: alexyk: oh, my. DateTime is from JodaTime?

23:56 quotemstr: Why does clojure use type hints instead of CL-style DECLARE?

Logging service provided by n01se.net