#clojure log - Sep 22 2009

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

0:01 interferon: is the a function somefunc s.t. (somefunc fn {:a 4, :b 5}} => {:a (fn 4), :b (fn 5)} ?

0:01 like a map for maps

0:13 mikehinchey: interferon: try destructuring in a map, like (map (fn [[k v]] {k (my-fn v)}) {...})

0:14 also, you need (into {} ...) around that

1:11 tomoj: I've always wondered about that

1:11 is it efficient to build single-pair maps and (into {} ..) them?

1:12 seems intuitively to me that it would not be such a good thing to create a new map for every single pair

1:27 mikehinchey: a vector would also work for the pair

3:05 Fossi: hi

3:07 mikehinchey: hi

3:39 LauJensen: Good morning gents

3:42 RomanRoe: good morning

4:58 AWizzArd: ~max people

4:58 clojurebot: max people is 171

5:00 jdz: i guess i'm the only one annoyed by this

5:00 you know you can communicate directly to the bot, right?

5:34 LauJensen: jdz: Calm down my friend, life is too short :)

5:34 jdz: i'm not upset, i'm annoyed :)

5:37 eevar2: jdz: some of us are pack animals. helps to know we're not alone ;)

5:39 licoresse: I know I can do (println (first (rest (rest ((vec sample-complex-structure) i))))) in a much simpler way

5:39 Can someone point me in a direction?

5:42 cgrand: licoresse ->

5:43 licoresse: ah :)

5:43 ,->

5:43 clojurebot: java.lang.Exception: Can't take value of a macro: #'clojure.core/->

5:43 cgrand: (-> i (vec sample-complex-structure) rest rest first println )

5:44 licoresse: thanks a lot!!

5:44 cgrand: "rest rest first" can be "nnext first" or simply (nth 2)

5:45 * licoresse is experimenting

5:48 eevar2: rest rest could also be written as (drop 2 seq)

5:50 licoresse: but I cannot do this: (doseq [i (range (count sample-complex-structure))]

5:50 (-> (i (vec sample-complex-structure)) rest rest first println)

5:52 ayal: Good morning. I was wondering if someone ever implemented logging while maintaining a pure functional approach (- no atoms, no print etc). We were thinking about a crazy solution where every *single* function recieves a "log-object" and returns its return value with a metadata of the "log-object" on it. An optional way of doing it is changing defn in main.clj or some other crazy macro-based approaches. This seems a little too much

5:54 eevar2: I'd go with java.util.logging

5:55 cgrand: licoresse: (let [sds [[:a :b :c] [:d :e :f :g]]] (doseq [i (range (count sds))] (-> ((vec sds) i) rest rest first println)))

5:55 but why not get rid of this index? (indexes are bad)

5:56 (let [sds [[:a :b :c] [:d :e :f :g]]] (doseq [item sds] (println (nth item 2))))

5:56 licoresse: yes, I was thinking about that too, (!)

5:57 I like this last one much better

5:57 thx

5:59 ayal: eevar2: We know how to log generally. However there is always a problem with two threads logging at the same time for example.

5:59 eevar2: The logs of two threads running at the same time would get interleaved, which is a problem.

6:06 licoresse: I think I understand this now, I feel great!

6:09 Chousuke: ayal: maybe you could use a thread-local logging agent :/

6:10 * Chousuke wonders how that would work.

6:10 ayal: Chousuke: Yes, we though of that but I'm not sure how to create thread-local variables. Can I use vars? How do I then update them?

6:11 mccraig: ayal: what do you need to do with the logs that makes it a problem for different threads logging to be interleaved ?

6:12 Chousuke: ayal: you could also send a thread identifier with each logger event and have the agent just use that for sorting I guess

6:14 ayal: mccraig: We are writing a google wave robot. Robots run in the context of events - each event gets sent to the robot and the robot responds with operations. So we'd like to be able to see logs in the context of each event seperately.

6:14 Chousuke: That seems like a good solution, albeit somewhat too technical and hacky. What do people do in other FP languages? This seems like a general issue.

6:15 Chousuke: hmmh.

6:16 I wouldn

6:16 wouldn't worry too much

6:16 a simple logging call doesn't make your functions impure as far as your program logic is concerned

6:16 mccraig: ayal: we use thread and context ids for our distributed logging : thread log sequence can then be recovered from a file with grep, or a logger can use the id as a database key

6:16 Chousuke: it's just logging. it doesn't change the way your program behaves.

6:18 ayal: mccraig, Chousuke: Thank you. I guess we will use the thread filtering approach for now.

6:19 So.. How do you get the thread identifier? :P

6:19 Chousuke: I suppose the Thread class has somethinf :)

