#clojure log - Aug 31 2010

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

0:00 ataggart: Is there a way to call clojure.lang.Numbers/shiftLeftInt without the primitives getting autoboxed to intermediate objects?

0:01 trying to do a lot of byte ops and I'm guessing this is where the slowdown is

0:12 scottj: maybe one of the special branches, like prim?

0:13 tomoj: how do you even tell whether stuff is getting boxed?

0:14 technomancy: prim is in 1.3 now iirc

0:15 notsonerdysunny: my messages are not appearing on the forum :(

0:15 ataggart: ah, I had forgotten about the prim stuff

0:18 Chousuke: notsonerdysunny: hm.

0:18 notsonerdysunny: no ... sorry .. I just found it :)

0:18 Chousuke: Ah, good.

0:19 I was about to tell you to poke chouser, as he's a group moderator :P

0:19 at least IIRC.

0:48 _na_ka_na_: guys does compojure 0.4.1 work with clojure 1.2?

0:49 what about one of 0.3.x ?

0:59 someone on #compojure answers 0.4.1 works with clojure 1.2, 0.3.x prob doesn't

1:05 scottj: I think there was mention of a request for a 0.3 that worked with 1.2 a couple months ago, it might be on clojars

1:08 _na_ka_na_: scottj: how do i search for it

1:10 this must be it .. org.clojars.bmabey/compojure 0.3.3-SNAPSHOT

1:10 let me try

1:18 bortreb: how do I do a primitive int type hint for clojure? #^int doesn't work....

1:32 ataggart: you don't unless you're working in the master branch

1:34 bartj: , (clojure.set/intersection [[1 2 3] [2 3]])

1:34 clojurebot: [[1 2 3] [2 3]]

1:34 bartj: I was expecting: [2 3] on the above statement

1:35 oh, they should be sets and not vectors...mea culpa

1:35 , (clojure.set/intersection #{1 2 3} #{2 3})

1:35 clojurebot: #{2 3}

3:36 LauJensen: Good morning all

3:40 lenw: Morning LauJensen

3:43 adityo: good morning :)

3:43 LauJensen: clojure.lang.RT/baseLoader extends URLClassLoader and has a method called getResourceAsStream - Any idea where thats implmented? (not in DynamicClassLoader.java or in URLClassLoader)

3:43 ah, silly me, its inherited from java.lang.ClassLoader, nvm

5:40 serp_: is there an idiomatic way of doing a priority queue?

5:45 LauJensen: A while ago I asked about getting a UUID from Clojure and it was suggested that I cat /proc/sys/kernel/random/uuid, which is easy to enough, but this is the way to go

5:45 -> (str (java.util.UUID/randomUUID))

5:45 ,(str (java.util.UUID/randomUUID))

5:45 clojurebot: "b5b0df74-f15a-4995-97b9-ab7315241e77"

5:56 notsonerdysunny: ,(java.util.UUID/randomUUID)

5:56 clojurebot: #<UUID d1ffd517-7132-4c70-acb6-8e719bc3685e>

5:56 notsonerdysunny: ,(java.util.UUID/randomUUID)

5:56 clojurebot: #<UUID a3bda2ea-7245-4f64-aab0-c90ebf6e9d47>

5:57 serp_: what are the semantics of a queue in clojure?

5:57 (with respect to concurrency)

5:58 tomoj: nothing special

5:59 if you mean PersistentQueue, that is

6:00 serp_: those are mutable though

6:00 I'd like an immutable queue, but perhaps that makes no sense :)

6:02 LauJensen: serp_: Nearly all talk of queues end up with people writing their own wrapper for LinkedBlockingQueue

6:03 tomoj: PersistentQueues aren't mutable

6:03 and if you want an immutable queue, why are you asking about concurrency semantics?

6:03 if it's immutable, it has the same semantics with respect to concurrency as all the other immutable stuff: it can't change at all!

6:05 serp_: LauJensen: all right

6:08 tomoj: what is PeristentQueue? I assumed you meant http://a.gaborcselle.com/open_source/java/persistent_queue_javadoc.html as that's the only hit on google I can find

6:09 tomoj: ah, no

6:09 ,(-> clojure.lang.PersistentQueue/EMPTY (conj 1) (conj 2) peek)

6:09 clojurebot: 1

6:10 tomoj: since you said "priority" earlier I think this won't help, though

