#clojure logs

2010-08-31

00:00ataggartIs there a way to call clojure.lang.Numbers/shiftLeftInt without the primitives getting autoboxed to intermediate objects?
00:01ataggarttrying to do a lot of byte ops and I'm guessing this is where the slowdown is
00:12scottjmaybe one of the special branches, like prim?
00:13tomojhow do you even tell whether stuff is getting boxed?
00:14technomancyprim is in 1.3 now iirc
00:15notsonerdysunnymy messages are not appearing on the forum :(
00:15ataggartah, I had forgotten about the prim stuff
00:18Chousukenotsonerdysunny: hm.
00:18notsonerdysunnyno ... sorry .. I just found it :)
00:18ChousukeAh, good.
00:19ChousukeI was about to tell you to poke chouser, as he's a group moderator :P
00:19Chousukeat least IIRC.
00:48_na_ka_na_guys does compojure 0.4.1 work with clojure 1.2?
00:49_na_ka_na_what about one of 0.3.x ?
00:59_na_ka_na_someone on #compojure answers 0.4.1 works with clojure 1.2, 0.3.x prob doesn't
01:05scottjI 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
01:08_na_ka_na_scottj: how do i search for it
01:10_na_ka_na_this must be it .. org.clojars.bmabey/compojure 0.3.3-SNAPSHOT
01:10_na_ka_na_let me try
01:18bortrebhow do I do a primitive int type hint for clojure? #^int doesn't work....
01:32ataggartyou don't unless you're working in the master branch
01:34bartj, (clojure.set/intersection [[1 2 3] [2 3]])
01:34clojurebot[[1 2 3] [2 3]]
01:34bartjI was expecting: [2 3] on the above statement
01:35bartjoh, they should be sets and not vectors...mea culpa
01:35bartj, (clojure.set/intersection #{1 2 3} #{2 3})
01:35clojurebot#{2 3}
03:36LauJensenGood morning all
03:40lenwMorning LauJensen
03:43adityogood morning :)
03:43LauJensenclojure.lang.RT/baseLoader extends URLClassLoader and has a method called getResourceAsStream - Any idea where thats implmented? (not in DynamicClassLoader.java or in URLClassLoader)
03:43LauJensenah, silly me, its inherited from java.lang.ClassLoader, nvm
05:40serp_is there an idiomatic way of doing a priority queue?
05:45LauJensenA 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
05:45LauJensen-> (str (java.util.UUID/randomUUID))
05:45LauJensen,(str (java.util.UUID/randomUUID))
05:45clojurebot"b5b0df74-f15a-4995-97b9-ab7315241e77"
05:56notsonerdysunny,(java.util.UUID/randomUUID)
05:56clojurebot#<UUID d1ffd517-7132-4c70-acb6-8e719bc3685e>
05:56notsonerdysunny,(java.util.UUID/randomUUID)
05:56clojurebot#<UUID a3bda2ea-7245-4f64-aab0-c90ebf6e9d47>
05:57serp_what are the semantics of a queue in clojure?
05:57serp_(with respect to concurrency)
05:58tomojnothing special
05:59tomojif you mean PersistentQueue, that is
06:00serp_those are mutable though
06:00serp_I'd like an immutable queue, but perhaps that makes no sense :)
06:02LauJensenserp_: Nearly all talk of queues end up with people writing their own wrapper for LinkedBlockingQueue
06:03tomojPersistentQueues aren't mutable
06:03tomojand if you want an immutable queue, why are you asking about concurrency semantics?
06:03tomojif it's immutable, it has the same semantics with respect to concurrency as all the other immutable stuff: it can't change at all!
06:05serp_LauJensen: all right
06:08serp_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
06:09tomojah, no
06:09tomoj,(-> clojure.lang.PersistentQueue/EMPTY (conj 1) (conj 2) peek)
06:09clojurebot1
06:10tomojsince you said "priority" earlier I think this won't help, though
06:13serp_hm
06:16serp_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.
06:17fliebelmorning
06:17serp_though obviously I'm a clojure noob, so what do I know
06:31LauJensenclojurebot: where are you ?
06:31clojurebothttp://github.com/hiredman/clojurebot/tree/master
06:32fliebelclojurebot: do you have a list of commands? :P
06:32clojurebotparedit commands is http://mumble.net/~campbell/emacs/paredit.html
06:33LauJensenclojurebot: whats the maximum size of a POST request?
06:33clojurebotexcusez-moi
06:35quizmeis there a function that gives the name of the variable as a string or symbol?
06:36LauJensen,(symbol "this")
06:36clojurebotthis
06:36LauJensen,(str 'this)
06:36clojurebot"this"
06:36quizmety :)
06:36fliebelwhat was the one with teh colon in front?
06:36quizmelemme try that
06:37LauJensen,(name :this)
06:37clojurebot"this"
06:37fliebeland the inverse of that?
06:37quizmehow about
06:37quizme(def x 3)
06:37quizme(whats-your-name x)
06:37quizme=> "x"
06:38quizmeany way to do that?
06:38tomojwhy would you want to do that?
06:38fullets(defmacro whats-your-name [s] (name s))
06:39quizmeso that i can process string messages and compare them to what i called them as variables in my code
06:40tomojO_o
06:40quizmesorry it's kind of mental hehe
06:40fliebelSounds like the local variant of xxs attacks, or whatever they're called :P
06:40quizmeit's just a toy example
06:41LauJensen(defmacro yourname? [x] (println (keys &env)))
06:41LauJensenuser> (let [x 5] (yourname? x))
06:41LauJensen(x)
06:41LauJensen
06:41quizmefullets that worked thanks
06:42fliebelLauJensen: How does that work? I mean the (keys &env part)
06:42tomojwhy not just write "x" instead of (whats-your-name x)?
06:43quizmetomoj: lol i dunno probably haven't thought it through yet
06:43LauJensenfliebel: 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
06:43LauJensenquizme: but tomoj is right, its pointless. I just wanted to show the &env off :)
06:44tomoj(let [x 1 y 2] (yourname? george))
06:45LauJensenyea it'll print (x y)
06:57quizmehttp://pastie.org/1128695
06:57quizmeit just kinda bugs me aesthetically.
07:01tomojquizme: https://gist.github.com/d236d21d9c84d7a2a37c
07:01fulletsThat's pretty cool
07:02tomojor even https://gist.github.com/9540cb130c19e85893e0
08:46jgracinHi! Is there a clojure-mode version which makes swank-clojure.el superfluous? I seem to recall techomancy saying that...
08:47jgracinI use the one whose commit id is 5006b3 and it doesn't work without swank-clojure.el.
09:00raekhrm, the clojure-mode on technomancy/clojure-mode doesn't work without swank-clojure.el?
09:01raekiirc, in my setup, emacs does not know about swank-clojure.el at all
09:03bobo_i have some memory of swank-clojure beeing deprecated?
09:03bobo_.el
09:04Lajla->(let [I (fn [x y z] 3) Worship nil Your nil Shadow nil] (I worship your shadow))
09:04Lajlano sexpbot. =(
09:06raekthat commit is the latest version, so that's goof
09:06raek*good
09:06jgracinraek: I can't get it to work. On C-M-x it doesn't find the proper namespace but evaluates in "user" namespace.
09:07raekjgracin: have you evaled the ns declaration at least once?
09:07raek...in that buffer
09:07jgracinraek: yes, the buffer is successfully compiled with C-c C-k.
09:07raekalso, I found that the auto-complete thingy that was posted on the group recently brakes this
09:08jgracinI don't have auto-complete turned on.
09:08raekjgracin: I think you still need to C-M-x the ns form once
09:08raekI always have to do that once
09:09jgracinIt seems to me that C-M-x always finds out the namespace by itself.
09:10raekI think slime (or would it be swank?) remembers the namespace from the point it evals the ns form
09:10raekthis is my experience of it, of course
09:13raekdid you get it working? (and if so, did it work without evaling the ns?)
09:16arnorhsyo
09:16arnorhsdid you write a tutorial raek?
09:16raekI'm writing it
09:16raekit's not done yet
09:17arnorhsok :)
09:17bobo_arnorhs: the one you retweeted i wrote
09:17arnorhsoh, really?
09:17raeklink?
09:17arnorhsthis one: http://cleancode.se/2010/08/30/getting-started-with-compojure.html ?
09:17clojurebotyour link is dead
09:17bobo_yes
09:17arnorhsI'm reading it as we speak
09:17arnorhs:)
09:17bobo_please bash me if you find something bad :-)
09:17arnorhsheh, don't worry
09:18raekhttp://raek.se/clojure-emacs.html <-- this is the outline I'm filling in
09:18bobo_raek: oh looks pretty!
09:18raekI have only worked on it last saturday
09:19raekbut I will try to write something on it every day
09:19raeksstathis made the awesome graph
09:25arnorhsraek: it's starting to look good
09:28arnorhsIs it possible to interface with swank from the command line?
09:30arnorhsfor instance something like: lein swank < file.clj
09:30arnorhsexcept, that would never work, of course :)
09:30bobo_lein repl < file.clj?
09:30arnorhsbut I'd like to really?
09:30arnorhsreally?
09:30bobo_dont know, lets try!
09:30arnorhsthat works?
09:32bobo_it seems to!
09:32bobo_http://gist.github.com/559017
09:32bobo_test.clj contained (+1 1)
09:44arnorhsbobo_: but if you have a running process, how would you add the file to that particular process?
09:44arnorhsdo they maybe get tied together by the lein directory somehow?
09:48bobo_hm, yeh, that it cant do, i guess. but i see what you want to do.
09:49arnorhsI'm basically trying to do the same thing as you do using emacs via slime/swank, but from the command prompt
09:49arnorhsLajla: I don't even want to know
09:50Lajlaarnorhs, it was already registered. =(
09:50LajlaI wished to seize it as mine own, yet alas another hath come before.
09:52arnorhsYou know what I would want
09:53arnorhs?
09:54arnorhsI 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
09:54arnorhsBut I probably just don't understand this stuff :)
10:02mrBlissWeird: 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:02mrBlissI even tried the examples on github and the tutorial, they're also broken
10:02mrBlissThe only thing I changed is switching from clojure-1.2-beta1 to 1.2
10:03tomojswitching back to beta1 fixes it?
10:04mrBlissI'm trying it now
10:05mrBlissit works under beta1!
10:06mrBlissI'm gonna try the RCs to isolate the breaking change
10:06patrkrisLauJensen: i was thinking about whether you have tried ledger for book keeping? i think it'll make you far more productive :)
10:07LauJensenpatrkris: You think Im spending too much time bookkeeping?
10:08mrBlissworks under rc1
10:08patrkrisLauJensen: no, i'm just thinking about your blog post about tools for maximum productivity
10:08patrkrisLauJensen: and thought maybe ledger was something for you
10:08LauJensenoh ok - I'm not familiar with Ledger, got link ?
10:08patrkrisLauJensen: http://wiki.github.com/jwiegley/ledger/
10:09patrkrisLauJensen: works fine, I think
10:09LauJensen"Ledger is a powerful, double-entry accounting system that is accessed from the UNIX command-line" -- Im sold
10:09patrkrisexactly :D
10:09tomojmrBliss: where's the error coming from?
10:09patrkrisLauJensen: there are a few things about sales taxes (moms) that could work better, but I've found a way to get around it
10:10mrBlissworks under rc2
10:11mrBlisstomoj: I'll answer you when it breaks again
10:12tomoj:)
10:12tomojif some map type started giving lazy seqs instead of map entries... that would be Bad
10:12tomojthat couldn't have happened, could it have?
10:12BahmanHi all!
10:13mrBlissit works under rc3
10:14mrBlissso it should work under 1.2.0 final because they're almost (if not) identical
10:14tomojall it takes is one bit
10:15mrBlissworks under 1.2.0 final
10:15mrBlissI must have done something crazy
10:16mrBlissso the 'problem' is fixed :)
10:30nlogaxhey. any good links for a clojure (and also java) noob? i can't even seem to get the classpath right :)
10:31nlogaxclojure itself works, but it won't find aleph and the other stuff i want to try
10:31mrBlissI recommend installing leiningen or cljr
10:33chouseror cake, right?
10:34mrBlisssure
10:43raeknlogax: check out http://github.com/technomancy/leiningen (when doing projects) and http://github.com/liebke/cljr (when just using the repl)
10:46nlogaxi will check those tools out, thanks guys
10:47nlogaxi had leiningen installed already, just gotta find out how to use it properly :)
10:48raekleiningen, 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:49nlogaxahh.. i thought leiningen was like cabal-install or pip or something. now i know what i should do with it
10:57jfieldsis 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:58raekI think the clojure RT is one-per-jvm
10:58raekyou want a sandbox or something?
10:58chouserthere isn't really a clojure runtime
10:58chouserother than the jvm itself
10:58jfieldsyeah, I guess I need a sandbox. thanks tho.
10:59chouserif 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:59raekhttp://github.com/Licenser/clj-sandbox
11:00raekcould be worth checking out
11:05Licenseroh 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_na_ka_na_I'm just talking about clojure.lang.Compiler
11:10_na_ka_na_I've tried to switch off my anti virus but doesn't knocks off ~10 secs most
11:10_na_ka_na_any ideas?
11:11mrBlissprobably silly but have you tried defragging?
11:13Licenser_na_ka_na_: get him to buy a MBP
11:14_na_ka_na_Licenser: its me who has to buy I guess
11:14Licenserah well even easyer then you just have to convince yourself :P
11:14_na_ka_na_its harder than you think :P
11:16_na_ka_na_hardware is not an issue .. windows m/c specs are better ..
11:25LauJensen_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_na_ka_na_LauJensen: are you serious? Clojure is slow on windows?
11:25_na_ka_na_I'll double check on some other windows m/c too
11:25LauJensen_na_ka_na_: Generally Windows performs (a little) worse than most alternatives. Its a gaming platform
11:25mrBlisscompiling is much more io-based than watching hd-video (which cpu based)
11:26chouserclojure does a lot of sync's during AOT compilation. Some filesystems handle that better than others.
11:27mrBlissyou could always use a ramdisk for compilation ;-)
11:27_na_ka_na_hehe
11:30bartjis there a "community guideline" for paren placement
11:30bartjas specified by fogus here - http://blog.fogus.me/2010/08/30/community-standards/
11:31dnolenbartj: http://mumble.net/~campbell/scheme/style.txt
11:32bartjdnolen, as specified by the clojure community ?
11:34_fogus_bartj: I don't see a guideline on that post
11:34_fogus_English syntax on the other hand...
11:36bartjer, I mean as discussed
11:37bartjI think you do discuss the need for some guideline
11:37dnolenbartj: 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:38bartjdnolen, ok
11:38bartjdnolen, thanks
11:39bartjI thought the community had discussed on some guideline
11:39bartjthanks 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_fogus_(I might be wrong)
11:58cemerick_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_na_ka_na_most probably there must be something wrong on my machine
12:01bartjI just read about ClojureCLR
12:01bartjand was a bit surprised that it is actually released so soon
12:03cemerick_na_ka_na_: defrag is a good idea, and there's always a risk of there being another process soaking up IOs.
12:05cemerickI 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:29nlogaxi've created a project using leiningen, can i get a repl up and play around with my stuff?
15:30BrianForesternlogax: lein repl
15:30__debaserlein repl
15:31nlogaxhmm, yes, that's what i tried. i've probably missed something crucial, i can't (:use it) or anything
15:31BrianForesterwhat kind of error do you get?
15:32nlogaxif i (:use 'mything) i just get nil
15:32nlogax(yes, total clojure noob)
15:33bobo_i think you want (require 'mything)
15:33bobo_(:use 'mything) imports the namespace, doesnt evaluate anything (right?)
15:34nlogaxthen it says it's not on my classpath
15:34bobo_what is 'mything?
15:34raeknlogax: 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:35raekbobo_: use is like require, but also puts the vars of that namespace into the current
15:35bobo_ hm, ok
15:35raekso that they can be used without a prefix (e.g. mything/some-function)
15:35bobo_ah
15:36raeknlogax: the error message should mention which file it tried to load, and from where
15:39nlogaxraek: 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:40raeknlogax: then you should use or require clujo.core
15:41raekthe file path reflects the namespace name
15:41raekand vice versa
15:41nlogaxtried that too, and got "lib names inside prefix lists must not contain periods"
15:42raekthat means that you triy to use prefix lists in the wrong way
15:42raekfor example
15:43nlogaxohhh
15:43nlogaxthe error is in my code now, i see
15:43raekinstead of (ns foo (:use bar.a bar.b)) on can write (ns foo (:use (bar a b)))
15:43raekbut not
15:43nlogaxi thought i was still failing at use-ing it :)
15:43raek(ns foo (:use bar.a bar.b.c)) -> (ns foo (:use (bar.a b.c))) ; not allowed
15:44nlogaxmakes sense now, thanks. now i can start to play with it
15:44raekthis lists some examples, if you haven't seen it: http://clojure.org/libs
15:44the_paalIs this the right place to ask about clojure web frameworks?
15:45nlogaxraek: thanks, now that part works :)
15:47solussdwhere can I find a copy of ants.clj these days?
15:47raekthe file section of the google group
15:48solussdthanks
15:48solussdwow the group is "timing out"
15:49raekthe_paal: this is the closes mail-wise http://groups.google.com/group/clojure-web-dev
15:49raekbut as for irc, I think this is the closest match
15:50raekants example: http://clojure.googlegroups.com/web/ants.clj?gda=pCTw8zoAAADKqc_OBXvAPFRl94RaAIUvn6aELI4KCTDaCWl-O0NLFe9OU0NQiFWgQuhmPR7veGf97daDQaep90o7AOpSKHW0
15:50the_paalthanks
15:50solussdraek: I get "An error occurred while processing your request..."
15:50raek*but as for irc, I think #clojure (or maybe #compojure) is the closest match
15:51raeksolussd: I copied it here: http://raek.se/ants.clj
15:51solussdthanks
15:53arbschtyou could idle in #clojure-web if you like -- it's supposed to be more general than #compojure
15:53the_paalthanks
16:11BrianForesterthere has to be a concise way of converting '((1 2 3) (4 5 6)) into "4\t5\t6\n1\t2\t3"
16:11BrianForesterthis is what I have working...http://gist.github.com/559655
16:14arbscht,(apply str (flatten (interpose \newline (map #(interpose \tab %) (reverse '((1 2 3) (4 5 6)))))))
16:14clojurebot"4\t5\t6\n1\t2\t3"
16:14arbschtsomething like that
16:14AWizzArdyes, I also had something similar in mind
16:15chouser,(use '[clojure.string :only [join]])
16:15clojurebotnil
16:15chouser,(join "\n" (map #(join "\t" %) '((1 2 3) (4 5 6))))
16:15clojurebot"1\t2\t3\n4\t5\t6"
16:15AWizzArdplus reverse
16:15raek,(->> '((1 2 3) (4 5 6)) (map #(interpose \tab %)) (interpose \newline) flatten (apply str))
16:15clojurebot"1\t2\t3\n4\t5\t6"
16:15AWizzArdhe wants 4 5 6 1 2 3
16:15chouseroh, whoops. missed the reverse
16:15AWizzArdBrianForester: There is really no very concise way, as this is a pretty specific thing you want to do
16:18BrianForesterthanks all. I was missing the interpose function.
16:20kumarshantanuarbscht: this looks like would do -- (apply str (interpose \tab (flatten (reverse coll)))) ;; where coll is the collection
16:21arbschtkumarshantanu: there's a \n in the middle :)
16:22kumarshantanuarbscht: Argh! :-D
16:23BrianForesterarbscht: Yes, I'm using apache poi to convert some MS excel files into a set of tab deliminated files.
16:32slyrus,(apply str (interpose (str \newline) (reverse (map #(apply str %) (map (partial interpose \tab) [[1 2 3] [4 5 6]])))))
16:32clojurebot"4\t5\t6\n1\t2\t3"
16:35BrianForester,(doc ->>)
16:35clojurebot"([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:35raek(->> x (f1 a) f2 (f3 b) f4) ==> (f4 (f3 b (f2 (f1 a x))))
16:43kumarshantanuarbscht: this seems to be working -- (apply str (flatten (interpose \newline (into [] (for [each (reverse coll)] (into [] (interpose \tab each))))))) ;; coll is collection
16:45kumarshantanu,(apply str (flatten (interpose \newline (into [] (for [each (reverse '((4 5 6) (1 2 3)))] (into [] (interpose \tab each)))))))
16:45clojurebot"1\t2\t3\n4\t5\t6"
16:48arbschtkumarshantanu: (into ...) looks redundant
16:48nlogaxcan i reload stuff in the lein repl? (:use 'it) again doesn't seem to reload
16:49nlogaxhaving a blast btw
16:49kumarshantanuarbscht: interpose creates lazy seq, into realizes it -- that's a hack :)
16:49Raynesnlogax: You can pass a :reload option to require and use.
16:50nlogaxRaynes: awesome, thanks!
16:51yayitsweinlogax: if you use slime, you can press C-x C-k to recompile and reload your whole file
16:51RaynesHe's using lein repl, apparently.
16:51nlogaxyayitswei: i don't, but i'll try it :)
16:53arbschtkumarshantanu: is there a problem with having lazy seqs?
16:53slyruskumarshantanu: I like my (cleaned up) version better: (apply str (interpose \newline (reverse (map #(apply str (interpose \tab %)) [[1 2 3] [4 5 6]]))))
16:53slyrus,(apply str (interpose \newline (reverse (map #(apply str (interpose \tab %)) [[1 2 3] [4 5 6]]))))
16:54clojurebot"4\t5\t6\n1\t2\t3"
16:54kumarshantanuarbscht: not really, but i needed to roll them inside a vector 'cause it wasn't giving correct order with a list
16:57kumarshantanuslyrus: your version looks neat -- will it work with '((1 2 3)(4 5 6)) ?
16:58kumarshantanu,(apply str (interpose \newline (reverse (map #(apply str (interpose \tab %)) ((1 2 3) (4 5 6))))))
16:58clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
16:58raekinterpose and friends will call seq on the vectors anyway
16:58kumarshantanu,(apply str (interpose \newline (reverse (map #(apply str (interpose \tab %)) '((1 2 3) (4 5 6))))))
16:58clojurebot"4\t5\t6\n1\t2\t3"
16:58kumarshantanuyup. it works
16:58raek,(seq [1 2 3])
16:58clojurebot(1 2 3)
16:59raek,(seq '(1 2 3))
16:59clojurebot(1 2 3)
16:59raekthe sequence funtions don
16:59raek't care about the type of the collection
16:59raekit only looks at the sequence view of it
17:25BrianForesterI 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:25BrianForester,(str (doall (flatten (interpose \newline (map #(interpose \tab %) '((1 2 3) (4 5 6)))))))
17:25clojurebot"clojure.lang.LazySeq@b29e7546"
17:26chouserjust get rid of the outer str
17:26BrianForesterdifferent way to convert the list to string?
17:27kumarshantanuBrianForester: (apply str any-lazy-seq)
17:28BrianForesterthanks kumarshantanu
17:30chouser,(str (range 4))
17:30clojurebot"clojure.lang.LazySeq@e1b83"
17:30chouser,(pr-str (range 4))
17:30clojurebot"(0 1 2 3)"
17:30chouser,(apply str (range 4))
17:30clojurebot"0123"
17:36chouserslyrus: I don't know that I'd say it quite that strongly, but I have rarely used it in final solutions.
17:36slyrushey, I said _usually_ :)
17:36BrianForesterthanks for the help all, later.
17:56anonymouse89I am trying to defn with a name constructed from two keywords
17:57anonymouse89so :abc :def should be like (defn abc_def
17:57anonymouse89but, I'm not sure how this can be done
17:57arohneranonymouse89: with a macro
17:58anonymouse89arohner: ok, I may have been putting off heading into macro land for too long
18:02anonymouse89and is there a shortcut for going from keyword to string without the colon?
18:03@rhickeyname
18:03msfdoes anyone know of an example cojure application that uses a configuration file ?
18:03@rhickey,(name :fred)
18:03clojurebot"fred"
18:03anonymouse89rhickey: thanks much
18:07fsmunozmsf: not strictly a configuration file, but mire uses a separate file to store game data, and swallows it...
18:41kencauseychouser: The clear function defined in JoC 3.4.4 and used in 3.4.5 isn't much good with fixed dimensions.
18:42kencauseythe frame should be the argument rather than the graphic
18:49kencausey(defn clear [frame]
18:49kencausey (let [d (.size frame)]
18:49kencausey (.clearRect (.getGraphics frame) 0 0 (.height d) (.width d))))
18:51kencauseyI think it's also better to define draw-values to take the frame as an argument and get the graphics context from it
19:49Rayneshttp://www.reddit.com/r/Clojure/comments/d7uv2/state_of_clojure_after_oracles_moves_with_javajvm/
20:16dnolen_is it possible to find out the arity or arglist of an anonymous function?
20:17AWizzArdYou can use reflection.
20:18AWizzArdThere currently is no real Clojure-Introspection yet which allows you to do this.
20:19dnolen_AWizzard: do what methods let you examine an anonymous fn?
20:23AWizzArdwith reflection you can analyze everything
21:01dnolen_I don't suppose there's a destructuring syntax for saying that you just want the last element is there?
21:01RaynesNosir.
21:01RaynesIt would be cool to be able to destructure from the back.
21:11pbuckleyanyone know how long it typically takes for your first post to the clojure google group to get moderated?
21:12pbuckleynm, just saw that it went through but no replies yet
21:13pbuckley/erc-cmd-N
21:13pbuckleyerc-cmd-N
22:48johnmn3hello
22:49johnmn3so I wanted to play around with extend-type a little bit.
22:49johnmn3but before I go on.. can anyone hear me? is this working?
22:50johnmn3I've had this not work before, where I wasn't logged on correctly and I talked to my self for 5 minutes :/
22:51scottjjohnmn3: it's working
22:52arnorhsno it's not
22:52arnorhsI can't hear you
22:53johnmn3sweet! 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:54johnmn3arnorhs: what's that?
22:55johnmn3So I thought I'd do an (extend-type java.util.regex.Pattern clojure.lang IFn (...
22:55ihodesjohnmn3: you'd have to implement that as a reader macro: basically, tell Clojure's reader that (#"…" means (re-find #"…"
22:55johnmn3The question is, what to put in the (...
22:55hiredmanjohnmn3: you can't do that
22:55johnmn3ihodes, why can't i just make a thing implement IFn?
22:56hiredmanyou can do that
22:56johnmn3and implement the (applyTo
22:56hiredmanbut you can't make something that implements Pattern and IFn
22:56johnmn3why not?
22:56hiredmanPattern is a final class
22:57johnmn3mmm.
22:57hiredmanand you can't add interfaces to classes
22:57hiredmanand I am fairly certain extend-type works with Protocols not Interfaces
22:58johnmn3I think it does both, sometimes
22:58hiredmanI doubt that very much
22:58hiredmanbecause you just can't add an interface to a class
23:00johnmn3I thought I remember reading about some interoperability with interfaces.. maybe you can extend interfaces with extend-protocol?
23:00hiredmanyou may be confused because Protocols compile to Interfaces + plus other stuff
23:00hiredmanyou cannot extend an interface
23:02johnmn3so 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:02johnmn3other than a reader-macro?
23:02hiredmanno a reader macro won't do it either
23:02hiredmanyou can extend protocols to classes
23:02hiredmanbut, IFn is not a protocol
23:04johnmn3right.. and clojure won't accept anything in the function position that does not implement IFn, right?
23:04hiredmancorrect
23:05johnmn3hmm. Okay, that settles it then. Thanks.\
23:10ihodeshiredman: you couldn't accomplish this with a reader macro? why is that?
23:10scottjjohnmn3: so when clojure is written in clojure and ifn is a protocol then maybe you'd be able to do it
23:10hiredmana reader macro will not get you a regex you can call as a function
23:10hiredmanIFn will most likely never be a protocol
23:11hiredmanas fast as protocols can be there is some overhead compared to an interface
23:12ihodeshiredman: 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:12johnmn3hiredman: could you not make a reader macro that builds a Matcher?
23:13johnmn3or (re-find (re-matcher "string" ...
23:14Rayneshiredman: There is an example in The Joy of Clojure where they extend String with a protocol. Something like that.
23:14johnmn3mmm
23:14johnmn3re-pattern is what I meant: (re-pattern "\\d+")
23:15hiredmanRaynes: what about it?
23:15hiredmanyou can extend protocols to classes
23:15RaynesOh, never mind. I thought you were saying protocols couldn't be extended to classes.
23:15RaynesReading comprehension is nil tonight.
23:16hiredmanbecause protocols are interfaces + indirection
23:16RaynesAye.
23:16hiredmanwhich makes them more flexible
23:16hiredmanjohnmn3: you could, but it would not be callable as a function
23:17ihodeshiredman: but you could have something like (#"hi" "hi") => true, right?
23:18hiredmansorry I gotta go
23:18RaynesBai!
23:19ihodesjohnmn3: 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:19ihodesfunction things* it's be like a macro, but a special, reader macro
23:19ihodesif you look in LispReader.java, you should see what you can do
23:20ihodes(i think that's the file…)
23:20ihodesbut in short, you can't really do this strictly within Clojure, i guess :)
23:21johnmn3I 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:22johnmn3seems to me (#"thing" "some thing") is clear enough
23:22johnmn3or even ("some thing" #"thing"), either way
23:23johnmn3were it possible to rig it up, I would have added it to my tool-box.
23:23ihodesthat'd be nice, but AFAIK not possible right now. but i could certainly be wrong.
23:25pdk,(* (* 2000 4) 12)
23:25clojurebot96000