2010-08-31
| 00:00 | ataggart | Is there a way to call clojure.lang.Numbers/shiftLeftInt without the primitives getting autoboxed to intermediate objects? |
| 00:01 | ataggart | trying to do a lot of byte ops and I'm guessing this is where the slowdown is |
| 00:12 | scottj | maybe one of the special branches, like prim? |
| 00:13 | tomoj | how do you even tell whether stuff is getting boxed? |
| 00:14 | technomancy | prim is in 1.3 now iirc |
| 00:15 | notsonerdysunny | my messages are not appearing on the forum :( |
| 00:15 | ataggart | ah, I had forgotten about the prim stuff |
| 00:18 | Chousuke | notsonerdysunny: hm. |
| 00:18 | notsonerdysunny | no ... sorry .. I just found it :) |
| 00:18 | Chousuke | Ah, good. |
| 00:19 | Chousuke | I was about to tell you to poke chouser, as he's a group moderator :P |
| 00:19 | Chousuke | at 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: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 |
| 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:18 | bortreb | how do I do a primitive int type hint for clojure? #^int doesn't work.... |
| 01:32 | ataggart | you don't unless you're working in the master branch |
| 01:34 | bartj | , (clojure.set/intersection [[1 2 3] [2 3]]) |
| 01:34 | clojurebot | [[1 2 3] [2 3]] |
| 01:34 | bartj | I was expecting: [2 3] on the above statement |
| 01:35 | bartj | oh, they should be sets and not vectors...mea culpa |
| 01:35 | bartj | , (clojure.set/intersection #{1 2 3} #{2 3}) |
| 01:35 | clojurebot | #{2 3} |
| 03:36 | LauJensen | Good morning all |
| 03:40 | lenw | Morning LauJensen |
| 03:43 | adityo | good morning :) |
| 03: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) |
| 03:43 | LauJensen | ah, silly me, its inherited from java.lang.ClassLoader, nvm |
| 05:40 | serp_ | is there an idiomatic way of doing a priority queue? |
| 05: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 |
| 05:45 | LauJensen | -> (str (java.util.UUID/randomUUID)) |
| 05:45 | LauJensen | ,(str (java.util.UUID/randomUUID)) |
| 05:45 | clojurebot | "b5b0df74-f15a-4995-97b9-ab7315241e77" |
| 05:56 | notsonerdysunny | ,(java.util.UUID/randomUUID) |
| 05:56 | clojurebot | #<UUID d1ffd517-7132-4c70-acb6-8e719bc3685e> |
| 05:56 | notsonerdysunny | ,(java.util.UUID/randomUUID) |
| 05:56 | clojurebot | #<UUID a3bda2ea-7245-4f64-aab0-c90ebf6e9d47> |
| 05:57 | serp_ | what are the semantics of a queue in clojure? |
| 05:57 | serp_ | (with respect to concurrency) |
| 05:58 | tomoj | nothing special |
| 05:59 | tomoj | if you mean PersistentQueue, that is |
| 06:00 | serp_ | those are mutable though |
| 06:00 | serp_ | I'd like an immutable queue, but perhaps that makes no sense :) |
| 06:02 | LauJensen | serp_: Nearly all talk of queues end up with people writing their own wrapper for LinkedBlockingQueue |
| 06:03 | tomoj | PersistentQueues aren't mutable |
| 06:03 | tomoj | and if you want an immutable queue, why are you asking about concurrency semantics? |
| 06:03 | tomoj | 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! |
| 06:05 | serp_ | LauJensen: all right |
| 06:08 | serp_ | 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:09 | tomoj | ah, no |
| 06:09 | tomoj | ,(-> clojure.lang.PersistentQueue/EMPTY (conj 1) (conj 2) peek) |
| 06:09 | clojurebot | 1 |
| 06:10 | tomoj | since you said "priority" earlier I think this won't help, though |
| 06:13 | serp_ | hm |
| 06:16 | serp_ | 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:17 | fliebel | morning |
| 06:17 | serp_ | though obviously I'm a clojure noob, so what do I know |
| 06:31 | LauJensen | clojurebot: where are you ? |
| 06:31 | clojurebot | http://github.com/hiredman/clojurebot/tree/master |
| 06:32 | fliebel | clojurebot: do you have a list of commands? :P |
| 06:32 | clojurebot | paredit commands is http://mumble.net/~campbell/emacs/paredit.html |
| 06:33 | LauJensen | clojurebot: whats the maximum size of a POST request? |
| 06:33 | clojurebot | excusez-moi |
| 06:35 | quizme | is there a function that gives the name of the variable as a string or symbol? |
| 06:36 | LauJensen | ,(symbol "this") |
| 06:36 | clojurebot | this |
| 06:36 | LauJensen | ,(str 'this) |
| 06:36 | clojurebot | "this" |
| 06:36 | quizme | ty :) |
| 06:36 | fliebel | what was the one with teh colon in front? |
| 06:36 | quizme | lemme try that |
| 06:37 | LauJensen | ,(name :this) |
| 06:37 | clojurebot | "this" |
| 06:37 | fliebel | and the inverse of that? |
| 06:37 | quizme | how about |
| 06:37 | quizme | (def x 3) |
| 06:37 | quizme | (whats-your-name x) |
| 06:37 | quizme | => "x" |
| 06:38 | quizme | any way to do that? |
| 06:38 | tomoj | why would you want to do that? |
| 06:38 | fullets | (defmacro whats-your-name [s] (name s)) |
| 06:39 | quizme | so that i can process string messages and compare them to what i called them as variables in my code |
| 06:40 | tomoj | O_o |
| 06:40 | quizme | sorry it's kind of mental hehe |
| 06:40 | fliebel | Sounds like the local variant of xxs attacks, or whatever they're called :P |
| 06:40 | quizme | it's just a toy example |
| 06:41 | LauJensen | (defmacro yourname? [x] (println (keys &env))) |
| 06:41 | LauJensen | user> (let [x 5] (yourname? x)) |
| 06:41 | LauJensen | (x) |
| 06:41 | LauJensen | |
| 06:41 | quizme | fullets that worked thanks |
| 06:42 | fliebel | LauJensen: How does that work? I mean the (keys &env part) |
| 06:42 | tomoj | why not just write "x" instead of (whats-your-name x)? |
| 06:43 | quizme | tomoj: lol i dunno probably haven't thought it through yet |
| 06: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 |
| 06:43 | LauJensen | quizme: but tomoj is right, its pointless. I just wanted to show the &env off :) |
| 06:44 | tomoj | (let [x 1 y 2] (yourname? george)) |
| 06:45 | LauJensen | yea it'll print (x y) |
| 06:57 | quizme | http://pastie.org/1128695 |
| 06:57 | quizme | it just kinda bugs me aesthetically. |
| 07:01 | tomoj | quizme: https://gist.github.com/d236d21d9c84d7a2a37c |
| 07:01 | fullets | That's pretty cool |
| 07:02 | tomoj | or even https://gist.github.com/9540cb130c19e85893e0 |
| 08:46 | jgracin | Hi! Is there a clojure-mode version which makes swank-clojure.el superfluous? I seem to recall techomancy saying that... |
| 08:47 | jgracin | I use the one whose commit id is 5006b3 and it doesn't work without swank-clojure.el. |
| 09:00 | raek | hrm, the clojure-mode on technomancy/clojure-mode doesn't work without swank-clojure.el? |
| 09:01 | raek | iirc, in my setup, emacs does not know about swank-clojure.el at all |
| 09:03 | bobo_ | i have some memory of swank-clojure beeing deprecated? |
| 09:03 | bobo_ | .el |
| 09:04 | Lajla | ->(let [I (fn [x y z] 3) Worship nil Your nil Shadow nil] (I worship your shadow)) |
| 09:04 | Lajla | no sexpbot. =( |
| 09:06 | raek | that commit is the latest version, so that's goof |
| 09:06 | raek | *good |
| 09: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. |
| 09:07 | raek | jgracin: have you evaled the ns declaration at least once? |
| 09:07 | raek | ...in that buffer |
| 09:07 | jgracin | raek: yes, the buffer is successfully compiled with C-c C-k. |
| 09:07 | raek | also, I found that the auto-complete thingy that was posted on the group recently brakes this |
| 09:08 | jgracin | I don't have auto-complete turned on. |
| 09:08 | raek | jgracin: I think you still need to C-M-x the ns form once |
| 09:08 | raek | I always have to do that once |
| 09:09 | jgracin | It seems to me that C-M-x always finds out the namespace by itself. |
| 09:10 | raek | I think slime (or would it be swank?) remembers the namespace from the point it evals the ns form |
| 09:10 | raek | this is my experience of it, of course |
| 09:13 | raek | did you get it working? (and if so, did it work without evaling the ns?) |
| 09:16 | arnorhs | yo |
| 09:16 | arnorhs | did you write a tutorial raek? |
| 09:16 | raek | I'm writing it |
| 09:16 | raek | it's not done yet |
| 09:17 | arnorhs | ok :) |
| 09:17 | bobo_ | arnorhs: the one you retweeted i wrote |
| 09:17 | arnorhs | oh, really? |
| 09:17 | raek | link? |
| 09:17 | arnorhs | this one: http://cleancode.se/2010/08/30/getting-started-with-compojure.html ? |
| 09:17 | clojurebot | your link is dead |
| 09:17 | bobo_ | yes |
| 09:17 | arnorhs | I'm reading it as we speak |
| 09:17 | arnorhs | :) |
| 09:17 | bobo_ | please bash me if you find something bad :-) |
| 09:17 | arnorhs | heh, don't worry |
| 09:18 | raek | http://raek.se/clojure-emacs.html <-- this is the outline I'm filling in |
| 09:18 | bobo_ | raek: oh looks pretty! |
| 09:18 | raek | I have only worked on it last saturday |
| 09:19 | raek | but I will try to write something on it every day |
| 09:19 | raek | sstathis made the awesome graph |
| 09:25 | arnorhs | raek: it's starting to look good |
| 09:28 | arnorhs | Is it possible to interface with swank from the command line? |
| 09:30 | arnorhs | for instance something like: lein swank < file.clj |
| 09:30 | arnorhs | except, that would never work, of course :) |
| 09:30 | bobo_ | lein repl < file.clj? |
| 09:30 | arnorhs | but I'd like to really? |
| 09:30 | arnorhs | really? |
| 09:30 | bobo_ | dont know, lets try! |
| 09:30 | arnorhs | that works? |
| 09:32 | bobo_ | it seems to! |
| 09:32 | bobo_ | http://gist.github.com/559017 |
| 09:32 | bobo_ | test.clj contained (+1 1) |
| 09:44 | arnorhs | bobo_: but if you have a running process, how would you add the file to that particular process? |
| 09:44 | arnorhs | do they maybe get tied together by the lein directory somehow? |
| 09:48 | bobo_ | hm, yeh, that it cant do, i guess. but i see what you want to do. |
| 09:49 | arnorhs | I'm basically trying to do the same thing as you do using emacs via slime/swank, but from the command prompt |
| 09:49 | arnorhs | Lajla: I don't even want to know |
| 09:50 | Lajla | arnorhs, it was already registered. =( |
| 09:50 | Lajla | I wished to seize it as mine own, yet alas another hath come before. |
| 09:52 | arnorhs | You know what I would want |
| 09:53 | arnorhs | ? |
| 09:54 | arnorhs | 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 |
| 09:54 | arnorhs | 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 | mrBliss | I even tried the examples on github and the tutorial, they're also broken |
| 10:02 | mrBliss | 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 | mrBliss | it works under beta1! |
| 10:06 | mrBliss | 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 | patrkris | 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 | patrkris | 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 | mrBliss | tomoj: I'll answer you when it breaks again |
| 10:12 | tomoj | :) |
| 10:12 | tomoj | if some map type started giving lazy seqs instead of map entries... that would be Bad |
| 10:12 | tomoj | that couldn't have happened, could it have? |
| 10:12 | Bahman | Hi all! |
| 10:13 | mrBliss | it works under rc3 |
| 10:14 | mrBliss | 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 | mrBliss | I must have done something crazy |
| 10:16 | mrBliss | 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 | nlogax | 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 | nlogax | 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 | raek | you want a sandbox or something? |
| 10:58 | chouser | there isn't really a clojure runtime |
| 10:58 | chouser | 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 | raek | 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 | _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: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 | _na_ka_na_ | 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 | _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: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 | bartj | 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 | _fogus_ | English syntax on the other hand... |
| 11:36 | bartj | er, I mean as discussed |
| 11:37 | bartj | 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 | bartj | dnolen, thanks |
| 11:39 | bartj | I thought the community had discussed on some guideline |
| 11:39 | bartj | 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 | _fogus_ | (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 | _na_ka_na_ | most probably there must be something wrong on my machine |
| 12:01 | bartj | I just read about ClojureCLR |
| 12:01 | bartj | 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 | cemerick | 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 | nlogax | (yes, total clojure noob) |
| 15:33 | bobo_ | i think you want (require 'mything) |
| 15:33 | bobo_ | (: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 | raek | 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 | raek | the file path reflects the namespace name |
| 15:41 | raek | 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 | raek | for example |
| 15:43 | nlogax | ohhh |
| 15:43 | nlogax | 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 | raek | 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 | solussd | 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 | raek | but as for irc, I think this is the closest match |
| 15:50 | raek | 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 | raek | 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 | BrianForester | 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 | kumarshantanu | ,(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 | nlogax | 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 | slyrus | ,(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 | kumarshantanu | slyrus: your version looks neat -- will it work with '((1 2 3)(4 5 6)) ? |
| 16:58 | kumarshantanu | ,(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 | raek | 't care about the type of the collection |
| 16:59 | raek | 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 | BrianForester | ,(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: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 | anonymouse89 | so :abc :def should be like (defn abc_def |
| 17:57 | anonymouse89 | 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 | anonymouse89 | 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 | kencausey | the frame should be the argument rather than the graphic |
| 18:49 | kencausey | (defn clear [frame] |
| 18:49 | kencausey | (let [d (.size frame)] |
| 18:49 | kencausey | (.clearRect (.getGraphics frame) 0 0 (.height d) (.width d)))) |
| 18:51 | kencausey | 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 | AWizzArd | 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 | Raynes | 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 | pbuckley | nm, just saw that it went through but no replies yet |
| 21:13 | pbuckley | /erc-cmd-N |
| 21:13 | pbuckley | erc-cmd-N |
| 22:48 | johnmn3 | hello |
| 22:49 | johnmn3 | so I wanted to play around with extend-type a little bit. |
| 22:49 | johnmn3 | but before I go on.. can anyone hear me? is this working? |
| 22:50 | johnmn3 | 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 | arnorhs | 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 | johnmn3 | arnorhs: what's that? |
| 22:55 | johnmn3 | 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 | hiredman | 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 | hiredman | 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 | hiredman | 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 | johnmn3 | other than a reader-macro? |
| 23:02 | hiredman | no a reader macro won't do it either |
| 23:02 | hiredman | you can extend protocols to classes |
| 23:02 | hiredman | 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 | hiredman | IFn will most likely never be a protocol |
| 23:11 | hiredman | 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 | johnmn3 | 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 | johnmn3 | re-pattern is what I meant: (re-pattern "\\d+") |
| 23:15 | hiredman | Raynes: what about it? |
| 23:15 | hiredman | 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 | Raynes | 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 | hiredman | 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 | ihodes | function things* it's be like a macro, but a special, reader macro |
| 23:19 | ihodes | if you look in LispReader.java, you should see what you can do |
| 23:20 | ihodes | (i think that's the file…) |
| 23:20 | ihodes | 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 | johnmn3 | seems to me (#"thing" "some thing") is clear enough |
| 23:22 | johnmn3 | or even ("some thing" #"thing"), either way |
| 23:23 | johnmn3 | 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 |