6:13 serp_: hm

6:16 I want to implement a multi-threaded A* in clojure... at the core of it is a priority queue. in order to not process the same queued item multiple times I guess I have to serialize access to the queue, but that feels un-clojurish.

6:17 fliebel: morning

6:17 serp_: though obviously I'm a clojure noob, so what do I know

6:31 LauJensen: clojurebot: where are you ?

6:31 clojurebot: http://github.com/hiredman/clojurebot/tree/master

6:32 fliebel: clojurebot: do you have a list of commands? :P

6:32 clojurebot: paredit commands is http://mumble.net/~campbell/emacs/paredit.html

6:33 LauJensen: clojurebot: whats the maximum size of a POST request?

6:33 clojurebot: excusez-moi

6:35 quizme: is there a function that gives the name of the variable as a string or symbol?

6:36 LauJensen: ,(symbol "this")

6:36 clojurebot: this

6:36 LauJensen: ,(str 'this)

6:36 clojurebot: "this"

6:36 quizme: ty :)

6:36 fliebel: what was the one with teh colon in front?

6:36 quizme: lemme try that

6:37 LauJensen: ,(name :this)

6:37 clojurebot: "this"

6:37 fliebel: and the inverse of that?

6:37 quizme: how about

6:37 (def x 3)

6:37 (whats-your-name x)

6:37 => "x"

6:38 any way to do that?

6:38 tomoj: why would you want to do that?

6:38 fullets: (defmacro whats-your-name [s] (name s))

6:39 quizme: so that i can process string messages and compare them to what i called them as variables in my code

6:40 tomoj: O_o

6:40 quizme: sorry it's kind of mental hehe

6:40 fliebel: Sounds like the local variant of xxs attacks, or whatever they're called :P

6:40 quizme: it's just a toy example

6:41 LauJensen: (defmacro yourname? [x] (println (keys &env)))

6:41 user> (let [x 5] (yourname? x))

6:41 (x)

6:41

6:41 quizme: fullets that worked thanks

6:42 fliebel: LauJensen: How does that work? I mean the (keys &env part)

6:42 tomoj: why not just write "x" instead of (whats-your-name x)?

6:43 quizme: tomoj: lol i dunno probably haven't thought it through yet

6:43 LauJensen: fliebel: Its semi hacky the way I used it, because it will print all locals. Macros in 1.2 have 2 special vars &env to inspect locals and &form to see the meta-data of the form being called

6:43 quizme: but tomoj is right, its pointless. I just wanted to show the &env off :)

6:44 tomoj: (let [x 1 y 2] (yourname? george))

6:45 LauJensen: yea it'll print (x y)

6:57 quizme: http://pastie.org/1128695

6:57 it just kinda bugs me aesthetically.

7:01 tomoj: quizme: https://gist.github.com/d236d21d9c84d7a2a37c

7:01 fullets: That's pretty cool

7:02 tomoj: or even https://gist.github.com/9540cb130c19e85893e0

8:46 jgracin: Hi! Is there a clojure-mode version which makes swank-clojure.el superfluous? I seem to recall techomancy saying that...

8:47 I use the one whose commit id is 5006b3 and it doesn't work without swank-clojure.el.

9:00 raek: hrm, the clojure-mode on technomancy/clojure-mode doesn't work without swank-clojure.el?

9:01 iirc, in my setup, emacs does not know about swank-clojure.el at all

9:03 bobo_: i have some memory of swank-clojure beeing deprecated?

9:03 .el

9:04 Lajla: ->(let [I (fn [x y z] 3) Worship nil Your nil Shadow nil] (I worship your shadow))

9:04 no sexpbot. =(

9:06 raek: that commit is the latest version, so that's goof

9:06 *good

9:06 jgracin: raek: I can't get it to work. On C-M-x it doesn't find the proper namespace but evaluates in "user" namespace.

9:07 raek: jgracin: have you evaled the ns declaration at least once?

9:07 ...in that buffer

9:07 jgracin: raek: yes, the buffer is successfully compiled with C-c C-k.

9:07 raek: also, I found that the auto-complete thingy that was posted on the group recently brakes this

9:08 jgracin: I don't have auto-complete turned on.

9:08 raek: jgracin: I think you still need to C-M-x the ns form once

9:08 I always have to do that once

9:09 jgracin: It seems to me that C-M-x always finds out the namespace by itself.

9:10 raek: I think slime (or would it be swank?) remembers the namespace from the point it evals the ns form

9:10 this is my experience of it, of course

9:13 did you get it working? (and if so, did it work without evaling the ns?)

9:16 arnorhs: yo

9:16 did you write a tutorial raek?

9:16 raek: I'm writing it

9:16 it's not done yet

9:17 arnorhs: ok :)

