2010-04-07
| 00:01 | dnolen | what's the best strategy for making sure an agent isn't queueing up a whole bunch of actions? |
| 00:07 | _ato | not sure if there's a proper way to do it |
| 00:07 | _ato | maybe... (when (> (.getQueueCount my-agent) 10) (await my-agent)) |
| 00:13 | konr | Why am I not being able to extend a particular class with proxy? I'm getting an "IllegalAcessError" with this class, but not with others |
| 00:30 | nteon | good evening |
| 00:35 | technomancy | TheBusby: hang on, you're saying (str "Main-Class: " (apply str (replace {\- \_} (str main)))) works but (str "Main-Class: " (.replaceAll (str main) "-" "_")) does not? |
| 00:36 | technomancy | TheBusby: oh, never mind; looks like this was fixed in git already; heh |
| 00:36 | dcnstrct | hi. How do I serve a javascript file from my compojure app ? I want for this compojure app to run as a single jar file using jetty so I can't program in a path to read the .js file from. |
| 00:37 | dcnstrct | I can't hard code a server path I mean.. |
| 00:37 | dcnstrct | can I serve the .js right out of the jar file somehow ? |
| 00:38 | metronome | dcnstrct: you can use a .war container for that |
| 00:38 | dcnstrct | so far I have done (def javascript "all my js lives in here") and then served that... but I'm tired of escaping quotes |
| 00:39 | dcnstrct | if I use a .war then I need a java application server to deploy to |
| 00:39 | dcnstrct | I want to make a single jar file that you run and it starts a server on 8080 completely self contained |
| 00:39 | dcnstrct | I'm going to wrap it in a .exe and ship it to a windows user to run on his desktop |
| 00:40 | dcnstrct | so I can't tell him "go setup a java application server" |
| 00:40 | _ato | dcnstrct: if you include the js file in the jar then you can get at it via getResourceInputStream or something... let me find the exact method.. |
| 00:40 | metronome | then why not just bundle the .js files with the exe? |
| 00:40 | dcnstrct | sweet |
| 00:41 | dcnstrct | metronome, that might work too |
| 00:41 | dcnstrct | another problem though is that I want it to still work when I'm running it in a slime |
| 00:41 | dcnstrct | during testing |
| 00:41 | dcnstrct | but I guess I can handle that as a seperate issue |
| 00:41 | dcnstrct | you can't always have your cake and eat it too |
| 00:42 | metronome | I guess you could do what _ato says then |
| 00:42 | technomancy | though M-x swank-clojure-project hasn't had a stable release that honors them yet |
| 00:43 | _ato | I think it should be just something like: (.getResourceAsStream (clojure.lang.RT/baseLoader) "foo/bar/myfile.js") |
| 00:43 | dcnstrct | great, I'll give it a shot. thnx |
| 00:44 | _ato | I wonder... |
| 00:44 | _ato | ,(.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/xml.clj") |
| 00:44 | clojurebot | nil |
| 00:44 | _ato | hmm |
| 00:44 | _ato | ah |
| 00:44 | _ato | works in my repl, must be a sandbox thing |
| 00:47 | dcnstrct | it works! gracias |
| 00:48 | dcnstrct | now can anyone think of an easy way to tell it to render from an absolute path when running inside slime and from the jar any other time ? |
| 00:48 | dcnstrct | I bet swank-clojure-project sets some kind of variable I can use |
| 00:48 | TheBusby | technomancy: the fix in git works fine. I was simply provding the fix I used against 1.1.0. DLing the latest lein now ;) |
| 00:48 | technomancy | great |
| 00:49 | technomancy | dcnstrct: if you use lein swank it will be able to load from the resources directory |
| 00:49 | dcnstrct | HRMMm ok thnx I'll get it if I'm not already using it. |
| 00:51 | TheBusby | technomancy: so I guess I'll need to wait for 1.2.0 before a stable version is out with the bug fix? (raw/stable pulls for 1.1.0 and doesn't appear to include that fix...) |
| 00:51 | dcnstrct | you're right it just works |
| 00:51 | technomancy | TheBusby: yeah, I haven't backported any fixes so far |
| 00:51 | technomancy | TheBusby: using the version from git shouldn't be too bad though; let me know if you run into problems |
| 00:51 | TheBusby | that's fine. I'll just stick with my hand fixed one until 1.2.0 and then switch back |
| 00:52 | TheBusby | need to keep a bunch of machines in sync, so I'd prefer to stick to a label/tagged version. |
| 00:53 | technomancy | ok... not sure how far 1.2.0 is. |
| 00:53 | technomancy | it's not just around the corner |
| 00:53 | TheBusby | well other than this tiny issue, lein has been working great ;) No hurry |
| 00:54 | peregrine81 | I cannot get vimclojure (probably vim) to work correctly.. |
| 00:54 | peregrine81 | trying to open a new reply using \sr and it just puts me in insert mode |
| 00:55 | bmason | technomancy: thanks for making Lein! it has really eased my linking pain |
| 00:56 | peregrine81 | how do I use vimclojure? The doc says type <LocalLeader>sr to open a new repl |
| 00:57 | peregrine81 | I've got ng running |
| 00:57 | technomancy | bmason: cool! |
| 00:58 | bmason | we were having a chat the other day about features to add to lein... I don't know if anyone went and did anything about it though |
| 00:59 | mikem | peregrine81: have you opened a .clj file first? |
| 01:00 | peregrine81 | mikem: yep, I've got the plugin installed, I can do completions, highlighting... |
| 01:00 | technomancy | bmason: remind me which features? |
| 01:00 | mikem | peregrine81: so what happens when you hit <LocalLeader>sr? |
| 01:01 | bmason | ah... three main ones that I can recall... being able to search repos, resolving dependencies, and having a default version (latest stable) |
| 01:01 | peregrine81 | I am assuming my LocalLeader is \ cause I haven't changed it. Nothing happens, when I press s it puts me in insert |
| 01:02 | mikem | peregrine81: do you have the appropriate options set in ~/.vimrc? namely, clj_want_gorilla and vimclojure#NailgunClient? |
| 01:02 | mikem | btw, which version of VimClojure are you using? |
| 01:03 | technomancy | bmason: searching repos would need some server-side support |
| 01:03 | technomancy | what do you mean by resolving dependencies? |
| 01:03 | peregrine81 | mikem: 2.1.2 |
| 01:03 | peregrine81 | mikem: lemme check .vimrc |
| 01:03 | bmason | something that would probably also require some support outside lein :) |
| 01:03 | bmason | I mean resolving hierarchical deps |
| 01:04 | mikem | peregrine81: you may be interested in an alpha version of 2.2.0: http://groups.google.com/group/vimclojure/browse_thread/thread/d15b0174d2a1e51 -- but 2.1.2 should work also :) |
| 01:04 | bmason | e.g. I add 'cupboard' to my deps, it needs 'berkeleydb', which needs a couple other jars |
| 01:04 | peregrine81 | the vimclojure#NailgunClient is not mentioned in the docs.. but I did not have gorilla I will add and retry |
| 01:04 | technomancy | bmason: if that's not working it's a pretty fundamental bug |
| 01:05 | bmason | really? |
| 01:05 | bmason | huh... didn't know it was supposed to |
| 01:05 | technomancy | yeah, that stuff is handled behind the scenes by maven |
| 01:06 | mikem | peregrine81: there is a README.txt that ships with the 2.1.2 files, as well as a clojure.txt in the doc/ folder. between the two files, all this stuff should be documented |
| 01:06 | _ato | Clojars is now providing the same search stuff maven central does (which eclipse etc use): http://clojars.org/repo/.index/ |
| 01:06 | _ato | the zip is just a zipped up lucene index |
| 01:07 | technomancy | oh, cool |
| 01:07 | technomancy | bmason: what do you mean about having a default version? |
| 01:08 | bmason | e.g. :dependencies [clojure], and it automatically uses the current stable release |
| 01:09 | technomancy | oh, yeah |
| 01:09 | bmason | none of this is really major |
| 01:09 | bmason | just stuff that would save steps for the developer |
| 01:09 | technomancy | the problem with that is it will cause code to break down the line even when your project hasn't changed |
| 01:09 | bmason | yeah |
| 01:09 | bmason | :) |
| 01:09 | technomancy | one day it works fine; the next it mysteriously doesn't |
| 01:10 | technomancy | you still get this with snapshot deps, but you try to minimize those, and then you know what you're getting into... kind of a necessary evil |
| 01:10 | technomancy | anyway using "lein new" should make it easier since that will leave you with the latest clojure at the time of the lein release |
| 01:10 | technomancy | and having a search would make it even easier |
| 01:10 | bmason | true true |
| 01:11 | technomancy | I'd love to see something like "lein add cupboard" that could search clojars, maven central, etc, and add a dependency to your project.clj for you |
| 01:11 | bmason | yeah, really my biggest hurdle has just been trying to figure out *where* the jars I'm looking for are |
| 01:11 | technomancy | if you're looking for a fun project that would be my suggestion. =) |
| 01:11 | technomancy | bmason: you know about jarvana.com? |
| 01:11 | bmason | jarvana doesn't cover all the repos |
| 01:12 | technomancy | true |
| 01:12 | bmason | whereas lein could hopefully tell you whether a package is in any of the repos that it's using |
| 01:12 | _ato | the starting point for anyone wanting to implement search would be to take a look at this: http://www.sonatype.com/people/2009/06/nexus-indexer-api-part-2/ |
| 01:13 | _ato | that's what most maven repo search things are using underneath as far as I can tell |
| 01:13 | bmason | gotcha |
| 01:15 | technomancy | bmason: that would make a great plugin, but unfortunately there's no way right now to activate plugins on a user-wide basis |
| 01:15 | technomancy | just on a per-project basis |
| 01:15 | technomancy | it's on the list though; shouldn't be hard |
| 01:17 | bmason | is "the list" accessible to mere mortals? |
| 01:18 | _ato | bmason: http://github.com/technomancy/leiningen/raw/master/todo.org |
| 01:18 | technomancy | only to org-mode users, sorry =) |
| 01:18 | bmason | ok, good link |
| 01:19 | technomancy | I have it under "for later", but if I got a patch for it I would be happy to move it to 1.2.0. =) |
| 01:19 | bmason | no worries... I really just wanted to make sure the ideas we were discussing weren't getting lost |
| 01:22 | peregrine81 | mikem: I probably couldn't be more frustrated by this... :/ |
| 01:22 | bmason | well, good night guys |
| 01:22 | bmason | thanks for the information :) |
| 01:26 | mikem | peregrine81: still not working? |
| 01:26 | peregrine81 | mikem: i cannot see why its not.. |
| 01:27 | mikem | you said the nailgun server is up and running, right? did you start it with a classpath which includes the files you're opening in vim? |
| 01:28 | peregrine81 | no.... |
| 01:28 | peregrine81 | i just used the command |
| 01:28 | peregrine81 | mikem: starting to see like that nailgun is not worth all the work |
| 01:28 | peregrine81 | /see/seem |
| 01:29 | mikem | peregrine81: well, it's working fine for me :) |
| 01:29 | peregrine81 | mikem: why would it need to be in the classpath? ANd I have to run the java command everytime I need to edit some files? |
| 01:30 | mikem | so, to recap: I start nailgun with, I have the following two lines in my .vimrc: "let clj_want_gorilla = 1" and 'let vimclojure#NailgunClient = "/home/mike/src/clojure/vimclojure/ng"' |
| 01:31 | peregrine81 | mikem: I have the lines in my .vimrc and I was under the impression I could start ng and forget it in a screen session |
| 01:31 | mikem | peregrine81: I think the files you're editing (and their dependencies) need to be in the classpath, because you end up sending some code to the nailgun server which then compiles and runs said code |
| 01:32 | mikem | my workflow is starting one ng server per coding session for the project I work on. I don't work for more than one project at one time |
| 01:33 | mikem | if you work on more than one project at any one time, I imagine it should be OK to launch the nailgun server with a classpath including all your dependencies |
| 02:11 | wooby | is there an easy way to write back out as xml the structure that clojure.xml/parse returns? |
| 02:11 | hiredman | there is a xml/emit |
| 02:12 | hiredman | but, uh, it is not nice to use |
| 02:14 | wooby | hm, looks like it barfs to *out* |
| 02:14 | hiredman | right |
| 02:15 | wooby | best way to mitigate, run in binding? |
| 02:16 | hiredman | ,(doc with-out-string) |
| 02:16 | clojurebot | Titim gan éirí ort. |
| 02:17 | hiredman | ,(doc with-out-str) |
| 02:17 | clojurebot | "([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls." |
| 02:17 | wooby | oh awesome, thanks man |
| 02:17 | hiredman | :/ |
| 02:17 | wooby | the good almost cancels out the bad |
| 02:17 | hiredman | I hope it works for you |
| 02:18 | wooby | thanks, about to give it a shot here |
| 02:23 | wooby | yup, we're cooking |
| 02:23 | wooby | thanks again |
| 03:04 | zmila | if (fun x) returns some transformation or false, is this idiomatic to recieve only not-falsy: |
| 03:04 | zmila | (filter #(identity %) (map fun some-seq)) |
| 03:04 | zmila | or there is smth more elegant? |
| 03:06 | zmila | ,(filter #(identity %) (map #(if (even? %) (* % %) false) (range 1 10))) |
| 03:06 | clojurebot | (4 16 36 64) |
| 03:08 | hiredman | uh |
| 03:08 | hiredman | just identity |
| 03:08 | Raynes | (filter identify ..) |
| 03:09 | hiredman | or, (remove false? ...) |
| 03:10 | zmila | yes! remove false? is the answer, thx hiredman |
| 03:10 | Raynes | ,(false? nil) |
| 03:10 | clojurebot | false |
| 03:10 | noidi | zmila, it's easier and faster to run the filter before the map |
| 03:11 | noidi | ,(map #(* % %) (filter even? (range 1 10))) |
| 03:11 | clojurebot | (4 16 36 64) |
| 03:12 | zmila | noidi, my example was wrong. I want to calculate fun x, then check if it is not false and collect only such results |
| 03:12 | noidi | ok |
| 03:14 | zmila | (remove false? (map #(let [x (* % %)] (if (even? x) x false)) (range 1 10))) |
| 03:24 | wooby | i found out about comp the other day, can be useful for stuff like that |
| 03:24 | wooby | (remove false? (map (comp even? #(* % %)) (range 10))) |
| 03:25 | wooby | hm, can i use proxy to implement a constructor? |
| 03:27 | wooby | nevermind |
| 03:31 | zmila | comp is good, i've to learn more. but in this example it returns seq of true's :) but not seq of squares |
| 03:33 | wooby | ah ;) |
| 03:33 | wooby | have you gotten into 'for' at all? |
| 03:33 | wooby | useful for same kinds of things also |
| 03:37 | zmila | yes, wooby, i know about (for ). i prefer to use filter/map in first turn, then for, lastly loop/recur :) |
| 03:38 | konr | Is there a tutorial or some other resource to shed some light on the error stack? |
| 03:49 | zmila | it's hard to read my own clojure code, written a month ago :( |
| 03:52 | esj | zmila - this is the main reason I write tests, so that I can understand later how I intended a function to used :) |
| 03:53 | zmila | it's myth about one-liners :) |
| 03:54 | zmila | one line: for the body, one-two lines: doc about params and return, and one-two more: test or example of use |
| 03:54 | esj | you're ahead though |
| 03:54 | _ato | yeah, having tests helps a lot. Someone was asking me the other day how some Java code I wrote 2 years ago was supposed to work, it would have taken much longer to figure out without the tests, they made it obvious |
| 03:54 | Raynes | Java code!?! Blasphemy. |
| 03:55 | _ato | Clojure barely existed at the time |
| 03:57 | tomoj | well, you should've simply written clojure yourself |
| 03:57 | _ato | having lots of really small functions rather than a few large functions seems to help a lot as well |
| 03:57 | zmila | in eclipse i can search for a method's references and see where and how it is used :) and method's signature helps to know what data gets in and out. |
| 03:57 | zmila | small clojure function is often equivalent to medium java function :) |
| 03:58 | esj | Yeah, I'm still getting my head around arranging them all so I don't up with some kinda function confetti |
| 03:59 | zmila | even in java i prefer not to write function with more then one cycle. but in clojure one-liner may have two or three map/filter/reduce :) |
| 04:00 | _ato | ->> is very nice for that |
| 04:01 | _ato | I also like to name the map/filter functions if they're any more complex than #(< % 5) |
| 04:02 | tomoj | I've noticed that sometimes I want a function that is just like take-while, except it takes one more element (i.e. the first one that doesn't satisfy the predicate) |
| 04:02 | tomoj | or, it takes a predicate which identifies sentinels, then takes everything up to and including the first sentinel it sees |
| 04:03 | tomoj | what I'm look at now is (concat (take-while #(not (= % sentinel)) s) [sentinel]) |
| 04:03 | tomoj | which is evil |
| 04:04 | esj | tomoj: I've been doing just that... |
| 04:05 | zmila | simplicity and conciseness are contagious :) |
| 04:06 | _ato | ,(concat (take-while (complement #{0}) [1 2 3 0 1 2 3]) [0]) |
| 04:06 | clojurebot | (1 2 3 0) |
| 04:06 | _ato | hmm |
| 04:15 | doseq | _ato: I posted off my contrib agreement yesterday! |
| 04:15 | doseq | How exciting. |
| 04:18 | _ato | doseq: cool. :) now the waiting part. I think Rich checks his mailbox weekly or so. You'll know when he's received it as your name will get added to the contributors page on clojure.org |
| 04:19 | doseq | ha, there you are. |
| 04:21 | Raynes | I don't have a printer. :( |
| 04:21 | Raynes | Somebody mail me the the CA. ;) |
| 05:23 | Raynes | defn: ping |
| 05:54 | AWizzArd | ~max people |
| 05:54 | clojurebot | max people is 269 |
| 06:03 | tomoj | it would be cool if we could automatically run the tests contained in old versions against the current version |
| 06:05 | tomoj | e.g. I'm about to tag 1.3.0. the tests have changed a bit since 1.2.3, but the tests that were in 1.X.* for X<3 should still pass against the 1.3.0 src |
| 06:07 | bsteuber | tomoj: if you want your old tests to still work, why not leave them in? |
| 06:07 | tomoj | well, I probably would do so |
| 06:07 | tomoj | but those tests might have slightly changed |
| 06:08 | tomoj | for introducing new backwards-compatible functionality |
| 06:08 | tomoj | if you always change the tests in such a way that the old behavior is still tested, there's no need, you're right |
| 06:09 | tomoj | but it seems like it might be a valuable sanity check, just to make sure you haven't broken something? not sure |
| 06:09 | bsteuber | if you want to be backwards-compatible, it es part of your spec - so you should test it, I'd say |
| 06:10 | bsteuber | you can move it to a module like backward-tests |
| 06:10 | tomoj | that makes sense |
| 06:11 | tomoj | having tests run that aren't actually in the source code but only in history does seem a bit crazy |
| 06:11 | bsteuber | :) |
| 06:38 | zmila | how to flatten result of (map fun seq) if fun may return nil, 1 item or list of items? |
| 06:40 | Chousuke | make it always return a list of items and use mapcat |
| 06:40 | Chousuke | (or nil, of course) |
| 06:45 | tomoj | there's a java class Coordinate with a constructor that takes two double arguments |
| 06:46 | tomoj | (Coordinate. 1 1) works fine |
| 06:46 | tomoj | how? |
| 06:46 | clojurebot | with style and grace |
| 06:46 | tomoj | yes indeed |
| 06:46 | tomoj | clojure's java interop specially checks if a cast can be performed to make the signature match? |
| 06:47 | tomoj | or is this a java thing I don't remember? |
| 06:53 | zmila | i'm afraid of mapcat - it seams to be slow |
| 06:56 | tomoj | well, it's not lazy, is it |
| 06:56 | tomoj | are you mapping over a lazy seq? |
| 07:00 | zmila | i want to calculate count of unique results, so laziness will not help here, does it? |
| 07:01 | tomoj | nope |
| 07:01 | tomoj | did you make the function always return a seq or nil? or still trying to find a way where it can return non-seqs? |
| 07:03 | tomoj | I wonder how (apply concat) works |
| 07:04 | tomoj | does it realize every mapped value and only then concat them? |
| 07:05 | _ato | ,(clojure.contrib.seq-utils/frequencies [:a :a :a :b :b :a :c]) |
| 07:05 | clojurebot | {:c 1, :b 2, :a 4} |
| 07:05 | _ato | zmila: do you mean like that? |
| 07:06 | _ato | oh wait |
| 07:06 | _ato | would you answer be 3? |
| 07:06 | tomoj | using reduce instead of apply makes it 3.5 times slower for me |
| 07:06 | tomoj | (mapcat, that is) |
| 07:08 | zmila | i'll try apply concat |
| 07:08 | tomoj | mapcat is apply concat |
| 07:09 | tomoj | (mapcat f xs) == (apply concat (apply map f [xs])) |
| 07:09 | tomoj | so you can save having to apply the map: (apply concat (map f xs)), but it doesn't seem any faster to me |
| 07:16 | zmila | i must be ashemed :) just put (println xx) in several end-places, run all in repl, then captured result into text editor, find-removed braces, and put (into #{}), then call count |
| 07:18 | tomoj | oh, you wanted to collect it all into a set? |
| 07:18 | zmila | i want to calc (count distinct ...) |
| 07:18 | tomoj | yeah I think I understand now |
| 07:19 | zmila | i have to read some theoretical papers on func-programming with trees. |
| 07:20 | zmila | lists are ok. but trees - where I have two recursions ... weak point for me |
| 07:21 | tomoj | ,(require 'clojure.set) |
| 07:21 | clojurebot | nil |
| 07:21 | tomoj | ,(clojure.set/union [1 2 3] [3 4 5]) |
| 07:21 | clojurebot | [1 2 3 3 4 5] |
| 07:21 | tomoj | weird |
| 07:22 | tomoj | I wonder what the best way to add the elements of a coll into a set are |
| 07:22 | tomoj | s/are/is/ |
| 07:23 | tomoj | ,(apply conj #{} [1 2 3]) |
| 07:23 | clojurebot | #{1 2 3} |
| 07:23 | tomoj | ? |
| 07:24 | Chousuke | I'd prefer (into #{} [1 2 3]) |
| 07:25 | Chousuke | it's shorter, and it uses transients :) |
| 07:25 | tomoj | ah, yes |
| 07:26 | tomoj | (defn mapunion [f & colls] (reduce into (cons #{} (apply map f colls)))) |
| 07:26 | tomoj | doesn't seem to be much faster than mapcat |
| 07:26 | tomoj | even though mapcat returns duplicates and all in one big seq |
| 07:27 | tomoj | it's doing more work eliminating duplicates, I guess |
| 07:27 | Chousuke | I don't think you should use reduce with into |
| 07:27 | Chousuke | use apply instead |
| 07:28 | Chousuke | that will allow it to use a single transient for the whole operation |
| 07:28 | zmila | run time 58 sec, and answer is correct - so now i have 99 problems solved! :) one more until next level :) |
| 07:28 | tomoj | (into #{} (apply map f colls)) ? |
| 07:29 | tomoj | er, no |
| 07:29 | Chousuke | ,(apply into #{} (map (comp map inc) [[1 2 3] [3 4 5]])) |
| 07:29 | clojurebot | java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number |
| 07:29 | Chousuke | HMM |
| 07:29 | Chousuke | oops |
| 07:29 | Chousuke | ,(apply into #{} (map (partial map inc) [[1 2 3] [3 4 5]])) |
| 07:29 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$into |
| 07:30 | tomoj | yeah, couldn't figure out what you meant |
| 07:30 | Chousuke | oh, it doesn't support more than one collection? :/ |
| 07:30 | Chousuke | that's a fault if you ask me |
| 07:31 | tomoj | we can always (into #{} (mapcat ...)) |
| 07:31 | tomoj | but that certainly won't be any faster than mapcat :) |
| 07:31 | Chousuke | mapcat shouldn't be slow |
| 07:39 | tomoj | https://gist.github.com/bf8f747e4ffa29591665 |
| 07:39 | tomoj | using a single transient set and conj! is about the same as mapcat |
| 07:40 | tomoj | even if you call set on what you get back from mapcat |
| 07:40 | tomoj | unless I screwed up |
| 08:40 | dgreensp | ,(prn 3) |
| 08:41 | clojurebot | 3 |
| 08:41 | dgreensp | ,(first (for [i (range 10)] (prn i))) |
| 08:41 | clojurebot | 0 1 2 3 4 5 6 7 8 9 |
| 08:41 | dgreensp | why is that not lazy? actually, it is, sometimes (on one machine) but not others, and not here |
| 08:42 | _ato | dgreensp: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/ |
| 08:42 | zmila | ,(first (for [i (range 40)] (prn i))) |
| 08:42 | clojurebot | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
| 08:43 | zmila | see chunk-size :) |
| 08:45 | dgreensp | ah, thanks; a little creepy but I can kind of see the trade-off |
| 08:45 | dgreensp | ,(first (for [i (take 10 (iterate inc 0))] (prn i))) |
| 08:45 | clojurebot | 0 |
| 08:45 | dgreensp | is that guaranteed to work? or will "iterate" become chunked or something? |
| 08:46 | dgreensp | heh |
| 08:47 | licoresse | . |
| 08:47 | dgreensp | it's just that I'd rather not use the "unofficial" drop-into-Java solution from the blog post. |
| 08:51 | _ato | I'm not sure |
| 08:51 | _ato | looks like seq1 still hasn't yet been added to git :( |
| 08:53 | SynrG | i have meticulously documented the jline issue i mentioned with clojure-repl on linux the other day here: http://bugs.debian.org/576814 |
| 08:53 | SynrG | now, presumably this is an upstream issue and next, the debian maintainer forwards this upstream. |
| 08:55 | dgreensp | _ato: actually chunking will work fine here. good to know it's still lazy. thanks |
| 08:56 | LauJensen | Hi all - I'm fiddling with clojure.test and wondering about the convention. If I'm using namespace x.y.z, is putting test/x/y/z/test.clj sufficient for lein test to know what to do ? Provided that test.clj has the namespace x.y.z.test |
| 08:57 | tomoj | src/x/y/z.clj <-> test/x/y/test/z.clj |
| 08:57 | tomoj | x.y.z <-> x.y.test.z |
| 08:57 | esj | yup |
| 08:58 | tomoj | that's clojure-test-mode's convention |
| 08:58 | _ato | SynrG: in the meantime use rlwrap instead? |
| 08:58 | SynrG | rlwrap? |
| 08:58 | tomoj | but `lein test` will just run ALL tests, I think |
| 08:58 | tomoj | so you can, I think, use whatever convention you like |
| 08:58 | LauJensen | thanks tomoj I'll give it a whirl |
| 08:58 | SynrG | ah, a generic thing |
| 08:59 | _ato | yeah, uses readline (like bash etc) I think it provides more editing features than jline too |
| 09:01 | AWizzArd | When I want to inject some configuration info into my JVM in the call (in emacs) to clojure, should i then do this best via dynamic vars, with the "java -Dproperty=value" option? |
| 09:01 | LauJensen | tomoj: So the problem remains, that the test doesnt run - How do you troubleshoot that in a sane way ? |
| 09:02 | SynrG | _ato: reverse incremental search is one i rely on heavily |
| 09:02 | tomoj | how are you defining the tests? |
| 09:02 | _ato | rlwrap certainly does that |
| 09:02 | _ato | and history saving |
| 09:02 | LauJensen | tomoj: deftest/testing/is |
| 09:02 | chouser | and tab completion |
| 09:03 | tomoj | hmm.. deftest should certainly work |
| 09:03 | esj | LauJensen: the are macro is mega-useful |
| 09:03 | LauJensen | esj: Lets look into that once testing actually works/runs :) |
| 09:03 | LauJensen | tomoj: It just outputs Total: {} |
| 09:04 | SynrG | _ato: jline does history saving |
| 09:04 | tomoj | LauJensen: try running `lein test` on a `lein new` skeleton? |
| 09:04 | SynrG | tab-completion, ah, nice |
| 09:04 | _ato | AWizzArd: that'll only work if you're spawning java from inside emacs -- not when connecting to an remote swank server. But maybe that's okay for use-case? |
| 09:04 | _ato | your use-case* |
| 09:04 | SynrG | so i guess it has some language-awareness somehow? |
| 09:04 | AWizzArd | _ato: yes, but anyway, do you have another suggestion? |
| 09:05 | tomoj | `lein new foo && cd foo && lein deps && lein test` should give you 1 failure |
| 09:05 | AWizzArd | I would just like to inject information into a Clojure during start up. |
| 09:05 | LauJensen | tomoj: Runs fine |
| 09:05 | chouser | SynrG: well, you can teach it things -- give it a completion file and/or command line options for what defines a "word" |
| 09:05 | AWizzArd | In my .emacs I don’t see how I can add command line args, as in swank-clojure-command-line-args, so I thought I could add a -D to swank-clojure-extra-vm-args |
| 09:05 | _ato | AWizzArd: if it has to be during startup then yeah, that's probably the best way to do it |
| 09:06 | tomoj | LauJensen: hmm.. any weird deps in your project.clj? leiningen stuff maybe? |
| 09:06 | LauJensen | No - I'll fiddle, thanks for the help |
| 09:06 | chouser | SynrG: I haven't bothered to populate my completiong file yet, but within a single session it learns from expressions you enter and will complete those words later |
| 09:06 | tomoj | it should just find every test defined in any clj file under test/, I think |
| 09:09 | zakwilson | Haskell's Data.Map has union, intersection and difference functions. I don't see equivalents in the Clojure API. Are they there under different names? They're easy enough to write, but I see no point in reinventing the wheel without cause. |
| 09:11 | _ato | ,(clojure.set/union #{1 2} #{2 3}) |
| 09:11 | clojurebot | #{1 2 3} |
| 09:11 | _ato | zakwilson: see http://richhickey.github.com/clojure/clojure.set-api.html |
| 09:12 | chouser | zakwilson: those sound like set ops, so I'm not sure how Haskell defines them on maps. |
| 09:12 | dgreensp | ,(into {:a 1 :b 2} {:c 3 :d 4}) |
| 09:12 | clojurebot | {:a 1, :b 2, :c 3, :d 4} |
| 09:12 | chouser | ,(apply dissoc {:a 1, :b 2} (keys {:b 2, :c 3})) ; difference? |
| 09:12 | clojurebot | {:a 1} |
| 09:12 | chouser | ,(select-keys {:a 1, :b 2} (keys {:b 2, :c 3})) ; intersection? |
| 09:12 | clojurebot | {:b 2} |
| 09:12 | triyo | Whats the most idiomatic way to model data associations in Clojure? |
| 09:12 | _ato | ah map.. missed that |
| 09:13 | AWizzArd | Is there already a tool, possibly in Contrib, which helps to load config files? I am about to implement a little (load-config) or something like that which will load .clj files to configure computer specific settings. |
| 09:13 | tomoj | hmm, I'm confused |
| 09:13 | tomoj | lein says it downloaded clojure-contrib-1.2.0-master-20100122.191106-1.jar from clojars |
| 09:13 | SynrG | chouser: ah, nice. |
| 09:14 | _ato | AWizzArd: what would such a tool do? isn't loading a clj as configuration just a matter of calling (read ..) on the file? |
| 09:14 | triyo | nested maps or some other better suited strategy? |
| 09:14 | tomoj | seems like clojars somehow forwards to http://build.clojure.org/releases/org/clojure/clojure-contrib/ |
| 09:14 | SynrG | oh, and it does paren flashing. super! |
| 09:14 | tomoj | but there is no 1.2.0 there |
| 09:14 | zakwilson | chouser: they work like the set ops with respect to keys, and prefer the values from the first argument. |
| 09:14 | _ato | tomoj: clojars does even trickier stuff than that |
| 09:14 | SynrG | submitting this extra info on the bug to use rlwrap as a workaround. thanks, guys |
| 09:15 | _ato | it forwards snapshots to http://build.clojure.org/snapshots/ |
| 09:15 | chouser | SynrG: it has a decent vi-bindings mode too. It's no vim, but better than nothing. :-) |
| 09:15 | tomoj | oh, I see |
| 09:15 | SynrG | chouser: sure :) |
| 09:15 | zakwilson | There are also union/intersection/difference With functions, that take a combination function (usually something like concatenation, addition or subtraction) |
| 09:15 | tomoj | I guess my question is then, why is the clojure-contrib snapshot so old? |
| 09:15 | chouser | zakwilson: so the expressions dgreensp and I pasted here should get you started |
| 09:15 | SynrG | there's a separate debian bug asking for clojure to Recommend jline, so i think I'll cross-reference this bug in that bug ... as this is clearly a superior solution |
| 09:16 | psykotic | zakwilson: there's merge, which is like haskell's data.map union. there's also merge-with, which lets you specify how to merge rather than preferring the first unconditionally. |
| 09:16 | AWizzArd | _ato: it would look up an environment variable, such as $CONFIG_ID which is maybe set to "ato" on *your* computer. Then when you include the com.company.server namespace in your project, it will have (def *port* 80) as default, but then after all the defs you place a (load-config). And then it looks up *your* specific config file from the repository, for exmaple /hg/clj/configs/ato/com/company/server.clj |
| 09:16 | zakwilson | chouser: Yep, those are about what I was looking for. I just wanted to know if I had to write them, or if they had different names. |
| 09:16 | AWizzArd | And in your config you have a (def *port* 8080) and other settings for your server, or whatever it is. |
| 09:18 | _ato | ah, so per-environment configuration? Ah no I don't think I've seen something that does that, shouldn't be hard to write though. |
| 09:19 | AWizzArd | _ato: yes, it’s a simple write |
| 09:19 | triyo | ,*clojure-version* |
| 09:19 | clojurebot | {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"} |
| 09:21 | dgreensp | zakwilson: it's kind of jarring coming from Haskell or Scala to find a collections library with no nouns, only verbs, and fewer of those :) |
| 09:24 | dgreensp | can I define my own ISeqs? |
| 09:25 | chouser | dgreensp: sure, a couple different ways |
| 09:25 | dgreensp | (clojure doesn't have interfaces, but doesn't really replace them either, except maybe with multimethods...) |
| 09:25 | tomoj | 1.2 does |
| 09:26 | chouser | dgreensp: clojure has interfaces, but they're less useful than protocols and multimethods |
| 09:27 | dgreensp | are protocols new? I'm working off of 1.1 |
| 09:27 | chouser | dgreensp: probably the easiest way to provide your own behavior for an ISeq is with 'lazy-seq' |
| 09:27 | chouser | dgreensp: yes, protocols are in github master, not in an official release yet. |
| 09:27 | AWizzArd | dgreensp: https://www.assembla.com/wiki/show/clojure/Protocols |
| 09:27 | chouser | dgreensp: but even in 1.1, clojure fully supports Java interfaces |
| 09:28 | dgreensp | yeah, though Java interfaces should be treated as for interop only I assume |
| 09:28 | dgreensp | I guess ISeqs are a bad example, they are easy to build |
| 09:29 | zakwilson | dgreensp: I actually learned Clojure before Haskell, but I haven't used Clojure very much lately. |
| 09:29 | dgreensp | what about random-access seqs, like java.util.List or scala's "Seq" class, which have a size and an apply/get method? |
| 09:29 | chouser | well, as you say they're not really replaced by anything in 1.1, so they can be useful outside of interop |
| 09:30 | dgreensp | I'm actually making a random-access seq right now in some code with a custom backing |
| 09:30 | chouser | dgreensp: have you looked at 'proxy'? |
| 09:30 | dgreensp | yes, I know a bit about proxy; trying to be idiomatic I guess |
| 09:31 | chouser | proxy is the best way to implement interfaces in 1.1 |
| 09:31 | chouser | and it's entirely idiomatic |
| 09:31 | dgreensp | ok, though the interface itself is always defined in Java code somewhere... |
| 09:33 | chouser | you can defined new interfaces using gen-interface, though you do need to AOT compile that. |
| 09:33 | dgreensp | heh, that's cool |
| 09:33 | dgreensp | clojure's interop has definitely been thought through |
| 09:33 | dgreensp | I'm having a great time with it |
| 09:34 | chouser | dgreensp: this story is dramatically improved now in what will become 1.2 |
| 09:34 | chouser | protocols are awesome |
| 09:34 | dnolen | *dramatically* |
| 09:44 | dgreensp | sweet, looking forward to what's coming in 1.2. |
| 09:48 | dgreensp | my initial skepticism about clojure's potential for speed (I've written a lot of tight loops in Java) is subsiding |
| 09:54 | dnolen | so after 1 1/2 of Clojure I'm finally starting to look into agents :) So is the difference with send-off/send that send-off creates a thread per agent? |
| 09:54 | dnolen | 1 1/2 years |
| 09:54 | chouser | dnolen: not necessarily. |
| 09:55 | chouser | dnolen: the difference is that the number of threads in the send pool is bounded by the number of processor cores, the send-off pool is unbounded. |
| 09:55 | dnolen | chouser: I'm using send and it looks like sleeping the thread slows all other agents down. |
| 09:56 | chouser | dnolen: right, if your action is constrained by anything other than the CPU (sleeps, IO blocking, etc.) you should use send-off. |
| 09:57 | dnolen | chouser: so you're saying that send would use a thread send pool of 2 if I have two cores? |
| 09:57 | dnolen | or just some optimal small number? |
| 09:57 | dnolen | I have 150 agents |
| 09:58 | chouser | dnolen: the send pool currently has a max of cpus+2 threads, so 4 in your case. But that's of course an implementation detail that might change. |
| 09:59 | chouser | the number of agents doesn't matter |
| 09:59 | AWizzArd | ,do |
| 09:59 | clojurebot | java.lang.Exception: Unable to resolve symbol: do in this context |
| 09:59 | AWizzArd | ,(fn [a] do(* 2 a)) |
| 09:59 | clojurebot | #<sandbox$eval__8370$fn__8372 sandbox$eval__8370$fn__8372@16e1533> |
| 09:59 | AWizzArd | ,((fn [a] do(* 2 a)) 100) |
| 09:59 | clojurebot | 200 |
| 09:59 | AWizzArd | why can do be resolved here? |
| 09:59 | dnolen | chouser: thx, I now am a little bit closer to understanding agents :) |
| 09:59 | Chousuke | it's probably just ignored rather than resolved |
| 10:00 | chouser | what matters is what the agents are doing. if the action you want to send will block or sleep, use send-off. If it will just burn cpu (tight loops, math, etc.) use send. |
| 10:00 | Chousuke | ,(do do 2) |
| 10:00 | clojurebot | java.lang.Exception: Unable to resolve symbol: do in this context |
| 10:00 | carkh | ,((fn [a] interleave (*2 a) 100)) |
| 10:00 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--8382$fn |
| 10:00 | Chousuke | ,(fn [x] do 2) |
| 10:00 | clojurebot | #<sandbox$eval__8388$fn__8390 sandbox$eval__8388$fn__8390@218a7f> |
| 10:00 | Chousuke | ,(fn [x] foo 2) |
| 10:00 | clojurebot | java.lang.Exception: Unable to resolve symbol: foo in this context |
| 10:00 | Chousuke | hmm, interesting |
| 10:01 | chouser | ,(fn [] do) |
| 10:01 | clojurebot | #<sandbox$eval__8398$fn__8400 sandbox$eval__8398$fn__8400@c06cac> |
| 10:01 | chouser | ,(fn [] do do) |
| 10:01 | clojurebot | java.lang.Exception: Unable to resolve symbol: do in this context |
| 10:01 | Chousuke | what does that return? |
| 10:01 | Chousuke | ,((fn [] do)) |
| 10:01 | clojurebot | nil |
| 10:02 | Chousuke | that's... rather weird. |
| 10:02 | carkh | it isn't |
| 10:03 | chouser | ,[do] |
| 10:03 | clojurebot | nil |
| 10:03 | carkh | special forms are special ! |
| 10:03 | chouser | ,[do do] |
| 10:03 | clojurebot | java.lang.Exception: Unable to resolve symbol: do in this context |
| 10:03 | Chousuke | chouser: that definitely is weird |
| 10:03 | Chousuke | ,[do 2] |
| 10:03 | clojurebot | 2 |
| 10:04 | Chousuke | :D |
| 10:04 | chouser | ha! |
| 10:04 | chouser | AWizzArd: so, um... don't do that. |
| 10:06 | chouser | well, there it is. if an "implicit do" starts with the symbol 'do', that symbol is ignored |
| 10:06 | stuartsierra | Does Incanter plotting work in headless mode? e.g., to generate PNGs |
| 10:06 | liebke | stuartsierra: yes, use the save function on the chart object |
| 10:08 | stuartsierra | ok |
| 10:09 | stuartsierra | One of my students couldn't get it to run on a plain-text SSH session. |
| 10:09 | chouser | http://tinyurl.com/ycuz3z5/src/jvm/clojure/lang/Compiler.java#LID4622 |
| 10:11 | liebke | stuartsierra: I have seen that issue before, when loading incanter.processing, but not with incanter.charts. |
| 10:13 | bsteuber | chouser: what is this good for, then? |
| 10:13 | stuartsierra | ok, might be because they're just running the uberjar |
| 10:13 | liebke | even that shouldn't be an issue, if they are not loading incanter.processing, unless they have a really old version |
| 10:14 | liebke | stuartsierra: if you use ssh -X when working with Processing, then it should load fine. |
| 10:15 | chouser | bsteuber: the 'do' thing? it's just an implementation detail leaking out. |
| 10:15 | chouser | not to be relied upon |
| 10:16 | chouser | and is only going to cause problems if you name your own things 'do', which you really really shouldn't do. |
| 10:16 | chouser | ,(let [do 5] do) |
| 10:16 | clojurebot | nil |
| 10:16 | stuartsierra | liebke: I told them to download 1.0.0 |
| 10:16 | Chousuke | that really should fail :/ |
| 10:16 | Chousuke | with an exception |
| 10:16 | chouser | ,(let [do 5] nil do) ; seriously, don't do this |
| 10:16 | clojurebot | 5 |
| 10:16 | liebke | hmm, 1.0.0 shouldn't fail |
| 10:17 | bsteuber | chouser: sure, I was just curious :) |
| 10:17 | AWizzArd | re |
| 10:17 | wthidden | cgrand: thanks for your blog post about flattening reduces I had a chance to use such an idiom today. |
| 10:17 | chouser | bsteuber: me too :-) |
| 10:17 | AWizzArd | chouser: I don’t want to do that, but in #Clojure.de we just stumbled upon such a piece of code and I was curious why (do do(+ 1 2)) doesn’t work, but the same thing inside a fn does. |
| 10:19 | chouser | AWizzArd: well, I explained that. both are unsupported, but only one is caught by the current compiler. |
| 10:20 | chouser | AWizzArd: http://tinyurl.com/ycuz3z5/src/jvm/clojure/lang/Compiler.java#LID4622 |
| 10:20 | chouser | AWizzArd: if an "implicit do" starts with the symbol 'do', that symbol is ignored |
| 10:21 | AWizzArd | chouser: oh good thanks, that is what I was looking for. So, it’s the compiler. |
| 10:22 | tomoj | ok, but what about [do 3] ? |
| 10:23 | chouser | heh, yeah that's probably something else. |
| 10:23 | AWizzArd | oh |
| 10:24 | tomoj | I mean, I'd expect [do 3] to be [3], not 3 |
| 10:25 | Chousuke | it's because the compiler uses RT.first to check for the do symbol |
| 10:25 | chouser | or [nil 3] or an error, right. |
| 10:25 | Chousuke | ,#{do 3} |
| 10:25 | clojurebot | java.lang.Exception: Unable to resolve symbol: do in this context |
| 10:25 | Chousuke | ,#{'do 3} |
| 10:25 | clojurebot | #{3 do} |
| 10:25 | Chousuke | hmm |
| 10:25 | Chousuke | ,#{'do 2344} |
| 10:25 | clojurebot | #{2344 do} |
| 10:26 | Chousuke | ,#{do -1} |
| 10:26 | clojurebot | -1 |
| 10:26 | Chousuke | :P |
| 10:26 | AWizzArd | strange |
| 10:26 | Chousuke | ,(seq #{do -1}) |
| 10:26 | clojurebot | java.lang.Exception: Unable to resolve symbol: do in this context |
| 10:26 | Chousuke | ,(seq #{'do -1}) |
| 10:26 | clojurebot | (do -1) |
| 10:27 | chouser | Chousuke: I think it's a different issue |
| 10:27 | chouser | [...] is not an "implicit do" |
| 10:27 | chouser | but still looking... |
| 10:30 | liebke | stuartsierra: I just tested version 1.0 with plain ssh (no -X option), and charts loaded without error (processing, of course, had the usual initialization error). So make sure your student isn't loading processing instead of charts (unless they use ssh -X). |
| 10:33 | tomoj | that negative thing is very very odd |
| 10:33 | tomoj | ,#{do -9} |
| 10:33 | clojurebot | -9 |
| 10:33 | tomoj | ,#{do -10} |
| 10:33 | clojurebot | -10 |
| 10:34 | tomoj | actually |
| 10:34 | tomoj | ,#{do -16} |
| 10:34 | clojurebot | -16 |
| 10:34 | tomoj | ,#{do -17} |
| 10:34 | clojurebot | java.lang.Exception: Unable to resolve symbol: do in this context |
| 10:34 | tomoj | thought it only worked for one-digit negative integers, but no, even weirder... |
| 10:35 | npoektop | what's wrong with (:use [com.server.tests.testhelpers :only (run-these-tests)])? when i add this line to ns, it says "at com.server.tests.junit$runtests__1343.invoke(junit.clj:30) [java] at user$eval__1347.invoke(NO_SOURCE_FILE:1)" |
| 10:36 | Chousuke | tomoj: it's because the hash codes happen to decide the order |
| 10:37 | Chousuke | ,(map #(.hashCode %) '[-17 do -9]) |
| 10:37 | clojurebot | (-17 -1640328432 -9) |
| 10:37 | Chousuke | I suppose that somehow decides the order :/ |
| 10:38 | tomoj | ahh, I see |
| 10:38 | npoektop | and it says [java] Caused by: java.lang.NullPointerException |
| 10:40 | tomoj | npoektop: do you have something in testhelpers.clj that calls runtests? |
| 10:41 | tomoj | if you put some code it testhelpers.clj at the top level (not inside defns/etc), it will be run when you try to use the namespace |
| 10:44 | npoektop | tomoj, even if i use :only? |
| 10:44 | tomoj | yeah, :only doesn't mattter |
| 10:44 | tomoj | the file has to be loaded |
| 10:45 | npoektop | and no, no runtests in testhelpers.clj |
| 10:45 | tomoj | and when the file is loaded, any top-level code is run |
| 10:45 | tomoj | oh, hmm |
| 10:46 | tomoj | can you paste testhelpers.clj somewhere (e.g. paste.lisp.org) |
| 10:47 | AWizzArd | Still, it really does not seem very intuitive with its current behaviour. |
| 10:52 | npoektop | tomoj, http://pastebin.com/SJheevSF |
| 10:54 | tomoj | well, I don't see any bad toplevel code there |
| 10:54 | tomoj | maybe in one of your other namespaces which is required by testhelpers? |
| 10:55 | tomoj | npoektop: this error is happening when you try to load junit.clj? |
| 11:16 | konr | What's the direct translation of pen-width.valueChanged.connect(foo,"setPenWidth(int)")? (.connect (.valueChanged pen-width) foo "setPenWidth(int)")? |
| 11:18 | Chousuke | hmm |
| 11:19 | Chousuke | I would do (-> pen-width .valueChanged (.connect foo "setPenWidth(int)")) |
| 11:24 | konr | much nicer, Chousuke! These arrows seem to be always handy |
| 11:31 | konr | shouldn't this thing have a method foo? http://pastebin.com/WHnG4D32 |
| 11:36 | chouser | konr: proxy can only implement existing methods, not define new ones. |
| 11:37 | npoektop | how to splice a vector of args to another function's args? (defn foo [& args] (require _spliced_args_)) |
| 11:38 | bsteuber | npoektop: apply |
| 11:40 | bsteuber | ,(let [myfun (fn [& args] (apply + args))] (myfun 1 2 3 4 5)) |
| 11:40 | clojurebot | 15 |
| 11:41 | npoektop | bsteuber, thank you. It's so obvious that i'm confused) |
| 11:41 | bsteuber | :) |
| 11:42 | stbgz | hello there anybody knows how to change the class path in swank-clojure? |
| 11:43 | liwp | stbgz: I just use the swank-clojure-project function and leiningen |
| 11:44 | stuartsierra | I use Maven and the clojure:swank goal |
| 11:44 | liwp | stbgz: or do you mean after you've launched slime? |
| 11:45 | bsteuber | stbgz: there are emacs vars called swank-clojure-classpath and swank-clojure-extra-classpath |
| 11:46 | stbgz | well I trying to add a jar to my project but after I run slime I get a ClassNotFound exception when trying to load the classes of the jar, I added swank-clojure-project to my .emacs and still no luck |
| 11:47 | bsteuber | swank-clojure-project doesn't belong in the .emacs |
| 11:47 | bsteuber | it is meant to be called by hand |
| 11:47 | carkh | so who was it that gave the advice to automatically delete trailing spaces when saving in emacs ? verrrrrry bad advice =) |
| 11:48 | carkh | i have this file with lots of database statements that update the database to match my program version |
| 11:48 | carkh | and lots of lines are ending with a "," |
| 11:48 | carkh | which i guess is considered as a white space by clojure mode |
| 11:49 | carkh | so when i save the file, all my trailing commas are deleted |
| 11:49 | stbgz | hmm so load slime and then run swank-clojure-projecct |
| 11:49 | stbgz | ? |
| 11:50 | carkh | how would that help ? |
| 11:50 | carkh | anyways it's too late, i need to go back put all the commas in place and retest the whole thing ='( |
| 11:51 | stbgz | what about adding the swank-clojure-classpath and |
| 11:51 | stbgz | swank-clojure-extra-classpath in my .emacs file? |
| 11:51 | liwp | stbgz: no, just do M-x swank-clojure-project (requires that you have a leiningen project.clj in your project directory) |
| 11:52 | carkh | stbgz: oh sorry i thought you were reacting to my crying |
| 11:52 | liwp | stbgz: swank-clojure-project will start slime for you |
| 11:53 | liwp | stbgz: using swank-clojure-(extra-)classpath is a real pain because you need to edit your .emacs when ever you change the clojure project that you're working with |
| 11:53 | carkh | ~seen technomancy |
| 11:53 | clojurebot | technomancy was last seen in #clojure, 634 minutes ago saying: I have it under "for later", but if I got a patch for it I would be happy to move it to 1.2.0. =) |
| 11:54 | stbgz | I see I was trying to do it without having leiningen around |
| 11:54 | bsteuber | stbgz: so swank-clojure-project finds all jar's in your project's lib subfolder |
| 11:54 | bsteuber | if you have clojure.jar etc. there, it's fine |
| 11:55 | bsteuber | I just set swank-clojure-classpath for setting the version slime uses without projects, when I just want a repl to play |
| 11:55 | liwp | stbgz: an alternative is to write a script that calls java for you with an appropriate classpath and then setup swank-clojure to call that script rather than java when you start slime |
| 11:56 | liwp | stbgz: if you google around for slime / clojure / start script you should be able to find some examples - I've seen some shell scripts and a ruby script IIRC |
| 11:57 | liwp | but leiningen and swank-clojure-project is definitely the easiest way to get going once you have leiningen running, i.e. you've downloaded all of Internet with maven etc. |
| 11:57 | stbgz | I see i was trying to modify the swank-clojure.el but that's not the best idea |
| 11:57 | liwp | nope :-) |
| 11:58 | stbgz | alright it seems like I'll have to install ant+mave+leinigen |
| 11:58 | stbgz | :S |
| 11:58 | liwp | stbgz: enjoy :-/ |
| 11:58 | stbgz | thanks guys |
| 11:58 | stbgz | cheers |
| 11:59 | liwp | np |
| 12:26 | underdev | Is there an api index somewhere that has the clojure.core api indexed by... err.. how to say this.. what it's used for? |
| 12:26 | underdev | i would say function, but that wouldn't make sense in this context :) |
| 12:27 | underdev | ie namespace functions, collection functions, etc |
| 12:30 | ndimiduk | i get an exception when using `lein compile` from (gen-interface :name com.foo.IFoo :methods [[foo [String] "[Ljava.lang.String;"]]). |
| 12:30 | ndimiduk | Exception in thread "main" java.lang.ClassFormatError: Method "foo" |
| 12:30 | ndimiduk | in class com/foo/IFoo has illegal signature "L[Ljava/lang/String;;" |
| 12:30 | ndimiduk | what am i doing wrong? |
| 12:57 | ndimiduk | how do I specify a native array in a method signature within gen-interface? |
| 12:58 | kotarak | "[B;" or so |
| 12:58 | kotarak | ,(class (into-array ["foo"])) |
| 12:58 | clojurebot | [Ljava.lang.String; |
| 12:58 | ndimiduk | I'd like to return a String[] and using "[Ljava.lang.String;" doesn't work |
| 13:00 | kotarak | ndimiduk: can you paste your code? |
| 13:00 | ndimiduk | so, I have (gen-interface :name com.foo.Foo :methods [[foo [String] "[Ljava.lang.String;"]]) |
| 13:00 | kotarak | hmmm |
| 13:00 | kotarak | seems right |
| 13:01 | ndimiduk | http://gist.github.com/359131 |
| 13:02 | ndimiduk | oops, that type is not what i ment |
| 13:03 | ndimiduk | fixed |
| 13:03 | ndimiduk | yeah, so this doesn't compile. i'm using leiningen |
| 13:04 | ndimiduk | Exception in thread "main" java.lang.ClassFormatError: Method "foo" in class com/foo/IFoo has illegal signature "L[Ljava/ |
| 13:04 | ndimiduk | lang/String;;" |
| 13:06 | ndimiduk | looks like clojure.asm.Type/getObjectType() always prepends 'L' and appends ';' |
| 13:06 | ndimiduk | which is called from clojure.core/generate-interface |
| 13:06 | ndimiduk | http://github.com/richhickey/clojure/blob/29389970bcd41998359681d9a4a20ee391a1e07c/src/jvm/clojure/asm/Type.java#L270 |
| 13:08 | ndimiduk | http://github.com/richhickey/clojure/blob/1.1.0/src/clj/clojure/genclass.clj#L614 |
| 13:08 | dnolen | ndimiduk: because the JVM expects that |
| 13:09 | ndimiduk | dnolen: in addition to what's provided in "[Ljava.lang.String;"? |
| 13:09 | ndimiduk | dnolen: because the compiler says "L[Ljava.lang.String;;" is not a valid type specifier |
| 13:10 | ndimiduk | dnolen: oh, you just joined. the context is http://gist.github.com/359131 won't compile |
| 13:10 | dnolen | yeah, I was about to say I think I missed something |
| 13:12 | kotarak | ,(clojure.lang.RT/classForName "[Ljava.lang.String;") |
| 13:12 | clojurebot | [Ljava.lang.String; |
| 13:12 | kotarak | Hmm, it's not possible to inject class into gen-interface, no? |
| 13:13 | ndimiduk | kotarak: correct. I tried (type (into-array [""])) instead of the type string. doesn't work. |
| 13:15 | chouser | hm, you might try #=(java.lang.Class/forName "[Ljava.lang.String;") |
| 13:16 | kotarak | chouser: is there a reason gen-interface does things differently to gen-class? |
| 13:16 | ndimiduk | chouser: haha, that works |
| 13:16 | kotarak | chouser: the latter basically uses with RT/classForName. |
| 13:17 | chouser | sorry, I haven't really looked at this issue |
| 13:17 | chouser | RT/classForName should work as well. the key is #=() |
| 13:18 | kotarak | chouser: I meant that gen-class uses internally RT/classForName to resolve the classes, while gen-interface does not. |
| 13:19 | chouser | no, I have no idea. |
| 13:20 | kotarak | http://github.com/richhickey/clojure/blob/1.1.0/src/clj/clojure/genclass.clj#L83 vs. http://github.com/richhickey/clojure/blob/1.1.0/src/clj/clojure/genclass.clj#L599 |
| 13:20 | kotarak | Maybe this could be unified. |
| 13:21 | chouser | gen-interface is largely superceded by definterface |
| 13:21 | kotarak | k |
| 13:22 | chouser | it has classloader magic that lets you redefine existing interfaces. |
| 13:23 | kotarak | oh, ah, "here be dragons"? |
| 13:23 | The-Kenny | Wasn't "here be dragons" the slogan of the latest chaos communication congress in berlin? |
| 13:23 | chouser | hm, pretty sure it's good magic |
| 13:24 | stuartsierra | What's the goal of definterface vis-a-vis defprotocol? |
| 13:25 | fogus | primitives |
| 13:25 | kotarak | I would suspect host interaction |
| 13:25 | chouser | you both beat me to it. I think those are the two benefits currently. Dunno how either of them stand up long-term |
| 13:26 | chouser | defprotocol already creates a same-named host interface if you AOT |
| 13:26 | chouser | and I imagine defprotocol eventually will support the same primitives supported by fn |
| 13:28 | ndimiduk | def{interface,protocol} are in 1.2, yes? should i be using that api instead? |
| 13:28 | ndimiduk | i've been working with clojure-1.1.0 because contrib is stable along side it. |
| 13:30 | fogus | I know that Clojure macros tend to have implicit pairs (i.e. cond case etc...) and I know how to write a macro that handles them (i.e. partition 2) but what about on the other hand if we are writing a macro to build the implicit pairs? I currently have an aux function that returns ((:a 1) (:b 2)) and have only been able to have success doing ~@(flatten the-pairs). Seems like there is a better way |
| 13:31 | chouser | I've used (apply concat the-pairs) |
| 13:32 | kotarak | ,(apply concat [[1 2] [3 4]]) |
| 13:32 | clojurebot | (1 2 3 4) |
| 13:32 | fogus | chouser: That's perfect! Now I can avoid defining flatten |
| 13:33 | kotarak | ,(mapcat identity [[1 2] [3 4]]) |
| 13:33 | clojurebot | (1 2 3 4) |
| 13:33 | fogus | chouser: thanks. You should write a book or something |
| 13:33 | chouser | other times it's useful to treat the seq of firsts and seconds separately, in which case interleave is handy |
| 13:34 | chouser | fogus: you mean instead of frittering away my time answering questions here, don't you. ;-) |
| 13:34 | fogus | kotarak: Thanks. |
| 13:35 | dnolen | ndimiduk: I use clojure 1.2.0 and contrib 1.2.0 they "seem" ok . it's might be little a bit of a workflow hassle (if you use lein or something) but it's worth it I think. |
| 13:35 | kotarak | fogus: many ways to Rome - eh - flattened lists. ;) |
| 13:36 | fogus | chouser: Thanks. In this case the flatten is the answer, but what case do you see for treating them differently? |
| 13:36 | fogus | kotarak: Seems I need to study up on the fine art of flattening |
| 13:37 | kotarak | fogus: and then maybe write a book about it. ;) |
| 13:38 | dakrone | "Flattening will get you everywhere" |
| 13:39 | dakrone | oh wait, maybe that's Flattery |
| 13:39 | kotarak | Flatten in Action, Pragmatic Flattening, The Art of List Flattening (the 5 Volume version), ... |
| 13:39 | fogus | Head First Flattening |
| 13:39 | stuartsierra | fogus: I like Head First Flattening. |
| 13:39 | dakrone | Learn to Flatten in 21 days |
| 13:39 | kotarak | Touch yourself flattening in fixnum days |
| 13:40 | kotarak | Teach |
| 13:40 | fogus | stuartsierra: sounds painful. ;-) |
| 13:40 | stuartsierra | yes |
| 13:40 | fogus | I've been waiting 2 days to say that |
| 13:40 | stuartsierra | :) |
| 13:42 | kotarak | If I set System.in to something else... will it automagically picked by |
| 13:42 | kotarak | *in*? |
| 13:42 | stuartsierra | I don't think so |
| 13:42 | kotarak | geez |
| 13:44 | stuartsierra | *in* is a Var in its own right, not identical to System.in |
| 13:44 | fogus | Almost perfect... Just need to find a way to get rid of that ~~x |
| 14:01 | maacl | Is there an elegant way to interact with Java lists that only implement get() and size() methods? |
| 14:02 | kotarak | maacl: define a seq on them |
| 14:03 | maacl | So implement first rest and cons? |
| 14:03 | hiredman | how is that a list? |
| 14:04 | maacl | hiredman: It is quite strange but that is what several of the classes in the XOM library looks like. |
| 14:04 | maacl | They call them lists, but I would tend to agree with you. |
| 14:05 | hiredman | (map #(.get LIST %) (range (.size LIST))) |
| 14:05 | hiredman | or (take (.size LIST) (repeatedly #(.get LIST))) |
| 14:06 | maacl | ah |
| 14:06 | chouser | I've used map like that a few times |
| 14:06 | slyphon | number of elements in a seq? |
| 14:07 | chouser | slyphon: count |
| 14:07 | slyphon | ty |
| 14:07 | chouser | but that's O(n) on a seq -- forces the whole thing |
| 14:07 | slyphon | yeah, that's ok in this situation |
| 14:09 | maacl | thanks - that will make it less painful |
| 14:21 | Licenser | doseq: I read about your idea I've something to look at for you |
| 15:41 | slyphon | is it possible to run a single deftest? |
| 15:45 | zaphar_ps | slyphon:in emacs M-x clojure-test-run-test while on the deftest form to run |
| 15:45 | slyphon | oh sweet |
| 15:45 | zaphar_ps | or is it clojure-test-runtest? |
| 15:45 | zaphar_ps | can't remember off hand |
| 15:45 | slyphon | hmm |
| 15:46 | slyphon | that seems like it doesn't run fixtures |
| 15:46 | zaphar_ps | slyphon: yeah it probably doesn't |
| 15:46 | slyphon | eh, w/e |
| 15:46 | slyphon | zaphar_ps: thanks |
| 15:47 | zaphar_ps | there is a clojure.test/runtest also I believe haven't really used it though |
| 15:47 | slyphon | hrm |
| 15:47 | slyphon | i thought it was only "run-tests" |
| 15:48 | carkh | just run it as a function with no parameters |
| 15:48 | slyphon | run which? |
| 15:48 | slyphon | the deftest? |
| 15:48 | carkh | yes |
| 15:48 | slyphon | oh |
| 15:48 | carkh | (test-id-seq-update) |
| 15:48 | slyphon | oh, good call |
| 15:48 | zaphar_ps | carkh: does that run the fixtures as well? |
| 15:48 | slyphon | :) |
| 15:49 | slyphon | yeah, apparently it does |
| 15:49 | slyphon | oh wait |
| 15:49 | carkh | zaphar_ps: i really don't know =P |
| 15:49 | slyphon | no |
| 15:49 | slyphon | it don't |
| 15:49 | zaphar_ps | cause I thought the emacs one just did that |
| 15:49 | slyphon | s'ok |
| 15:49 | zaphar_ps | yeah |
| 15:49 | zaphar_ps | you can always run the fixtures manually |
| 15:49 | slyphon | yeah, i have a macro i can wrap the body of the test with |
| 16:08 | chouser | they say it's "in production", though I'm not exactly sure what that means. |
| 16:09 | LauJensen | chouser: That probably means that they are cleaning out your typos |
| 16:09 | chouser | hopefully |
| 16:10 | LauJensen | Did you write your part in Vim by any chance ? :) |
| 16:10 | chouser | of course |
| 16:10 | chouser | am writing |
| 16:10 | LauJensen | ok, and ehm.. I'm guessing no spelling correction in Vim? |
| 16:10 | carkh | ah damn you're not chouser anymore but c-houser =/ |
| 16:11 | LauJensen | carkh: You thought he was chinese too ? |
| 16:11 | carkh | nah just thought he was very picky ! |
| 16:22 | shales | hi, I'm trying to setup a google appengine project with clojure and maven |
| 16:23 | shales | specifically trying to get the make changes <-> see results loop nice and tight |
| 16:25 | shales | I've got the clj source files in layed out like a war and am running the appengine devserver directly from that so I can see changes by just reloading the browser |
| 16:26 | shales | but for this to work, whenever I require a namespace it also needs to :reload |
| 16:27 | shales | Is there a better way to handle this than putting :reload everywhere? Is having all of these reloads in a deployed app even a bad idea? |
| 16:27 | chouser | you can do a single :reload-all at the top |
| 16:28 | shales | oh, yeah. perfect. thanks! |
| 16:29 | shales | I think I read that, but then totally forgot about it |
| 16:31 | slyphon | is there something in contrib that will diff two hashes? |
| 16:31 | slyphon | er, hash-maps |
| 16:31 | slyphon | and return just the differences? |
| 16:32 | chouser | just diffs among keys, or values also? recursively? |
| 16:32 | slyphon | well, in this case it's a flat hash-map |
| 16:33 | slyphon | in my code, i return a db row, and stash a copy of the original hash in the metadata, when that "row" is altered, and then used as the argument to my "update" function, i want to only update the cols that have changed |
| 16:34 | chouser | ah, so the keys are the same? you want a list of keys for which the values are different? |
| 16:34 | slyphon | yeah, that sounds right |
| 16:36 | slyphon | i mean, i could probably write a for statement that does it, but i wanted to see if there were something clever that already existed |
| 16:36 | chouser | I don't know of such a thing. |
| 16:36 | slyphon | ok :) |
| 16:36 | chouser | ,(let [oldm {:a 1 :b 2} newm {:a 1 :b 3}] (remove #(= (oldm %) (newm %)) (keys oldm))) |
| 16:36 | clojurebot | (:b) |
| 16:36 | slyphon | oooh |
| 16:36 | slyphon | nice |
| 16:36 | slyphon | chouser: ty |
| 16:49 | slyphon | hrm |
| 16:49 | slyphon | if-let would be more useful it seems if it had an alternative 'else' value |
| 16:57 | kotarak | slyphon: like (let [foo (or if-let-clause else-value)] ....)? |
| 16:57 | drewr | ,(deftype Foo [] IPersistentMap) (merge {} (Foo)) |
| 16:57 | clojurebot | DENIED |
| 16:57 | slyphon | kotarak: something like that |
| 16:58 | slyphon | i guess it's intended to be used in specific situations |
| 16:59 | slyphon | it'd kind of behave like 'get' with the alternative value |
| 17:00 | kotarak | slyphon: it's called "or", no? |
| 17:00 | slyphon | heh, i guess it is |
| 17:00 | Borkdude | if you would have kotarak's one, why not just use an if inside a let? |
| 17:00 | slyphon | well, that's what i've been doing |
| 17:01 | kotarak | slyphon: (if-let [foo (bla) hypothetical-else] ...) <=> (let [foo (or (bla) not-so-hypothetical-else)] ...) |
| 17:01 | slyphon | yeah, i guess i wasn't thinking very creatively about it |
| 17:04 | slyphon | kotarak: i guess it's that if say, i'm using if-let to avoid some computation in the case that the test is logical false, then the (or) doesn't really help me, as the body of the if-let will still be evaluated |
| 17:04 | slyphon | it's more (or (if-let [...) alternative) |
| 17:05 | kotarak | slyphon: ??? I don't get what you want to do. (or (if-let ...) alternative) is equivalent to (if-let [..] (bla) alternative) |
| 17:06 | kotarak | slyphon: more or less |
| 17:06 | slyphon | maybe i don't understand if-let |
| 17:07 | slyphon | the first binding *is* the test, no? |
| 17:07 | slyphon | oh, hrm |
| 17:08 | kotarak | slyphon: (if-let [local (test)] (logical-true-branch might use local) (logical-false-branch)) |
| 17:08 | slyphon | kotarak: ok, i didn't know there were two forms |
| 17:08 | slyphon | like with 'if' |
| 17:08 | kotarak | slyphon: well, it's called if |
| 17:08 | slyphon | hah |
| 17:08 | slyphon | true |
| 17:08 | kotarak | slyphon: there is also when-let |
| 17:08 | Borkdude | ,(doc if-let) |
| 17:08 | clojurebot | "([bindings then] [bindings then else & oldform]); bindings => binding-form test If test is true, evaluates then with binding-form bound to the value of test, if not, yields else" |
| 17:08 | Borkdude | might want to read that ;) |
| 17:08 | kotarak | slyphon: which is called when |
| 17:09 | slyphon | i need toi-let |
| 17:09 | slyphon_away | ;) |
| 17:12 | bitti | hm |
| 17:12 | bitti | (defn hash-map |
| 17:12 | bitti | "keyval => key val |
| 17:12 | bitti | Returns a new hash map with supplied mappings." |
| 17:12 | bitti | ([] {}) |
| 17:13 | bitti | ([& keyvals] |
| 17:13 | bitti | (. clojure.lang.PersistentHashMap (create keyvals)))) |
| 17:13 | bitti | |
| 17:13 | bitti | (defn hash-set |
| 17:13 | bitti | "Returns a new hash set with supplied keys." |
| 17:13 | bitti | ([] #{}) |
| 17:13 | bitti | ([& keys] |
| 17:13 | bitti | (clojure.lang.PersistentHashSet/create keys))) |
| 17:13 | bitti | why sometimes the . syntax and then the / syntax for static method calls are employed? |
| 17:13 | bitti | just a inconsistence? |
| 17:14 | kotarak | bitti: old code is not changed. only in case of a patch. new code uses / syntax |
| 17:14 | _ato | / is newer and didn't used to exist |
| 17:14 | bitti | ic |
| 17:15 | bitti | but a patch has to be a fix? there are no consistency patches? |
| 17:16 | kotarak | bitti: yes. only fixes. consistency patches don't help anything, just bear the risk of introducing new bugs. |
| 17:17 | The-Kenny | Isn't / just for static methods and . for "methods"? |
| 17:18 | bitti | kotarak: yeah, that's why many projects never get refactored... |
| 17:18 | kotarak | bitti: consistency != refactoring |
| 17:18 | kotarak | The-Kenny: (. SomeClass (staticMethod)) is the ancient way |
| 17:19 | The-Kenny | kotarak: Oh ok |
| 17:19 | Borkdude | The-Kenny, in the first example create is also a static method |
| 17:21 | bitti | kotarak: yeah it isn't refactoring, it's a kind of refactoring. |
| 17:21 | bitti | even a simple thing like rename is a kind of refactoring |
| 17:26 | lancepantz | is it possible to destructure mutlidimensional data structures? |
| 17:26 | lancepantz | like {:foo {:bar "a" :baz "b"}}, can i bind to baz? |
| 17:27 | kotarak | ,(let [[[a b] c] [[1 2] 3]] (vector a b c)) |
| 17:27 | clojurebot | [1 2 3] |
| 17:28 | lancepantz | what about with maps? |
| 17:28 | kotarak | hmm let's see |
| 17:29 | kotarak | ,(let [{:a {:b b :c c} :d d} {:a {:b 1 :c 2} :d 3}] (vector b c d)) |
| 17:29 | clojurebot | java.lang.Exception: Unsupported binding form: :a |
| 17:31 | kotarak | ,(let [{{b :b c :c} :a d :d} {:a {:b 1 2} :d 3}] (vector b c d)) |
| 17:31 | clojurebot | 3 |
| 17:31 | kotarak | 3? |
| 17:31 | lancepantz | hahaha |
| 17:31 | lancepantz | that's what i said |
| 17:31 | drewr | I thought this was supposed to be working now http://gist.github.com/359487 |
| 17:31 | hiredman | ,(let [{{baz :baz} :foo} {:foo {:bar "a" :baz "b"}}] baz) |
| 17:31 | clojurebot | "b" |
| 17:32 | lancepantz | there we go |
| 17:32 | lancepantz | thanks hiredman |
| 17:32 | kotarak | ,(let [{{b :b c :c} :a d :d} {:a {:b 1 :c 2} :d 3}] (vector b c d)) |
| 17:32 | clojurebot | [1 2 3] |
| 17:32 | kotarak | Stupid cut'n'paste bug. |
| 17:32 | lancepantz | that helps, thanks guys |
| 17:33 | lancepantz | i think we're kinda thin on destructuring documentation |
| 17:33 | kotarak | lancepantz: well the recursive thing is described on clojure.org/special_forms |
| 17:34 | Borkdude | it would be useful if the api had examples |
| 17:34 | bitti | surely lot's of irc/erc users here. no? |
| 17:34 | bitti | who do you avoid smiley parsing in s-expr? |
| 17:35 | bitti | s/who/how/ |
| 17:35 | licoresse | in colloquy? |
| 17:36 | Borkdude | smiley parsing? the repl isn't an instant messaging program? ;) |
| 17:37 | bitti | Borkdude: sure, but this channel has a lot of s-expr |
| 17:37 | Borkdude | bitti: clojurebot is activated by a preceding comma |
| 17:37 | licoresse | bitti: check with your client |
| 17:37 | Borkdude | ah you mean that |
| 17:37 | Borkdude | gtg |
| 17:38 | bitti | seems he didn't know a solution... |
| 17:38 | _ato | bitti: simply don't enable the erc smiley module? |
| 17:38 | _ato | it's off by default isn't it? |
| 17:38 | licoresse | so bitti is using erc |
| 17:39 | bitti | I just try. I used to use irc, was enough for me |
| 17:44 | carkh | bitti: emacs currently comes with rcirc, very easy to use |
| 17:47 | bitti | carkh: yeah, that's what i meant, irc is just an alias for rcirc in emacs |
| 17:48 | bitti | carkh: but no matter how easy it is, I need my smileys, but not in s-expr |
| 17:48 | carkh | the smiley thing doesn't come preconfigure, you probably added a script to your .emacs |
| 17:48 | carkh | ohhh i see |
| 17:49 | carkh | well you need to check your added script and modify it =P |
| 17:50 | carkh | tho smiling sexps must be sexxy =) |
| 17:50 | bitti | ok, I may try to adopt all the smiley regexps :/ |
| 17:51 | carkh | clojurebot: clojure is also making your sexp smile |
| 17:51 | clojurebot | You don't have to tell me twice. |
| 17:57 | brian__ | noob question> I want to send a number value in a multimethod, something like (defmethod count-cat [:toys :set] [category action value] (prn value)) |
| 17:58 | brian__ | then (count-cat {:category :toys} {:action :set} 10) , but doesnt work |
| 17:59 | carkh | what's your defmulti looking like ? |
| 18:00 | brian__ | (defmulti count-cat (fn [c a v] [(:category c)(:action a)(v)])) |
| 18:01 | carkh | remove the (v) from the body |
| 18:01 | brian__ | ok |
| 18:02 | brian__ | whats the body? |
| 18:02 | carkh | make it look like that : (defmulti count-cat (fn [c a v] [(:category c)(:action a)])) |
| 18:03 | brian__ | ok, thnks |
| 18:03 | carkh | don't forget to recompile the defmethod after this |
| 18:03 | brian__ | ok |
| 18:04 | dakrone | alright, need some parsing advice |
| 18:04 | dakrone | what would be the best way to accomplish this transformation: http://pastebin.com/f5gX4TbZ |
| 18:04 | dakrone | keeping a stack seems like a reasonable way, but not easy to do in Clojure |
| 18:06 | tomoj | how would you generate matrices like [[1 2 3] [8 9 4] [7 6 5]] (i.e. (iterate inc 1) spiraling around the matrix) in clojure? |
| 18:06 | carkh | dakrone: can't you just use the normal call stack you get when calling functions ? |
| 18:06 | licoresse | partition? |
| 18:06 | tomoj | I can think of one way by threading a set through, but that seems too much like the imperative version to me :( |
| 18:07 | dakrone | carkh: what do you mean? |
| 18:08 | carkh | dakrone: just recursively call the same transforming function |
| 18:08 | carkh | when it's comes back from the recursive call, that's like a pop |
| 18:08 | dakrone | I'm just not really sure how to keep that all in a struct sort of structure |
| 18:09 | carkh | if the goal is only to make the transformation you're showing there, that's a very easy function to write |
| 18:09 | dakrone | tomoj: (map #(into [] %) (partition 3 (take 9 (iterate inc 1)))) |
| 18:09 | dakrone | ,(map #(into [] %) (partition 3 (take 9 (iterate inc 1)))) |
| 18:09 | clojurebot | ([1 2 3] [4 5 6] [7 8 9]) |
| 18:10 | tomoj | dyslexic? :P |
| 18:10 | dakrone | tomoj: ah yea, a bit :P |
| 18:10 | Chousuke | dakrone: map vec instead :P |
| 18:11 | tomoj | like this https://gist.github.com/c0657ce9ce2850c9bb25 |
| 18:13 | dakrone | ahh yea, that's much more difficult |
| 18:14 | Raynes | Anyone have the link to that Clojure for Lisp programmers transcript handy? |
| 18:17 | carkh | dakrone: : check this http://pastebin.com/HPsRy8yu |
| 18:18 | carkh | not exactly what you asked, but pretty close |
| 18:20 | dakrone | carkh: that's really cool, never used ` and ~ outside of a macro |
| 18:20 | carkh | ah my bad, makes it harder to understand =/ |
| 18:21 | dakrone | it's not bad, it just never occurred to me to use them outside of a macro |
| 18:22 | carkh | i think you should use maps : instead of (:tag symbol :chunk ...) have {:tag symbol :chunk ..} |
| 18:23 | carkh | that's more clojuresque |
| 18:23 | carkh | also the chunk part should always be a sequence, not sometimes a sequence and other times the sub-chunk itself |
| 18:25 | dakrone | having a hard time trying to figure out how to get it run through the function, it comes out as a string "(TOP (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN sentence))) (. .)))" |
| 18:26 | dakrone | (eval (str "(tb '" str ")")) doesn't do the trick |
| 18:26 | carkh | ,(read-string "(TOP (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN sentence))) (. .)))") |
| 18:26 | clojurebot | (TOP (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN sentence))) (. .))) |
| 18:27 | carkh | you're using some natural language processing library ? |
| 18:27 | dakrone | yes |
| 18:27 | dakrone | opennlp |
| 18:27 | carkh | nice =) |
| 18:27 | dakrone | unfortunately they keep all the actual tree structure for this private, so instead I'm trying to parse the string output |
| 18:28 | dakrone | ahh, there we go, (tr (read-string (.toString sb))) did the trick |
| 18:28 | carkh | nice =) |
| 18:28 | dakrone | that's awesome, thank you very much carkh :) |
| 18:28 | dakrone | I'll credit you in the source |
| 18:29 | carkh | hehe no need |
| 18:29 | dakrone | on the same note, there isn't an easy way to bypass the private var restriction for java classes in clojure, is there? |
| 18:30 | dakrone | that'd make this much better than attempting to parse a string |
| 18:30 | maxhodak | is it possible to access a password-protected maven repository using lein? |
| 18:30 | Chousuke | dakrone: make sure the string form of the structure always makes sense if parsed as a clojure structure. |
| 18:31 | dakrone | Chousuke: you mean, a valid s-exp? |
| 18:31 | Chousuke | dakrone: I guess so |
| 18:31 | Chousuke | dakrone: it does look like it's designed to be one |
| 18:31 | dakrone | yea, it does, but I'll write tests to make sure |
| 18:32 | maxhodak | technomancy|away: |
| 18:32 | Chousuke | things like apostrophes or double quotes could result in something unexpected |
| 18:32 | dakrone | hmm.. good point, that would throw things off |
| 18:32 | Chousuke | or the # character :P |
| 18:34 | carkh | ah true, you might want to use a real parser |
| 18:35 | carkh | like fnparse from joshua choi |
| 18:36 | Chousuke | in common lisp you'd probably customise the reader to treat ' as a symbol character and have it produce |it's| or something for things with apostrophes but Clojure unfortunately is not so flexible :P |
| 18:37 | carkh | well the parsed languae looks quite regular so it should be easy to parse |
| 18:37 | carkh | or you could search and replace special cases beforehand |
| 18:37 | Chousuke | though I'm sure no-one would mind an extensible reader, as long as it's done sanely. |
| 18:38 | carkh | Chousuke: you think CL's reader is not sane ? |
| 18:38 | Chousuke | carkh: well, reader macros don't compose very well |
| 18:39 | carkh | how would you do it so they're composable ? looks like a difficult task |
| 18:39 | Chousuke | indeed. |
| 18:39 | carkh | i used reader macros maybe twice |
| 18:40 | Chousuke | I kind of like the scheme approach to reader macros; at least as far as I understand it |
| 18:40 | carkh | ah i never played with any scheme |
| 18:40 | carkh | besides this one >< |
| 18:40 | Chousuke | At least PLT scheme has a #lang pragma that lets you change the language on the fly |
| 18:41 | Chousuke | between, say, various standard revisions or typed scheme for example |
| 18:41 | Chousuke | It's probably not ideal, or even a complete solution, but something similar could work |
| 18:42 | carkh | i guess reader macros would be saner with a lexical scope |
| 18:42 | Chousuke | perhaps |
| 18:43 | carkh | that would reove a whole bunch of composability issues |
| 18:43 | carkh | remove* |
| 18:44 | Chousuke | however, the bigger issue probably is that you could end up with everyone creating all kinds of weird mini languages bearing little resemblance to plain Clojure |
| 18:44 | carkh | ah true, i hated cl-sql for that |
| 18:45 | carkh | not quite sure on the name of that library anymore =/ |
| 18:45 | dakrone | how badly-frowned-upon would be doing something like this: http://tutorials.jenkov.com/java-reflection/private-fields-and-methods.html ? |
| 18:46 | Chousuke | though I would err on the side of optimism in this case. ;P The Clojure community tends to listen to Rich and if he says people shouldn't go crazy with reader mods (assuming they become possible someday in the first place) then I think most people would listen |
| 18:48 | carkh | dakrone: in the long run i think you're better off doing the work to do thing the good way |
| 18:49 | dakrone | okay, I'll do it that way, I'll check out fnparse too |
| 18:49 | carkh | there might also be some other library that does parsing for you presenting a "DOM" of some kind |
| 18:49 | tomoj | Chousuke: weird mini-languages is an issue? :P |
| 18:50 | carkh | haha who doesn't love CL's loop macro ? |
| 18:50 | Chousuke | tomoj: I think fear of fragmentation and lack of composability are the primary reasons why Clojure's reader is not extensible. |
| 18:50 | Chousuke | and that it's written in Java, but that's another thing entirely. :P |
| 18:51 | dnolen | anyone know how to constrain the amount of RAM swank-clojure-project starts the REPL with? |
| 18:51 | Chousuke | there was some parameter to specify jvm args |
| 18:51 | The-Kenny | dnolen: There's some variable "swank-clojure-extra-jvm-args" or so in swank-clojure.el |
| 18:52 | Chousuke | pass -Xmx64m or something to the jvm |
| 18:52 | dnolen | The-Kenny: yeah I've set that doesn't seem to do any good. |
| 18:52 | Chousuke | mx is max heap and ms is minimum heap (initial allocation) I think |
| 18:53 | carkh | i found it pretty hard to change the startup of swank-clojure, eventually i set it to run a batch file, and create it on the fly before starting slime |
| 18:53 | The-Kenny | dnolen: After taking a look, setting "swank-clojure-extra-vm-args" to some list should work. It's used in swank-clojure-project |
| 18:53 | dnolen | lein swank works fine, the proper JVM settings. it's just swank-clojure-project that's giving me a headache. |
| 18:54 | Chousuke | swank-clojure-project might be overriding your settings ;P |
| 19:07 | tomoj | ,(class (rationalize 1)) |
| 19:07 | clojurebot | java.lang.Integer |
| 19:18 | tomoj | ,(letfn [(ratio [x y] (clojure.lang.Ratio. (bigint x) (bigint y)))] (= (ratio 0 1) (ratio 0 2))) |
| 19:18 | clojurebot | false |
| 19:18 | tomoj | :D |
| 19:19 | tomoj | hmm, that is strange |
| 19:21 | tomoj | the identity on clojure.lang.Ratio under addition is not unique... |
| 19:22 | _ato | ,(= 0/1 0/2) |
| 19:22 | clojurebot | true |
| 19:22 | _ato | ,(class 0/1) |
| 19:22 | clojurebot | java.lang.Integer |
| 19:22 | _ato | ah |
| 19:23 | _ato | ,(= 1/3 9/3) |
| 19:23 | clojurebot | false |
| 19:23 | _ato | ,(= 1/3 3/9) |
| 19:23 | clojurebot | true |
| 19:23 | tomoj | _ato: those Ratios aren't accessible with / or with the x/y syntax, it seems |
| 19:23 | tomoj | just an oddity of the java class |
| 19:24 | _ato | ah |
| 19:24 | _ato | yeah |
| 19:24 | _ato | the constructor just sets the numerator and denominator, it doesn't do any normalisation |
| 19:24 | tomoj | challenge: create a lazy seq of all rational numbers in as few lines as possible |
| 19:24 | tomoj | this is what I decided to do instead of real work |
| 19:24 | tomoj | but I could only get it with 34 ugly lines |
| 19:24 | tomoj | https://gist.github.com/f26c30ababa4437404ab |
| 19:25 | tomoj | (I left out 0) |
| 19:25 | tomoj | (and the negatives...) |
| 19:25 | _ato | ,(bigint (/ 1000000000000000000000000000 3)) |
| 19:25 | clojurebot | java.lang.ExceptionInInitializerError |
| 19:45 | slyphon | argh |
| 19:46 | slyphon | can you publish multiple jars as part of a single pom.xml |
| 19:46 | slyphon | ? |
| 19:46 | technomancy | slyphon: I think there's a plugin to do that |
| 19:46 | slyphon | yeah? |
| 19:46 | technomancy | the dog poop mailing, I mean |
| 19:46 | slyphon | hahahahaha |
| 19:46 | slyphon | wow, leiningen is the answer to *everything*! |
| 19:47 | slyphon | i'm trying to package up the redstone-xmlrpc lib, and i'm finding myself full of hate |
| 19:49 | carkh | technomancy: may i take a minute of your time ? |
| 19:50 | Licenser | _ato: clojurebot does not like big nubers |
| 19:57 | technomancy | carkh: sure; for something quick |
| 19:58 | carkh | ok quickly then : i think you'e maintaining clojure-mode right now, is that correct ? |
| 19:59 | carkh | i've been adding a hook to my .emcs to delete trailing white spaces from my saved files |
| 19:59 | carkh | and it looks like this removes commas from clojure files when saving |
| 19:59 | technomancy | yeah, that's a bug; not sure how to get it to preserve commas inside strings and comments |
| 19:59 | carkh | my guess is that clojure-mode somehow tells emacs that commas are white space as they are for clojure |
| 19:59 | technomancy | deleting trailing whitespace in a hook is pretty dangerous though |
| 20:00 | technomancy | well dangerous is a strong word |
| 20:00 | technomancy | but having changes applied to a file without your active involvement is iffy |
| 20:00 | slyphon | yeah |
| 20:00 | slyphon | "WTF happened?!" |
| 20:01 | carkh | well i just wanted to make you aware of that, looks like you already know about it |
| 20:03 | technomancy | yeah, thanks |
| 21:30 | defn | Hey all |
| 21:30 | doseq | Hey. |
| 21:30 | defn | I have some thoughts on how I might achieve this but I thought I'd ask people smarter than me first: |
| 21:31 | defn | Given: (some really long sexp (with nested (forms))) |
| 21:31 | defn | How would you go about intelligently indenting that |
| 21:31 | defn | programatically, I mean |
| 21:32 | defn | regex? a parser? is there some easy logic I'm missing? |
| 21:34 | carkh | by using clojure.contrib.pprint maybe ? |
| 21:34 | defn | carkh: huh, didn't even consider that |
| 21:34 | defn | that will print long sexps nicely? |
| 21:34 | carkh | it never is as nice as hand-crafted, but it does the job, yes |
| 21:35 | defn | carkh: im very grateful for the suggestion -- this looks like a "good enough" way to go for the time being |
| 21:35 | defn | thank you |
| 21:35 | carkh | =) |
| 21:45 | Licenser | hi defn how is walton going? |
| 21:45 | defn | carkh: were you thinking pprint-simple-code-list? |
| 21:46 | defn | carkh: was wondering if you had a pprint/* fn in mind |
| 21:47 | Raynes | Licenser: I added some new functions last night. Got A through C from the Clojure API. I'm getting there, slowly but surely. :p |
| 21:47 | Licenser | hi raek :) |
| 21:47 | Licenser | erm Raynes narf, silly tab compleatiion. And yes i saw it, great work! |
| 21:47 | carkh | ,(clojure.contrib.pprint/pprint '(:a "blahblah")) |
| 21:47 | clojurebot | (:a "blahblah") |
| 21:48 | Raynes | Hehe. |
| 21:53 | tomoj | Raynes: what adding do you have to do? |
| 21:53 | tomoj | I thought it was supposed to be automatic |
| 21:54 | Raynes | tomoj: clj-sandbox, not walton |
| 21:54 | Licenser | point of clj-snadbox is not being automatic ;) |
| 21:54 | tomoj | oh, I misread something someone said |
| 21:54 | tomoj | have to go through and whitelist them? |
| 21:54 | Raynes | Indeed. |
| 21:55 | Raynes | My goal is to go through the entire clojure core API. |
| 21:55 | Raynes | Not that difficult. |
| 21:55 | Raynes | Just lazy. :p |
| 21:55 | tomoj | sounds like a lot of work to me |
| 21:55 | tomoj | would be cool if they were grouped |
| 21:56 | tomoj | I mean presumably the whitelist will be configurable, right? |
| 21:56 | tomoj | so you could group them into related sets and enable/disable certain chunks of clojure |
| 21:56 | _ato | tomoj: http://github.com/Licenser/clj-sandbox/blob/master/src/net/licenser/sandbox/safe_fns.clj |
| 21:57 | tomoj | awesome |
| 21:58 | Licenser | *snickers* |
| 21:58 | slyphon | hrm, is there some debugging hook on the server side for swank? evaluating a function consistently just aborts, but there's no error in the logs or on stdout or anything |
| 21:59 | defn | (inc Licenser) |
| 21:59 | Licenses | great now I've a silly name |
| 21:59 | slyphon | hah! |
| 22:00 | slyphon | Licenses: cleva! |
| 22:00 | Licenses | I'm just glad that he didn't do something lie (sqrt defn) |
| 22:00 | slyphon | hahaha |
| 22:00 | Licenses | thatd'b e a pain! |
| 22:00 | slyphon | srsly |
| 22:00 | slyphon | first you'd have to figure out what Locale he was in |
| 22:01 | Licenses | nah I go with ASCII |
| 22:01 | slyphon | :) |
| 22:01 | Licenses | so for defn it'd not eben be that hard I'ts only 4 byte |
| 22:02 | Licenses | on the other hand it is more a logical problem then a mathematical one |
| 22:02 | Licenses | since I would expect to work over the letters a-z and A-Z not over their number representations in the charset |
| 22:02 | slyphon | sure, just make it complicated |
| 22:02 | Licenses | nah it's not so complicated it is as complicated as binary |
| 22:03 | Licenses | just a different base |
| 22:03 | defn | cleva? |
| 22:03 | slyphon | "clever" |
| 22:03 | slyphon | but with a colloquial twang |
| 22:03 | defn | ah |
| 22:03 | defn | sorry im lagging a bit |
| 22:03 | slyphon | heh |
| 22:05 | Licenses | hmm so base 51 |
| 22:06 | defn | the best base I think |
| 22:06 | defn | better than 47, anyway |
| 22:06 | carkh | the most natural for licenser incrementation |
| 22:06 | defn | incrimination or incrementation? |
| 22:07 | carkh | for basic incrimination we can go with all good base 47 |
| 22:07 | carkh | we might get more digits that way =P |
| 22:08 | Raynes | Is there a function just for discarding output? Like, a function that takes anything and returns nil? |
| 22:09 | hiredman | ,((constantly nil) 1 2 3 4) |
| 22:09 | clojurebot | nil |
| 22:09 | Raynes | Thank you. |
| 22:10 | tomoj | 51? |
| 22:10 | tomoj | your alphabet has 25.5 letters in it? |
| 22:11 | hiredman | j is barely even a letter |
| 22:11 | tomoj | oh, I see |
| 22:12 | tomoj | wait, nevermind, I don't see |
| 22:12 | hiredman | http://en.wikipedia.org/wiki/J a johnny come lately to the alphabet |
| 22:12 | tomoj | base n has n different symbols |
| 22:12 | tomoj | no? |
| 22:13 | _ato | ,(let [bb (java.nio.ByteBuffer/wrap (.getBytes "defn")), i (int (Math/sqrt (.getInt bb)))] (.clear bb)(.putInt bb i)(String. (.array bb) 2 2)) |
| 22:13 | clojurebot | "�Q" |
| 22:13 | defn | how to convert "(1 2 3)" to '(1 2 3)? |
| 22:13 | hiredman | … |
| 22:14 | defn | hiredman: silly questiopn? |
| 22:14 | _ato | ,(doc read-string) |
| 22:14 | clojurebot | "([s]); Reads one object from the string s" |
| 22:14 | defn | question* |
| 22:14 | hiredman | are you sure you want '(1 2 3)? |
| 22:14 | hiredman | _ato: well he would have to cons 'quote on afterwards |
| 22:14 | defn | (1 2 3), i suppose |
| 22:15 | defn | the ultimate destination would be the quoted form |
| 22:15 | defn | but the intermediary step i guess is what i was looking for |
| 22:15 | _ato | ,(= (read-string "(1 2 3)") '(1 2 3)) |
| 22:15 | clojurebot | true |
| 22:15 | hiredman | '(1 2 3) is an illusion |
| 22:15 | defn | _ato: thanks much |
| 22:15 | hiredman | ,(macroexpand ''(1 2 3)) |
| 22:15 | clojurebot | (quote (1 2 3)) |
| 22:15 | _ato | ,(read-string "'(1 2 3)") |
| 22:15 | clojurebot | (quote (1 2 3)) |
| 22:15 | hiredman | well |
| 22:15 | hiredman | ,''(1 2 3) |
| 22:15 | clojurebot | (quote (1 2 3)) |
| 22:25 | dcnstrct | I can't figure it out... last night swank-clojure-project was respecting my (.getResourceAsStream (clojure.lang.RT/baseLoader) "src/myproj/whatever.js") |
| 22:25 | dcnstrct | but tonight it stopped working |
| 22:25 | dcnstrct | and no code has changed I simply restarte emacs |
| 22:26 | dcnstrct | ,(.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/xml.clj") |
| 22:29 | _ato | dcnstrct: the path shouldn't start with src/ unless you have this file under myproj/src/src/myproj/whatever |
| 22:30 | dcnstrct | wow that was it |
| 22:30 | dcnstrct | maybe last night I started swank-clojure-project in the wrong directory or something |
| 22:30 | dcnstrct | who knows... but that works.. thanks |
| 22:30 | tomoj | I think you can put them in resources/ too? |
| 22:30 | dcnstrct | thats probably a much better idea actually.. keep it tidy |
| 22:31 | tomoj | I still don't really understand how to stick stuff in there and give http access to it without security problems |
| 22:33 | dcnstrct | (GET "/loading.gif" (.getResourceAsStream (clojure.lang.RT/baseLoader) "src/bots/pva/loading.gif")) |
| 22:33 | dcnstrct | I don't care if hackers steal my loading indicator gif |
| 22:35 | hiredman | clojurebot: ping? |
| 22:36 | hiredman | :( |
| 22:36 | hiredman | clojurebot: ping? |
| 22:36 | clojurebot | PONG! |
| 22:37 | dcnstrct | I wonder if I broke him with that command earlier |
| 22:37 | dcnstrct | ,(.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/xml.clj") |
| 22:37 | clojurebot | nil |
| 22:40 | hiredman | I was monkeying with internals |
| 22:45 | ct__ | Jennifer Aniston likes Clojure: http://java.ociweb.com/mark/clojure/ (Sound Clip #1 at the bottom) |
| 23:04 | defn | heh |
| 23:04 | defn | the inspiration for me buying getclojure.org/com |
| 23:04 | defn | getclojure.org:8080/examples/function |
| 23:14 | dgreensp | can I type-hint the return value of a defmethod? |
| 23:16 | dgreensp | type-hinting the name of a defn works, right? what's the mechanism behind that? |
| 23:16 | dgreensp | and yes, I do need the speed :P |
| 23:17 | Apage43 | no reason why it wouldn't work, i think. |
| 23:25 | dgreensp | oh, except having different type hints for different defmethods in the multimethod isn't really helpful at compile-time... |
| 23:29 | trptcolin | defn: that's pretty sweet |
| 23:33 | _ato | dysinger: look at the :prompt option of clojure.main/repl |
| 23:34 | _ato | or in fact :need-prompt |
| 23:37 | dysinger | _ato: thanks |
| 23:59 | slyphon | i'm confused about the "implicit this" |
| 23:59 | slyphon | in proxy methods |