6:20 ayal: Chousuke: Are you really not Chouser?

6:20 Chousuke: I am me :P

6:21 ayal: Thank you all, have a nice day!

6:21 licoresse: hm

6:23 I found (map #(-> % (nth 2)) sample-complex-structure) equally nice to work with, since I don't really need the sideeffect

6:25 Chousuke: why the ->?

6:25 #(nth % 2)

6:26 licoresse: oh

6:27 no, that does not work with the structure

6:27 Chousuke: huh. but it's equivalent :/

6:28 ,(macroexpand '(-> x (nth 2))

6:28 clojurebot: EOF while reading

6:28 Chousuke: ,(macroexpand '(-> x (nth 2)))

6:28 clojurebot: (nth x 2)

6:29 licoresse: I'm sure you know this, but it is trying to cast a PresistentList to a IFn if I leave out ->

6:29 Chousuke: don't just leave out the ->

6:30 I mean #(-> % (nth 2)) -> #(nth % 2)

6:30 licoresse: okay...

6:31 Chousuke: that ought to work, because they're exactly identical as far as the compiler is concerned :)

6:31 * licoresse checking

6:32 Chousuke: but I'll go get something to eat now. later

6:34 cow-orker: Chousuke: "it's just logging. it doesn't change the way your program behaves." <- that's a dangerous assumption! :)

6:35 licoresse: Chousuke: yes, I see your point now...

6:40 jdz: dotimes instead of doseq?

6:40 but then i'd just use map

6:40 or rather, (doseq [x sample-complex-structure] (-> x rest rest first println)

6:40 )

6:40 i'd say logging is sideeffecting by nature

6:40 i don't know the details, but if the whole logging record is not performed in a single system call then logs from different threads might be interleaved, right?

6:46 eevar2: any logging api worth using should be thread safe

7:06 Jomyoot: It would be great if I can readily convert clojure structures into Ruby structures without going through JSON

7:10 tomoj: JRuby?

7:10 or what? I don't get it

7:11 Jomyoot: convert { :a 0 :b 1} into { :a => 0, :b => 1}

8:00 crios: hi

8:02 jonvv: hi does anyone have time to discuss thread local bindings that get "lost" by the use of lazy sequences?

8:04 cgrand: jonvv: you have to capture and restore them

8:05 rhickey: jonvv: just grab them into a let before creating the lazy seq. Putting code that uses vars inside the closure is the problem

8:06 if your lazy seq function calls code that in turn uses vars, then you'll have to explicitly bind them

8:10 patches 169 and 170 will provide helpers for grabbing bindings

8:10 https://www.assembla.com/spaces/clojure/tickets/169

8:10 https://www.assembla.com/spaces/clojure/tickets/170

8:11 jonvv: ok.. but if i want to make any 'system-wide' (rather than fairly targeted, localized use) of var bindings.. i'd have to be capturing and rebinding absolutely all over the place? why is it useful for lazy sequences *not* to *always* grab and rebind the threadlocals?

8:12 (ie. what's a use case for lazy calculations to be done later on in an effectively random 'context'?

8:14 rhickey: jonvv: if you are using vars inside a lazy sequence, directly or indirectly, those are like side-effects (i.e. non-local) and must be treated similarly. The overhead for capturing the dynamic context for every lazy seq op would be extreme, and would effectively render dynamics non-dynamic

8:15 there is a fundamental tension between laziness and dynamic scope

8:15 combine with extreme caution

8:26 ayal: ,(contains? '(1 2) 1)

8:26 clojurebot: false

8:26 ayal: why?

8:28 jonvv: ok.. thanks.. when i first met clojure last year (coming from VB.net) i thought the thread local bindings solved some problems quite neatly.. and the use of them for *in*, *out*, etc seemed to encourage their (potentially) 'system-wide' use for certain things.. and i was thinking of using them (as suggested a couple of times on the group) for switching between more than one simultaneously available low level implementations of "interfa

8:31 hi ayal.. i know the answer to that..

8:32 contains only works on.. Associative, IPersistentSet, Map, + Strings and Arrays when used with an integer.. otherwise returns false!

8:33 ayal: jonvv: oh ok weird. thanks.

8:33 jonvv: (some #{1} '(1 2)) returns 1 (ie. a true value since not nil)

8:34 Chouser: ayal: if you have a collection that you'll use mainly to see if it contains things, try using a set instead of a list.

8:34 ayal: Chouser: you're right but we get it from an external API

8:35 jonvv: Thank you, that'll do.

8:35 Chouser: ayal: the external API prefers to provide a PersistentList vs. a PersistentHashSet?

8:36 cow-orker: ...but sometimes you have a list (eg - code) ... it is strange, seen from a user perspective, that it doesn't work with a list.

8:36 jonvv: ayal: (contains? (into #{} '(1 2)) 1)

8:36 Chouser: ,(contains? (set '(1 2)) `)

8:36 clojurebot: Unmatched delimiter: )

8:36 Chouser: ,(contains? (set '(1 2)) 1)

8:36 clojurebot: true

8:37 Chouser: ,(.contains '(1 2) 1)

8:37 clojurebot: true

8:37 Chouser: there are ways. :-)

8:38 cow-orker: the idea is that generally only things the collection can do fast have direct functions available. Doing 'contains' on a list is O(n), so it doesn't support 'contains?' directly.

8:38 Though 'nth' seems to stretch that rule a bit.

8:40 drewr: http://www.artima.com/forums/flat.jsp?forum=226&thread=268948

8:40 rhickey: Chouser: yes, nth gets a break it probably shouldn't, r at least there should be a guaranteed-fast indexed lookup

8:43 Chouser: When I do positional destructuring, it's almost always on a vector, I think.

8:43 rhickey: drewr: yeah, the discussion there has been quite disappointing

8:43 Chouser: Actually, I hardly ever use lists except when writing macro-related code.

8:44 rhickey: Chouser: yeah, vectors rule everywhere else

8:45 cow-orker: I see... a good reason, but not very ducky... I mean, performance is not always the issue, clearity and elegance are important too. Anyway - a writeup wrt internals, lookup speed O(?) ++ would be useful :-)

8:46 rhickey: ,(doc nth)

8:46 clojurebot: "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."

8:50 Chouser: I almost wonder if some readers thought you meant that fixing the Date object would solve the time problem.

8:50 rhickey: Chouser: heh

8:52 Chouser: whoa. paste.lisp.org pastes expire!?

8:52 jcall is gone

8:52 drewr: shouldn't by default

8:53 Chouser: I'm pretty sure this used to be jcall: http://paste.lisp.org/display/67182

8:54 drewr: my delicious agrees

8:55 Chouser: http://clojure-log.n01se.net/date/2008-07-23.html#15:02

8:58 way past time to put that in contrib, apparently. java-utils?

9:02 rhickey: Chouser: the problem with jcall is, some people come to Clojure expecting a string-based duck-typing system. That's not what Clojure is about. > 90% of the time they shouldn't be using jcall, but if it were there they would happily use it and never ask the questions that help them understand how Clojure works. Then they will complain about jcall being slow...

9:17 cow-orker: would it make sense for RT-contains to throw an exception instead of returning F (last line in method) ?

9:17 Chouser: rhickey: adding warnings in the jcall docstring wouldn't be sufficient?

9:18 rhickey: Chouser: warning, do not use this :)

9:18 Chouser: exactly!

9:19 rhickey: I'd rather see it live in a FAQ than the library

9:21 Jomyoot: what is THE json library for clojure?

9:23 Chouser: Jomyoot: I think there are two

9:24 Jomyoot: is the contrib one good?

9:24 cannot find documentation

9:24 Chouser: that's about par for contrib. :-)

9:26 Jomyoot: how would I find doc for clojure.contrib.json.read

9:27 sorry i am stupid

9:27 found it

9:31 how would I change all {"a" 1 "b" 2} to {:a 1 :b 2}?

9:32 Chouser: Jomyoot: didn't I answer that for you yesterday?

9:33 Jomyoot: something with zipmap

9:33 right?

9:33 Chouser: yes

9:33 Jomyoot: i thought it was related question

9:33 Chouser: http://clojure-log.n01se.net/date/2009-09-21.html#09:38a

9:33 eevar2: Jomyoot: i know I said _don't_

9:33 Jomyoot: yep

9:33 I prefer to use (:a hash) than (hash "a")

9:33 when accessting

9:34 accessing

9:34 it's easier to read

9:35 eevar2: how large is said hash?

9:37 or nm, i don't care

9:52 drewr: how do I force expansion of a symbol in a macro?

9:53 e.g., (defmacro foo [args] `(do ~@(map ... args)))

9:54 (let [bar [1 2 3 ...]] (foo bar)) will complain about args being a symbol

9:55 Chouser: drewr: the value of bar there isn't known until runtime. you probably need to generate a call to map instead of trying to execute the map at compile time

9:55 Chousuke: *sight*

9:55 -t

9:55 Chouser: (defmacro foo [args] `(map ... ~args))

9:55 Chousuke: I took a course for GUI programming and since the assignment is in Qt I hoped I could do it without Windows

9:55 I was wrong,

9:55 they distribute the program as a windows DLL and we have to write an UI for it...

9:56 I don't even have a windows licence :(

9:58 Chouser: Chousuke: probably not worth messing with wine. :-/

9:59 drewr: Chouser: hm, you're right, but the reason I'm mapping at compile time is to generate a dynamic list of (.foo ...) method calls in a doto

9:59 Chousuke: so now I can either drop the course or get a Windows environment set up somehow

9:59 drewr: Chouser: virtualbox or qemu?

9:59 whoops, that was for Chousuke

9:59 Chousuke: I'm definitely not going to pay for a full windows licence though.

9:59 crios: maybe a trivial question. What is a "cell" in your context?

10:00 Chousuke: drewr: you must pass the vector as a literal to the macro

10:01 drewr: I guess I just need to use a function

10:01 the fn is ugly though

10:02 Chouser: you either have to have the vector at compile time (pass it in directly, generate non-reflective code at compile time) or not have the vector until runtime and do reflective calls.

10:06 drewr: can I do the reflective calls in clojure?

10:06 Chouser: sure

10:07 well, what do you mean? You can do anything in clojure. :-)

10:07 drewr: heh

10:07 are they uglier than the fn version?

10:07 Chouser: you're passing in a vector of method names, or ...?

10:08 drewr: let me paste a full example

10:08 Chouser: yes please.

10:13 lisppaste8: drewr pasted "seq expansion from macro arg" at http://paste.lisp.org/display/87499

10:13 drewr: well that doesn't work

10:14 guess jcall isn't lost forever :-)

10:14 http://gist.github.com/191109

10:23 Chouser: drewr: you're going to have several functions that look like make-options, or you're just trying to clean up that one?

10:24 drewr: just that one for now, though I do see a pattern there that's worth generalizing

10:25 Jomyoot: why does read-json parse {"action": "save", "id": 37296, "model": "story"} into {model story, id 37296, action save}

10:25 I am using the contrib read-json

10:25 is it wrong?

10:25 it looks wrong to me

10:25 [

10:25 Fossi: looks good to me, what's looking wrong to you?

10:26 Jomyoot: I am not expecting the comma

10:26 Fossi: the comma is optional in clojure

10:26 hiredman:

10:27 Fossi: it's like whitespace

10:27 Jomyoot: duh

10:27 hiredman: ,'{a b c d}

10:27 clojurebot: {a b, c d}

10:27 hiredman: the comma is an artifact of printing out the map

10:28 Jomyoot: ok

10:30 ,(map #({:a %}) [ {:a 1} {:a 2}])

10:30 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap

10:32 Jomyoot: ,(hash-map :a 1 :b 2)

10:32 clojurebot: {:a 1, :b 2}

10:32 hiredman: #({:a %}) => (fn [x] ({:a x}))

10:38 Jomyoot: clojure is the only langue where i feel smarter everyday using it

10:39 cgrand: clojure enlarges your iq :-)

10:39 drewr: Jomyoot: it's the first *practical* language to have that effect on me

10:40 plenty of stuff out there can stretch you

10:40 Chousuke: making the comma whitespace was an interesting decision. :)

10:42 cgrand: Chousuke: I don't know, cause it's now my #1 error when wrtiting in other languages

10:42 Chousuke: most lisp people will probably go "wait, what?", while people coming from other languages will be grateful that they don't get errors if they accidentally type it :P

10:42 tmountain: I think it's nice for readability when representing a data structure

10:42 hiredman: cgrand: me too, that and missing returns

10:43 Chousuke: tmountain: yeah.

10:43 cgrand: yeah that one too

10:43 hiredman: I love the coma as whitespace

10:43 tmountain: great for maps

10:43 Chousuke: it's not actual *syntax*. it's like indentation.

10:43 Chouser: or pairs in vectors

10:46 djpowell: Would core benefit from a 're-split' function, that basically does pattern.split(s)? (for parsing tab-separated files and stuff)

10:48 Chouser: djpowell: why not just call pattern.split(s) ?

10:49 hiredman: String's .split takes a string regex also

10:49 djpowell: Yeah, I am doing: (seq (.split #"\t" s)).

10:49 Chouser: most things that take seqs will call seq for you

10:50 djpowell: yeah, but arrays don't have nice string representations

10:50 hiredman: the regexp version is probably better, cause then you can use an interned regexp

10:51 Chouser: there's also split in str-utils and str-utils2

10:52 djpowell: Chouser: Oh ok. I'm a bit shy about using contrib cause I'm never sure what state it is in.

10:53 Chouser: has it bitten you?

10:55 djpowell: No not yet. There is some great stuff in there, but for what I'm doing it hasn't really been worth the effort of discovering it.

10:56 seqs rock. I'm just working on reading a directory of tab-separated files into the same format as I get from resultset-seq, to test my heavily interweaved java/clojure project.

11:02 drewr: djpowell: I share your frustration with contrib, but you can lock into your build a version that has working parts you need

11:06 stuartsierra: What would make contrib palatable?

11:06 djpowell: drewr: yeah, it isn't really a problem for me yet. It would be nicer if we had something a bit more CPANish, but I'm not in a hurry yet.

11:40 stegano: hi guys having read this blog http://bestinclass.wordpress.com/2009/09/17/scala-vs-clojure-round-2-concurrency/ its not very clear if clojure would be a good choice for distributed computing ... obviously I don't know much about clojure but I do understand the Actor model that Scala has adopted from the Erlang world ....

11:41 so the question is does clojure support distributed computing as easily as Erlang's actor based paradigm ??

11:42 rhickey: stegano: no, distribution is not built into Clojure. OTOH, you have a wealth of non-built-in options, i.e. JMS, AMQP, etc

11:43 stuartsierra: Hadoop, Terracotta, ...

11:43 crios: maybe stegano do you mean "parallel" distributed computing?

11:43 rhickey: JGroups, GridGain, NetKernel

11:46 stegano: rhickey: thanks for those pointers .... so I would assume that distribution is not built into clojure bcoz of the jvm limitations right ? ... and that means clojure like other jvm languages wouldn't be able to take advantage of multiple cpu's ....

11:46 stuartsierra: no, no!

11:46 The JVM uses multiple CPUs in a single machine just fine.

11:46 stegano: well that may not be true ... but certainly a cluster would be very difficult to build

11:46 stuartsierra: i mean you are right.... sorry for that oversight

11:47 rhickey: stegano: http://www.gridgain.com/

11:47 stegano: crios: yes I mean parallel distributed computing

11:47 stuartsierra: Parallel distributed computing is always hard.

11:48 stegano: stuartsierra: except that erlang makes it some what easier

11:48 albino: How do you bootstrap erlang onto multiple machines?

11:49 Chouser: does erlang force or encourage you to handle node and communication failures even when just using mutliple local cores?

11:49 drewr: stegano: erlang makes serialization trivial, and forces you to pass messages, but you can do both in clojure

11:50 Chouser: both

11:50 rhickey: Chouser: yes, the local case is exactly the same as the distributed

11:50 drewr: a process is a process is a process

11:50 Chouser: hm

11:51 stegano: drewr: i am sure I can do the same in clojure too on a local node ... but is there any additional complexity to deal when dealing with remote nodes

11:51 ?

11:51 drewr: as rhickey just said the local case is same as distributed case in Erlang

11:51 albino: just the complexity of putting grid gain agents on multiple machines?

11:51 rhickey: which means reading data == sendMeTheData(you, me), then blockWaitingFor(you)

11:53 IMO most applications are better served using a higher-level construct like message queues. Note, e.g. the #1 application of Erlang outside of telcomm is to write message queues (RabbitMQ, ejabberd)

11:53 drewr: stegano: my point is that with clojure the local case is easier and the distributed case can be as elegant

11:53 rhickey: Erlang is great plumbing for that

11:54 drewr: it also has great binary splitting for implementing certain protocols

11:55 stegano: drewr: how do you mean in clojure the distributed case can be as elegant ? do you mean by using GridGrain's

11:55 rhickey: but managing webs of directly interconnected distributed objects is tricky. Message queues add useful indirection, durability, manageability etc

11:56 drewr: stegano: it's not baked into the language like it is with erlang, but there are plenty of ways to pass messages robustly (see rhickey's ongoing comments)

11:57 rhickey: Writing a message queue? use Erlang. Writing an ordinary application? use a message queue.

11:59 danlarkin: rhickey: +1

12:01 Chouser: I need to understand better what a message queue system provides and how an application is meant to interact with it.

12:04 stuartsierra: Chouser: try the Amazon SQS docs -- don't know how that compares with libs like JMS, but it's very easy to follow.

12:04 Chouser: stuartsierra: ok, thanks.

12:05 tmountain: is there a more idiomatic way to do this? (= clojure.lang.Ref (class my-var))

12:06 hiredman: ,(doc instance?)

12:06 clojurebot: "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"

12:06 Chouser: tmountain: not exactly that, but (instance? clojure.lang.Ref my-var) is close

12:07 tmountain: ok, but there's nothing equivalent to (ref? ...)

12:09 Chouser: I don't think so

13:37 winterstream: Hi everyone. I'm trying to create a plugin for a program (Cytoscape, if it matters). I'm using AOT compilation to generate a minimal plugin class, but it fails to load. Could Cytoscape be loading plugins in a way which causes trouble with Clojure generated classes, or is my mistake likely elsewhere? (I've been struggling with this for 2 days).

13:39 Chouser: winterstream: so you get any kind or exception or stack trace?

13:39 do you?

13:40 winterstream: Chouser: I can only see NoClassDefFound in Cytoscape's error window. I compiled it from source and should probably put a breakpoint in at its plugin loading code to see what's going wrong.

13:40 Chouser: that is the kind of error one would expect when classloaders start to get in each others' way, though other things can cause it too.

13:44 winterstream: Chouser: Thanks. I'm going to hook Cytoscape to jSwat to see if I can identify the problem. Another question: if I distribute a jar containing Clojure compiled classes, where should clojure.jar be placed? Can jars be nested? Sorry - I realize that this is really a non-Clojure question, but it is something to worry about with Clojure code.

13:46 Chouser: I believe you can nest jars, and have the outer jar specify the inner one as part of the classpath using the outer's manifest file.

13:46 but I've never done it.

13:47 I always just unpack all the jars into a common dir, then pack them up into a single .jar

13:48 stuartsierra: I think nesting jars requires special classloaders

13:48 winterstream: I'm quickly checking if that's causing my issues.

13:52 Ug. It was as simple as that - I just had to unpack clojure.jar and place its contents into my jar.

13:52 hiredman: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4648386 <-- "Simplify deployment and versioning by embedding JAR files within each other"

13:52 winterstream: Thanks Chouser & stuartsierra.

13:52 Thanks hiredman, I'll check that out.

13:53 Oh wait, I see

13:53 :/

13:53 Oh well. It's not too bad taking the extra step.

13:53 hiredman: http://one-jar.sourceforge.net/

15:52 lisppaste8: hamza pasted "rss concatanation" at http://paste.lisp.org/display/87523

15:53 hamza`: hey guys i am trying to create an rss feed but i can't figure out how to add inner-test functions output after the desc tag?

15:54 stuartsierra: hamza`: you can return data structures from the xml-inner-test, don't call (prxml...) again

15:55 hamza`: i am going to call inner-test multiple times is it ok to concat the resulting vector for each item in list?

15:56 stuartsierra: Sure, just return a list.

15:56 If prxml sees a list in its arguments, it recursively prxml's each element of the list

15:56 hamza`: kk thank you

15:57 stuartsierra: welcome

16:16 prospero_: are there plans to let you add metadata to anonymous functions?

16:20 technomancy: prospero_: there's a ticket for it

16:20 prospero_: have you seen the workaround with proxy?

16:35 prospero_: technomancy: no, I haven't. link?

16:35 technomancy: prospero_: not sure off the top of my head; try searching the mailing list for: proxy fn metadata

17:04 hiredman: clojurebot: ticket search Fn metadata

17:04 clojurebot: ("#140: Single :tag for type hints conflates value's type with type of return value from an invoke" "#12: GC Issue 8:\t:default as keyword arg to defmulti")

17:04 hiredman: :|

17:06 clojurebot: ticket #94

17:06 clojurebot: {:url http://tinyurl.com/mgjunh, :summary "GC Issue 90: Support metadata on fns", :status :new, :priority :normal, :created-on "2009-06-17T20:43:34+00:00"}

17:07 hiredman: "milestone set to Release 1.1"

17:51 jensli: Is there a shorter way to do:

17:51 ,(apply concat '((1 2)(3 4)))

17:51 clojurebot: (1 2 3 4)

17:51 jensli: ?

17:51 stuartsierra: that's pretty short

17:52 but c.c.seq-utils/flatten might work

17:53 jensli: k, thanks.

17:54 stuartsierra: http://stuartsierra.com/2009/09/22/its-about-the-platform

17:54 jensli: the standart lib is big enough for me for a while

17:59 Chouser: no memory leaks in java?

18:00 oh, he's gone.

18:01 jensli: Java leaks in a more controled manner.

18:02 hiredman: that article is timely

18:02 plog post

18:02 blog

18:02 whatever, man

18:22 hamza`: hey guys how can turn a string to a keywork "platform" -> :platform?

18:23 LauJensen: ,(keyword "platform")

18:23 clojurebot: :platform

18:23 hamza`: thx

18:23 LauJensen: np

18:29 jensli: I dont seem to be able to do this: (defn create-obj [class-sym] (new class-sym))

18:29 Do I have to use reflection for this? Create an object of a class passed as an argument.

18:30 hiredman: ,(new (Class/forName "java.lang.Object"))

18:30 clojurebot: java.lang.IllegalArgumentException: Unable to resolve classname: (Class/forName "java.lang.Object")

18:30 hiredman: whee

18:30 yeah, you need to use reflection

18:32 jensli: ok, thanks, hrm, then I have to learn some new stuff...

18:32 clojurebot: new Class(x) is (Class. x)

18:33 hamza`: why is this causing an exception?

18:33 ,(with-meta "atest" {:layout true})

18:33 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IObj

18:33 hiredman:

18:33 a String is not an IObj

18:34 hamza`: so i can't store meta for a string that i am returning from a function?

18:34 hiredman: any string

18:34 technomancy: hamza`: that's right; unfortunately Java doesn't let you subclass strings to add features.

18:34 hiredman: clojure strings are java.lang.String strings

18:35 technomancy: "If God had wanted strings to have features, he would have built them into the JDK!"

18:35 according to Sun, at least.

18:35 hamza`: kk got it thx i'll stick to maps :(

18:36 hiredman: you could always proxy CharSequence and IObj

19:43 hamza`: is there a native clojure way to cast "12" to 12?

19:43 or do i resort to java?

19:46 Makoryu: , (read "12")

19:46 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to java.io.PushbackReader

19:46 Makoryu: Dang

19:46 technomancy: ,(int "12")

19:46 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character

19:49 dnolen: ,(.parseInt "12")

19:49 clojurebot: java.lang.IllegalArgumentException: No matching field found: parseInt for class java.lang.String

19:49 dnolen: heh

19:49 hamza`: ,(Integer. "12")

19:49 clojurebot: 12

19:49 hamza`: worked

19:49 Chousuke: it's Integer/parseInt anyway

19:49 dnolen: there you go, just saw that.

19:53 rhickey: ,(read-string "12")

19:53 clojurebot: 12

20:03 Chouser: ,(read-string "#=(println \"watchout\")")

20:03 clojurebot: watchout

21:02 khora: hello

21:03 how do I setup acquamacs for clojure?

21:16 I'd like to be able to install Acquamacs and its support for Clojure, is this a recommended setup?

21:16 hiredman: ~emacs

21:16 clojurebot: emacs is best configured for Clojure with instructions at http://technomancy.us/126

21:16 Chouser: khora: I believe that's what Rich Hickey uses, though he doesn't use slime.

21:16 khora: Chouser: what's slime?

21:18 hiredman: thanks. Will those instructions work for aquamacs too?

21:19 Chouser: it's an advanced mechanism for emacs to interact with a running lisp. I don't use it either. :-)

21:20 khora: Chouser: oh ok. So all I need is Aquamacs itself, and clojure-mode?

21:24 ~textmate

21:24 clojurebot: Excuse me?

21:24 khora: lol

21:25 hiredman: ~google clojure textmate bundle

21:25 clojurebot: First, out of 3860 results is:

21:25 ANN: Clojure Textmate Bundle 0.1 | Educate. Liberate.

21:25 http://nullstyle.com/2008/11/09/ann-clojure-textmate-bundle-01/

21:29 dnolen: khora: http://bc.tech.coop/blog/081023.html, bill clementson's tips are also very helpful.

21:33 hiredman: except all the urls are outdated

22:44 blcooley: Hi, I am trying to figure out an idiomatic way to accumulate a sequence, kind of like reduce. An example would be (accumulate + '(1 2 3 4)) yielding (1 3 6 10).

22:44 My first attempt was (defn accumulate [f coll] (for [ind (range 1 (inc (count coll)))] (reduce f (take ind coll))))

22:45 but this obviously calls f needlessly

22:46 So I wrote a recursive version: http://gist.github.com/191620

22:46 Feels like I am missing something, though. Any tips?

22:47 Chouser: blcooley: seq-utils reductions

22:47 blcooley: Chouser: thanks

22:48 Chouser: ,(reductions + [1 2 3 4])

22:48 clojurebot: (1 3 6 10)

22:48 blcooley: exactly what I was looking for. guess i have some studying to do. :)

22:49 hiredman: http://video.google.com/videoplay?docid=-8860158196198824415# Growing a Language -- Guy Steele

22:50 Chouser: hiredman: I've watched that. Fantastic.

22:51 hiredman: yeah, it's great

22:51 I wanted clojurebot to delicious it

22:53 savanni: Hey, all. I don't have any questions at the moment, but I'm just letting you know that I am here. I started playing Clojure today.

22:55 durka42: savanni: welcome

22:56 be careful, i hear the boss at the end is a bitch

22:56 savanni: The boss at the end?

22:57 * durka42 was making a joke based on "started playing Clojure"

22:57 hiredman: ~laugh

22:57 clojurebot: No entiendo

22:57 savanni: Oh. I didn't even realize my grammer failure!

22:57 grammar.

22:57 hiredman: ~laugh is <reply>ha ha

22:57 clojurebot: Ack. Ack.

22:57 hiredman: clojurebot: it's funny, laugh

22:57 clojurebot: The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' (I found it!) but 'That's funny ...' -- Asimov

22:57 hiredman: bah!

23:00 savanni: Anyway, I started doing this because I've gotten frustrated trying to figure out how to create a clisp *program*... something I could easily launch from the command line or run as a CGI. And because some co-workers are interested.

23:01 hiredman: the jvm's start up time sort of nixs cgi most of the time

23:01 durka42: you could teach apache how to use a nailgun

23:02 hiredman: ~laugh

23:02 clojurebot: ha ha

23:02 savanni: Well, theoretically, I should be able to do something crazy with Apache. Like mod_java or tomcat or something.

23:02 Or just use the java-implemented web server.

23:03 hiredman: sure

23:03 savanni: Or forget CGI and use Swing. :)

23:03 Chouser: the world is your oyster.

23:05 durka42: (identical? World/getGlobalWorld (.oyster savanni))

23:05 savanni: nil

23:06 hiredman: (.getWorld SingletonMatrixFactoryObject)

23:06 durka42: RuntimeException: too many design patterns in: SingletonMatrixFactoryObject

23:07 rlb: ClevernessOverflow...

23:09 durka42: break c-c-c-combo;

23:09 savanni: C-c

23:11 Curiosity point... does clojure support conditions and restarts?

23:11 durka42: there is chouser's clojure.contrib.error-kit

23:12 savanni: k. I'm not even sure it matters because I haven't programmed enough lisp to use them yet.

23:49 killy971: is there a known bug concerning maps not being able to store more than 8 key/value associations ?

23:49 transient ones

23:50 technomancy: killy971: array maps become hash-maps when they have more than 8 entries

23:51 killy971: so how should I do_

23:51 ?

23:52 technomancy: they should function the same way

23:52 danlarkin: one becomes the other

23:52 the class is not important

23:53 free your mind!

23:53 killy971: of course

23:54 but the problem is that if I execute in the REPL the following 3 lines

23:54 (def a (transient {}))

23:54 (map #(assoc! a % %) (range 10))

23:54 (count (keys (persistent! a)))

23:54 hiredman: :(

23:54 killy971: the result is 8

23:54 not 10 :/

23:54 hiredman: have you read the docs for transient?

23:55 you need to pass the output of transient around still

23:55 ,(doc transient)

23:55 clojurebot: No entiendo

23:55 hiredman: bah

23:55 anyway, a. don't def transients

23:56 b. you need to pass around the result of assoc!, etc

23:56 danlarkin: killy971: you're trying to shoehorn state in here... incorrectly

23:56 killy971: yup

23:56 well

23:57 hiredman: so don't do those things

23:57 killy971: I would like

23:57 so

23:57 hiredman: why would you want to do a bad thing?

23:57 killy971: is there a nice way to do dynamic programming without adding useless parameter to my functions ?

23:58 danlarkin: killy971: you have the wrong mindset

23:59 hiredman: http://en.wikipedia.org/wiki/Dynamic_programming <-- this kind of dynamic programming?

Logging service provided by n01se.net