9:17 bobo_: arnorhs: the one you retweeted i wrote

9:17 arnorhs: oh, really?

9:17 raek: link?

9:17 arnorhs: this one: http://cleancode.se/2010/08/30/getting-started-with-compojure.html ?

9:17 clojurebot: your link is dead

9:17 bobo_: yes

9:17 arnorhs: I'm reading it as we speak

9:17 :)

9:17 bobo_: please bash me if you find something bad :-)

9:17 arnorhs: heh, don't worry

9:18 raek: http://raek.se/clojure-emacs.html <-- this is the outline I'm filling in

9:18 bobo_: raek: oh looks pretty!

9:18 raek: I have only worked on it last saturday

9:19 but I will try to write something on it every day

9:19 sstathis made the awesome graph

9:25 arnorhs: raek: it's starting to look good

9:28 Is it possible to interface with swank from the command line?

9:30 for instance something like: lein swank < file.clj

9:30 except, that would never work, of course :)

9:30 bobo_: lein repl < file.clj?

9:30 arnorhs: but I'd like to really?

9:30 really?

9:30 bobo_: dont know, lets try!

9:30 arnorhs: that works?

9:32 bobo_: it seems to!

9:32 http://gist.github.com/559017

9:32 test.clj contained (+1 1)

9:44 arnorhs: bobo_: but if you have a running process, how would you add the file to that particular process?

9:44 do they maybe get tied together by the lein directory somehow?

9:48 bobo_: hm, yeh, that it cant do, i guess. but i see what you want to do.

9:49 arnorhs: I'm basically trying to do the same thing as you do using emacs via slime/swank, but from the command prompt

9:49 Lajla: I don't even want to know

9:50 Lajla: arnorhs, it was already registered. =(

9:50 I wished to seize it as mine own, yet alas another hath come before.

9:52 arnorhs: You know what I would want

9:53 ?

9:54 I want a script that starts lein repl, requires the right files and monitors if any of the files in the src folder have been modified and injects them into the process

9:54 But I probably just don't understand this stuff :)

10:02 mrBliss: Weird: every time I use Enlive's select function I get a java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.util.Map$Entry

10:02 I even tried the examples on github and the tutorial, they're also broken

10:02 The only thing I changed is switching from clojure-1.2-beta1 to 1.2

10:03 tomoj: switching back to beta1 fixes it?

10:04 mrBliss: I'm trying it now

10:05 it works under beta1!

10:06 I'm gonna try the RCs to isolate the breaking change

10:06 patrkris: LauJensen: i was thinking about whether you have tried ledger for book keeping? i think it'll make you far more productive :)

10:07 LauJensen: patrkris: You think Im spending too much time bookkeeping?

10:08 mrBliss: works under rc1

10:08 patrkris: LauJensen: no, i'm just thinking about your blog post about tools for maximum productivity

10:08 LauJensen: and thought maybe ledger was something for you

10:08 LauJensen: oh ok - I'm not familiar with Ledger, got link ?

10:08 patrkris: LauJensen: http://wiki.github.com/jwiegley/ledger/

10:09 LauJensen: works fine, I think

10:09 LauJensen: "Ledger is a powerful, double-entry accounting system that is accessed from the UNIX command-line" -- Im sold

10:09 patrkris: exactly :D

10:09 tomoj: mrBliss: where's the error coming from?

10:09 patrkris: LauJensen: there are a few things about sales taxes (moms) that could work better, but I've found a way to get around it

10:10 mrBliss: works under rc2

10:11 tomoj: I'll answer you when it breaks again

10:12 tomoj: :)

10:12 if some map type started giving lazy seqs instead of map entries... that would be Bad

10:12 that couldn't have happened, could it have?

10:12 Bahman: Hi all!

10:13 mrBliss: it works under rc3

10:14 so it should work under 1.2.0 final because they're almost (if not) identical

10:14 tomoj: all it takes is one bit

10:15 mrBliss: works under 1.2.0 final

10:15 I must have done something crazy

10:16 so the 'problem' is fixed :)

10:30 nlogax: hey. any good links for a clojure (and also java) noob? i can't even seem to get the classpath right :)

10:31 clojure itself works, but it won't find aleph and the other stuff i want to try

10:31 mrBliss: I recommend installing leiningen or cljr

10:33 chouser: or cake, right?

10:34 mrBliss: sure

10:43 raek: nlogax: check out http://github.com/technomancy/leiningen (when doing projects) and http://github.com/liebke/cljr (when just using the repl)

10:46 nlogax: i will check those tools out, thanks guys

10:47 i had leiningen installed already, just gotta find out how to use it properly :)

10:48 raek: leiningen, cljr and cake are tools for launching clojure and handling dependencies (among other things). one should not (in general) have to manage the classpath manually

10:49 nlogax: ahh.. i thought leiningen was like cabal-install or pip or something. now i know what i should do with it

10:57 jfields: is there a way in Java to create instances of the clojure runtime? I want to load a resource script into one RT, run a few functions and return the result. Then do the same thing in another RT, without any of the state from the first RT?

10:58 raek: I think the clojure RT is one-per-jvm

10:58 you want a sandbox or something?

10:58 chouser: there isn't really a clojure runtime

10:58 other than the jvm itself

10:58 jfields: yeah, I guess I need a sandbox. thanks tho.

10:59 chouser: if you want namespaces that can't see each other or something, you may be to able to use custom classloaders to get there. not sure.

10:59 raek: http://github.com/Licenser/clj-sandbox

11:00 could be worth checking out

11:05 Licenser: oh it certenly is raek :P

11:08 _na_ka_na_: guys me & my partner work on a clojure project.. on his macbookpro the project compiles in 30 secs ... but on my windows 7 desktop compilation takes no less than 3 minutes ..

11:09 I'm just talking about clojure.lang.Compiler

11:10 I've tried to switch off my anti virus but doesn't knocks off ~10 secs most

11:10 any ideas?

11:11 mrBliss: probably silly but have you tried defragging?

11:13 Licenser: _na_ka_na_: get him to buy a MBP

11:14 _na_ka_na_: Licenser: its me who has to buy I guess

11:14 Licenser: ah well even easyer then you just have to convince yourself :P

11:14 _na_ka_na_: its harder than you think :P

11:16 hardware is not an issue .. windows m/c specs are better ..

11:25 LauJensen: _na_ka_na_: Windows is slow, next question :)

11:25 _na_ka_na_: mrBliss: I'll try but don't think it would help, other things like hd video, games play fine

11:25 LauJensen: are you serious? Clojure is slow on windows?

11:25 I'll double check on some other windows m/c too

11:25 LauJensen: _na_ka_na_: Generally Windows performs (a little) worse than most alternatives. Its a gaming platform

11:25 mrBliss: compiling is much more io-based than watching hd-video (which cpu based)

11:26 chouser: clojure does a lot of sync's during AOT compilation. Some filesystems handle that better than others.

11:27 mrBliss: you could always use a ramdisk for compilation ;-)

11:27 _na_ka_na_: hehe

11:30 bartj: is there a "community guideline" for paren placement

11:30 as specified by fogus here - http://blog.fogus.me/2010/08/30/community-standards/

11:31 dnolen: bartj: http://mumble.net/~campbell/scheme/style.txt

11:32 bartj: dnolen, as specified by the clojure community ?

11:34 _fogus_: bartj: I don't see a guideline on that post

11:34 English syntax on the other hand...

11:36 bartj: er, I mean as discussed

11:37 I think you do discuss the need for some guideline

11:37 dnolen: bartj: the Clojure community seems to adopt existing Lisp standards as far as formatting goes.

11:38 _fogus_: bartj: Clojure is only mentioned as a a setup for a more general discussion

11:38 bartj: dnolen, ok

11:38 dnolen, thanks

11:39 I thought the community had discussed on some guideline

11:39 thanks again for the clarification

11:40 _fogus_: bartj: There is an assembla page listing some style guidelines, but I believe that is from the perspective of Clojure contributions

11:40 (I might be wrong)

11:58 cemerick: _na_ka_na_: Clojure is a champ on Windows. As chouser said, compiling is heavily IO-bound, so minutiae w.r.t. disk and filesystems, etc. can make a big difference. Don't let LauJensen worry you. :-)

11:59 _na_ka_na_: cemerick: I'm trying to convince a friend to try n compile code on his windows box :P

11:59 most probably there must be something wrong on my machine

12:01 bartj: I just read about ClojureCLR

12:01 and was a bit surprised that it is actually released so soon

12:03 cemerick: _na_ka_na_: defrag is a good idea, and there's always a risk of there being another process soaking up IOs.

12:05 I had a similar problem on OS X a few weeks ago (builds being really slow), and discovered that the spotlight indexing daemon was killing my IOs (though I didn't think to look for a time, because IOs aren't shown in the usual activity monitor CPU graph).

14:25 _na_ka_na_: ok I've confirmed its not a windows issue ... its compiling fine on one other windows m/c but that was XP .. I'm on 7

15:29 nlogax: i've created a project using leiningen, can i get a repl up and play around with my stuff?

15:30 BrianForester: nlogax: lein repl

15:30 __debaser: lein repl

15:31 nlogax: hmm, yes, that's what i tried. i've probably missed something crucial, i can't (:use it) or anything

15:31 BrianForester: what kind of error do you get?

15:32 nlogax: if i (:use 'mything) i just get nil

15:32 (yes, total clojure noob)

15:33 bobo_: i think you want (require 'mything)

15:33 (:use 'mything) imports the namespace, doesnt evaluate anything (right?)

15:34 nlogax: then it says it's not on my classpath

15:34 bobo_: what is 'mything?

15:34 raek: nlogax: either do (use 'mything) from the repl (which loads "src/mything.clj"), or put (ns myotherthing (:use mythin)) in, for example, "src/myotherthing.clj"

15:35 bobo_: use is like require, but also puts the vars of that namespace into the current

15:35 bobo_: hm, ok

15:35 raek: so that they can be used without a prefix (e.g. mything/some-function)

15:35 bobo_: ah

15:36 raek: nlogax: the error message should mention which file it tried to load, and from where

15:39 nlogax: raek: hmm, lein generated /src/clujo/core.clj, when i started a project named clujo. not sure how to load that. this is what it says: http://paste.pocoo.org/show/256831/

15:40 raek: nlogax: then you should use or require clujo.core

15:41 the file path reflects the namespace name

15:41 and vice versa

15:41 nlogax: tried that too, and got "lib names inside prefix lists must not contain periods"

15:42 raek: that means that you triy to use prefix lists in the wrong way

15:42 for example

15:43 nlogax: ohhh

15:43 the error is in my code now, i see

15:43 raek: instead of (ns foo (:use bar.a bar.b)) on can write (ns foo (:use (bar a b)))

15:43 but not

15:43 nlogax: i thought i was still failing at use-ing it :)

15:43 raek: (ns foo (:use bar.a bar.b.c)) -> (ns foo (:use (bar.a b.c))) ; not allowed

15:44 nlogax: makes sense now, thanks. now i can start to play with it

15:44 raek: this lists some examples, if you haven't seen it: http://clojure.org/libs

15:44 the_paal: Is this the right place to ask about clojure web frameworks?

15:45 nlogax: raek: thanks, now that part works :)

15:47 solussd: where can I find a copy of ants.clj these days?

15:47 raek: the file section of the google group

15:48 solussd: thanks

15:48 wow the group is "timing out"

15:49 raek: the_paal: this is the closes mail-wise http://groups.google.com/group/clojure-web-dev

15:49 but as for irc, I think this is the closest match

15:50 ants example: http://clojure.googlegroups.com/web/ants.clj?gda=pCTw8zoAAADKqc_OBXvAPFRl94RaAIUvn6aELI4KCTDaCWl-O0NLFe9OU0NQiFWgQuhmPR7veGf97daDQaep90o7AOpSKHW0

15:50 the_paal: thanks

15:50 solussd: raek: I get "An error occurred while processing your request..."

15:50 raek: *but as for irc, I think #clojure (or maybe #compojure) is the closest match

15:51 solussd: I copied it here: http://raek.se/ants.clj

15:51 solussd: thanks

15:53 arbscht: you could idle in #clojure-web if you like -- it's supposed to be more general than #compojure

15:53 the_paal: thanks

16:11 BrianForester: there has to be a concise way of converting '((1 2 3) (4 5 6)) into "4\t5\t6\n1\t2\t3"

16:11 this is what I have working...http://gist.github.com/559655

16:14 arbscht: ,(apply str (flatten (interpose \newline (map #(interpose \tab %) (reverse '((1 2 3) (4 5 6)))))))

16:14 clojurebot: "4\t5\t6\n1\t2\t3"

16:14 arbscht: something like that

16:14 AWizzArd: yes, I also had something similar in mind

16:15 chouser: ,(use '[clojure.string :only [join]])

16:15 clojurebot: nil

16:15 chouser: ,(join "\n" (map #(join "\t" %) '((1 2 3) (4 5 6))))

16:15 clojurebot: "1\t2\t3\n4\t5\t6"

16:15 AWizzArd: plus reverse

16:15 raek: ,(->> '((1 2 3) (4 5 6)) (map #(interpose \tab %)) (interpose \newline) flatten (apply str))

16:15 clojurebot: "1\t2\t3\n4\t5\t6"

16:15 AWizzArd: he wants 4 5 6 1 2 3

16:15 chouser: oh, whoops. missed the reverse

16:15 AWizzArd: BrianForester: There is really no very concise way, as this is a pretty specific thing you want to do

16:18 BrianForester: thanks all. I was missing the interpose function.

16:20 kumarshantanu: arbscht: this looks like would do -- (apply str (interpose \tab (flatten (reverse coll)))) ;; where coll is the collection

16:21 arbscht: kumarshantanu: there's a \n in the middle :)

16:22 kumarshantanu: arbscht: Argh! :-D

16:23 BrianForester: arbscht: Yes, I'm using apache poi to convert some MS excel files into a set of tab deliminated files.

16:32 slyrus: ,(apply str (interpose (str \newline) (reverse (map #(apply str %) (map (partial interpose \tab) [[1 2 3] [4 5 6]])))))

16:32 clojurebot: "4\t5\t6\n1\t2\t3"

16:35 BrianForester: ,(doc ->>)

16:35 clojurebot: "([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."

16:35 raek: (->> x (f1 a) f2 (f3 b) f4) ==> (f4 (f3 b (f2 (f1 a x))))

16:43 kumarshantanu: arbscht: this seems to be working -- (apply str (flatten (interpose \newline (into [] (for [each (reverse coll)] (into [] (interpose \tab each))))))) ;; coll is collection

16:45 ,(apply str (flatten (interpose \newline (into [] (for [each (reverse '((4 5 6) (1 2 3)))] (into [] (interpose \tab each)))))))

16:45 clojurebot: "1\t2\t3\n4\t5\t6"

16:48 arbscht: kumarshantanu: (into ...) looks redundant

16:48 nlogax: can i reload stuff in the lein repl? (:use 'it) again doesn't seem to reload

16:49 having a blast btw

16:49 kumarshantanu: arbscht: interpose creates lazy seq, into realizes it -- that's a hack :)

16:49 Raynes: nlogax: You can pass a :reload option to require and use.

16:50 nlogax: Raynes: awesome, thanks!

16:51 yayitswei: nlogax: if you use slime, you can press C-x C-k to recompile and reload your whole file

16:51 Raynes: He's using lein repl, apparently.

16:51 nlogax: yayitswei: i don't, but i'll try it :)

16:53 arbscht: kumarshantanu: is there a problem with having lazy seqs?

16:53 slyrus: kumarshantanu: I like my (cleaned up) version better: (apply str (interpose \newline (reverse (map #(apply str (interpose \tab %)) [[1 2 3] [4 5 6]]))))

16:53 ,(apply str (interpose \newline (reverse (map #(apply str (interpose \tab %)) [[1 2 3] [4 5 6]]))))

16:54 clojurebot: "4\t5\t6\n1\t2\t3"

16:54 kumarshantanu: arbscht: not really, but i needed to roll them inside a vector 'cause it wasn't giving correct order with a list

16:57 slyrus: your version looks neat -- will it work with '((1 2 3)(4 5 6)) ?

16:58 ,(apply str (interpose \newline (reverse (map #(apply str (interpose \tab %)) ((1 2 3) (4 5 6))))))

16:58 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

16:58 raek: interpose and friends will call seq on the vectors anyway

16:58 kumarshantanu: ,(apply str (interpose \newline (reverse (map #(apply str (interpose \tab %)) '((1 2 3) (4 5 6))))))

16:58 clojurebot: "4\t5\t6\n1\t2\t3"

16:58 kumarshantanu: yup. it works

16:58 raek: ,(seq [1 2 3])

16:58 clojurebot: (1 2 3)

16:59 raek: ,(seq '(1 2 3))

16:59 clojurebot: (1 2 3)

16:59 raek: the sequence funtions don

16:59 't care about the type of the collection

16:59 it only looks at the sequence view of it

17:25 BrianForester: I was unwrapping raek's solution: (str (flatten (interpose \newline (map #(interpose \tab %) '((1 2 3) (4 5 6)))))) which returns a lazy seq; how do I force evaluation?

17:25 ,(str (doall (flatten (interpose \newline (map #(interpose \tab %) '((1 2 3) (4 5 6)))))))

17:25 clojurebot: "clojure.lang.LazySeq@b29e7546"

17:26 chouser: just get rid of the outer str

17:26 BrianForester: different way to convert the list to string?

17:27 kumarshantanu: BrianForester: (apply str any-lazy-seq)

17:28 BrianForester: thanks kumarshantanu

17:30 chouser: ,(str (range 4))

17:30 clojurebot: "clojure.lang.LazySeq@e1b83"

17:30 chouser: ,(pr-str (range 4))

17:30 clojurebot: "(0 1 2 3)"

17:30 chouser: ,(apply str (range 4))

17:30 clojurebot: "0123"

17:35 * slyrus thinks flatten is a crutch and that there's usually a better, more precise tool for the job at hand

17:36 chouser: slyrus: I don't know that I'd say it quite that strongly, but I have rarely used it in final solutions.

17:36 slyrus: hey, I said _usually_ :)

17:36 BrianForester: thanks for the help all, later.

17:56 anonymouse89: I am trying to defn with a name constructed from two keywords

17:57 so :abc :def should be like (defn abc_def

17:57 but, I'm not sure how this can be done

17:57 arohner: anonymouse89: with a macro

17:58 anonymouse89: arohner: ok, I may have been putting off heading into macro land for too long

18:02 and is there a shortcut for going from keyword to string without the colon?

18:03 rhickey: name

18:03 msf: does anyone know of an example cojure application that uses a configuration file ?

18:03 rhickey: ,(name :fred)

18:03 clojurebot: "fred"

18:03 anonymouse89: rhickey: thanks much

18:07 fsmunoz: msf: not strictly a configuration file, but mire uses a separate file to store game data, and swallows it...

18:41 kencausey: chouser: The clear function defined in JoC 3.4.4 and used in 3.4.5 isn't much good with fixed dimensions.

18:42 the frame should be the argument rather than the graphic

18:49 (defn clear [frame]

18:49 (let [d (.size frame)]

18:49 (.clearRect (.getGraphics frame) 0 0 (.height d) (.width d))))

18:51 I think it's also better to define draw-values to take the frame as an argument and get the graphics context from it

19:49 Raynes: http://www.reddit.com/r/Clojure/comments/d7uv2/state_of_clojure_after_oracles_moves_with_javajvm/

20:16 dnolen_: is it possible to find out the arity or arglist of an anonymous function?

20:17 AWizzArd: You can use reflection.

20:18 There currently is no real Clojure-Introspection yet which allows you to do this.

20:19 dnolen_: AWizzard: do what methods let you examine an anonymous fn?

20:23 AWizzArd: with reflection you can analyze everything

21:01 dnolen_: I don't suppose there's a destructuring syntax for saying that you just want the last element is there?

21:01 Raynes: Nosir.

21:01 It would be cool to be able to destructure from the back.

21:11 pbuckley: anyone know how long it typically takes for your first post to the clojure google group to get moderated?

21:12 nm, just saw that it went through but no replies yet

21:13 /erc-cmd-N

21:13 erc-cmd-N

22:48 johnmn3: hello

22:49 so I wanted to play around with extend-type a little bit.

22:49 but before I go on.. can anyone hear me? is this working?

22:50 I've had this not work before, where I wasn't logged on correctly and I talked to my self for 5 minutes :/

22:51 scottj: johnmn3: it's working

22:52 arnorhs: no it's not

22:52 I can't hear you

22:53 johnmn3: sweet! ok.. I want to make it so that (re-find #"thing" "another thing") works as (#"thing" "another thing") .. much like "maps are functions of their keys"

22:54 arnorhs: what's that?

22:55 So I thought I'd do an (extend-type java.util.regex.Pattern clojure.lang IFn (...

22:55 ihodes: johnmn3: you'd have to implement that as a reader macro: basically, tell Clojure's reader that (#"…" means (re-find #"…"

22:55 johnmn3: The question is, what to put in the (...

22:55 hiredman: johnmn3: you can't do that

22:55 johnmn3: ihodes, why can't i just make a thing implement IFn?

22:56 hiredman: you can do that

22:56 johnmn3: and implement the (applyTo

22:56 hiredman: but you can't make something that implements Pattern and IFn

22:56 johnmn3: why not?

22:56 hiredman: Pattern is a final class

22:57 johnmn3: mmm.

22:57 hiredman: and you can't add interfaces to classes

22:57 and I am fairly certain extend-type works with Protocols not Interfaces

22:58 johnmn3: I think it does both, sometimes

22:58 hiredman: I doubt that very much

22:58 because you just can't add an interface to a class

23:00 johnmn3: I thought I remember reading about some interoperability with interfaces.. maybe you can extend interfaces with extend-protocol?

23:00 hiredman: you may be confused because Protocols compile to Interfaces + plus other stuff

23:00 you cannot extend an interface

23:02 johnmn3: so there is not anyway to extend existing things, like a string or a number, so that it can be used in the function position?

23:02 other than a reader-macro?

23:02 hiredman: no a reader macro won't do it either

23:02 you can extend protocols to classes

23:02 but, IFn is not a protocol

23:04 johnmn3: right.. and clojure won't accept anything in the function position that does not implement IFn, right?

23:04 hiredman: correct

23:05 johnmn3: hmm. Okay, that settles it then. Thanks.\

23:10 ihodes: hiredman: you couldn't accomplish this with a reader macro? why is that?

23:10 scottj: johnmn3: so when clojure is written in clojure and ifn is a protocol then maybe you'd be able to do it

23:10 hiredman: a reader macro will not get you a regex you can call as a function

23:10 IFn will most likely never be a protocol

23:11 as fast as protocols can be there is some overhead compared to an interface

23:12 ihodes: hiredman: i see you're saying that, but why? i thought you could make a reader macro expand something it sees into something else, so if it saw, e.g., (#"..." … it could transform that into (re-find #"..." ...

23:12 johnmn3: hiredman: could you not make a reader macro that builds a Matcher?

23:13 or (re-find (re-matcher "string" ...

23:14 Raynes: hiredman: There is an example in The Joy of Clojure where they extend String with a protocol. Something like that.

23:14 johnmn3: mmm

23:14 re-pattern is what I meant: (re-pattern "\\d+")

23:15 hiredman: Raynes: what about it?

23:15 you can extend protocols to classes

23:15 Raynes: Oh, never mind. I thought you were saying protocols couldn't be extended to classes.

23:15 Reading comprehension is nil tonight.

23:16 hiredman: because protocols are interfaces + indirection

23:16 Raynes: Aye.

23:16 hiredman: which makes them more flexible

23:16 johnmn3: you could, but it would not be callable as a function

23:17 ihodes: hiredman: but you could have something like (#"hi" "hi") => true, right?

23:18 hiredman: sorry I gotta go

23:18 Raynes: Bai!

23:19 ihodes: johnmn3: well i'm fairly certain you could make this a reader macro - you wouldn't be able to do function thing with it, though: no mapping, comping etc, but (#"…" would transform into (re-find (or whatever you're looking for ) #"..." ... )

23:19 function things* it's be like a macro, but a special, reader macro

23:19 if you look in LispReader.java, you should see what you can do

23:20 (i think that's the file…)

23:20 but in short, you can't really do this strictly within Clojure, i guess :)

23:21 johnmn3: I don't have a need burning enough to go messing with the java, I just wondered if it'd be possible.. I'd prefer my suggested syntax for regex' as short-hand

23:22 seems to me (#"thing" "some thing") is clear enough

23:22 or even ("some thing" #"thing"), either way

23:23 were it possible to rig it up, I would have added it to my tool-box.

23:23 ihodes: that'd be nice, but AFAIK not possible right now. but i could certainly be wrong.

23:25 pdk: ,(* (* 2000 4) 12)

23:25 clojurebot: 96000

Logging service provided by n01se.net