2010-05-21
| 00:01 | Licenser | nice :) now the ident token is faster then the space token |
| 00:05 | Licenser | well thank you all for the help so now I got to go to bed |
| 00:15 | mmarczyk | Licenser: see you next time :-) |
| 00:15 | mmarczyk | (even though it's a bit of a pleonasm ;-)) |
| 00:33 | mmarczyk | Licenser: got a non-regex solution for (re-find basic-identifier-re some-string) which appears to be twice as fast in some cases, need to squeeze it a bit more :-) |
| 00:34 | mmarczyk | (well actually it is partly regex based at this proof-of-concept stage, but it won't stay this way long) |
| 00:47 | tomoj | b |
| 00:47 | tomoj | oops |
| 01:21 | mmarczyk | got it down to up to 16x faster, but I am in fact still using regexes... oh well. |
| 01:22 | remleduff | Darn ;) |
| 01:26 | mmarczyk | actually, I found a bug |
| 01:26 | mmarczyk | so it's not going to be quite that nice :-( |
| 01:47 | Blackfoot | can i use :as in (import)? I want to refer to SomeCrazy$InnerClass as just Inner |
| 01:59 | mmarczyk | Blackfoot: nope :-( |
| 01:59 | mmarczyk | is this for the purpose of calling static methods? |
| 02:00 | mmarczyk | or for construction etc. too? |
| 02:00 | Blackfoot | mostly a static method and it's enums |
| 02:01 | mmarczyk | in this case I think I'll plug an answer I posted on SO |
| 02:01 | mmarczyk | maybe it'll be useful to you |
| 02:01 | mmarczyk | and I'd love to hear some feedback ("it's insane" etc.) |
| 02:01 | Blackfoot | ha, sure |
| 02:02 | mmarczyk | http://stackoverflow.com/questions/2852133/clojure-vars-and-java-static-methods |
| 02:02 | sexpbot | "Clojure vars and Java static methods - Stack Overflow" |
| 02:02 | mmarczyk | it's the accepted answer |
| 02:03 | mmarczyk | actually it has occurred to me that creating the "gensymed" ns is probably pointless as written there |
| 02:03 | mmarczyk | I meant to use a dot in the ns name |
| 02:04 | mmarczyk | (should be "adapter.") |
| 02:07 | Blackfoot | mmarczyk: i think i understand it, thought not sure how it would work with the enums. since i'm only using it in a few places, i'll probably use the whole name for now, but try it out if usage grows |
| 02:07 | Blackfoot | thanks |
| 02:07 | mmarczyk | sure |
| 03:07 | bartj | hi |
| 03:08 | bartj | can anyone please tell me the difference between doseq and for in clojure? |
| 03:09 | bartj | er is anyone there? |
| 03:10 | bartj | hello? |
| 03:10 | clojurebot | BUENOS DING DONG DIDDLY DIOS, fRaUline bartj |
| 03:11 | technomancy | bartj: for is lazy, doseq is used for side effects |
| 03:17 | bartj | (defn t[i] (for [j i] (println j) (inc i))) - how is this wrong? |
| 03:17 | bartj | (defn t [i] (for [j i] (println j))) |
| 03:18 | technomancy | bartj: "i" would need to be a seq or "for" can't work on it |
| 03:18 | technomancy | and you can't inc a seq |
| 03:18 | technomancy | ,((fn [i] (for [j i] (println j) (inc j))) [1 2 3]) |
| 03:18 | clojurebot | java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: core$for |
| 03:18 | technomancy | ,((fn [i] (for [j i] (do (println j) (inc j)))) [1 2 3]) |
| 03:18 | clojurebot | (2 3 4) |
| 03:19 | technomancy | ,(map inc [1 2 3]) ; <= essentially the same thing |
| 03:19 | clojurebot | (2 3 4) |
| 03:22 | danlarkin | clojurebot: donkeyballs |
| 03:22 | clojurebot | Titim gan éirí ort. |
| 03:22 | bartj | well that actually returns: (1 \n 2 \n 2 3 \n3 4) |
| 03:22 | bartj | "\n" = equals |
| 03:22 | bartj | ,((fn [i] (for [j i] (do (inc j)))) [1 2 3]) |
| 03:22 | clojurebot | (2 3 4) |
| 03:23 | technomancy | bartj: I think the output getting interleaved with the return value is confusing you |
| 03:24 | bartj | technomancy: yes |
| 03:24 | bartj | technomancy: which is why I removed it :) |
| 03:24 | technomancy | you don't need the "do" if you're only performing one function call in the body of the "for" |
| 03:25 | bartj | technomancy: yes, thanks |
| 03:25 | bartj | is the usage of doseq instead of "for" purely idiomatic - to indicate that side-effects occur? |
| 03:27 | technomancy | bartj: it's more than just a style thing--doseq returns nil, while for returns a lazy sequence |
| 03:27 | technomancy | so side-effects simply don't happen with "for" until the return value gets forced |
| 03:29 | bartj | technomancy: thank you so much |
| 03:29 | technomancy | sure |
| 03:31 | bartj | technomancy: I was confused because the doc string for "for" does not mention anything about the return value. :) |
| 03:50 | vegai | hmm, isn't there a simple split function in core? |
| 03:50 | vegai | (split "a,b,c,d" ",") => [a b c d] sorta thing |
| 03:51 | bartj | vegai: you need to use ".split" |
| 03:51 | cgrand | ,(vec (.split "a,b,c,d" ",")) |
| 03:51 | clojurebot | ["a" "b" "c" "d"] |
| 03:52 | cgrand | ,(vec (.split #"," "a,b,c,d")) |
| 03:52 | clojurebot | ["a" "b" "c" "d"] |
| 03:52 | vegai | ah, through Java? |
| 03:52 | bartj | yeah - atleast that is what I know |
| 03:53 | vegai | thanks |
| 03:53 | vegai | I'm finally starting to regret that I ignored Java for so many years.. |
| 03:55 | vegai | another one: strip? |
| 03:55 | vegai | (strip " abc ") => "abc" |
| 03:55 | Chousuke | vegai: you only need to learn to read javadoc :( |
| 03:55 | Chousuke | :) even :P |
| 03:56 | vegai | yea.. |
| 03:56 | Chousuke | anyway, there's the .trim method |
| 03:56 | Chousuke | http://java.sun.com/javase/6/docs/api/java/lang/String.html |
| 03:56 | sexpbot | "String (Java Platform SE 6)" |
| 03:56 | Chousuke | Those are good to know |
| 03:56 | vegai | ah, great. I'll read that |
| 03:57 | technomancy | slime inspector will show you the methods at least: C-c S-i |
| 03:58 | Chousuke | technomancy: is that a pun of CSI by accident or intentionally? :P |
| 03:58 | technomancy | CSI? |
| 03:58 | technomancy | oh, the television show? |
| 03:58 | technomancy | heh |
| 03:58 | technomancy | probably coincidence; I think slime is pretty old |
| 03:59 | eevar2 | i for inspect, not investigate ;) |
| 03:59 | eevar2 | or whatever the csi folks do |
| 04:00 | Chousuke | Slime isn't as powerful as the CSI guys' computer systems though. |
| 04:00 | Chousuke | I think they zoomed in behind a corner in one episode |
| 04:00 | technomancy | yeah, it needs to get ported to visual basic |
| 04:01 | technomancy | so it can be used to create a GUI to track IP addresses |
| 04:01 | eevar2 | lolpics.se has a few nice csi pictures |
| 04:01 | eevar2 | among a lot of nsfw stuff ;) |
| 04:03 | rava | There's gotta be a cleaner/more idiomatic way of doing this: http://gist.github.com/408610 |
| 04:03 | rava | Any thoughts? |
| 04:03 | eevar2 | http://www.m5board.com/vbulletin/off-topic-forum/151964-csi-lol-pics.html |
| 04:03 | sexpbot | "CSI lol pics.. - The Unofficial BMW M5 Messageboard (m5board.com)" |
| 04:04 | Chousuke | rava: not using a struct map would be more idiomatic, unless you really need one :) |
| 04:05 | Chousuke | rava: also, calling vec on the file list is unnecessary. |
| 04:06 | Chousuke | rava: other than that, I think the code |
| 04:06 | Chousuke | is perfectly idiomatic |
| 04:06 | defn | ^what he said. |
| 04:06 | defn | just use a plain vector of maps, no need for the struct-map, unless of course there is ;) |
| 04:06 | rava | more like habbit :) |
| 04:07 | rava | i'm used to having to declare some kind of data type |
| 04:07 | Chousuke | heh |
| 04:08 | Chousuke | in Clojure, data types declare themselves ;P |
| 04:08 | rava | still getting used to that :) |
| 04:08 | rava | hrm, what's the syntax for this: (map #{:fname (.getName %)} (.listFiles (File. *enc-files-dir*))) |
| 04:09 | defn | oops |
| 04:09 | bartj | , (doc file-map) |
| 04:09 | clojurebot | excusez-moi |
| 04:09 | defn | you don't want #{} |
| 04:09 | defn | you want #() |
| 04:09 | rdsr | Also would file-seq on path would be better that (.listFiles ...) ??? |
| 04:09 | rava | i'm all sorts of hazy on using the % for args |
| 04:09 | defn | rdsr: file-seq will recurse subdirectories IIRC |
| 04:09 | Chousuke | #{} is set syntax |
| 04:09 | rava | erk |
| 04:10 | Chousuke | #() is for function shortcuts :) |
| 04:10 | rava | lol yes indeed it is../doh |
| 04:10 | rdsr | yes |
| 04:20 | mmarczyk | you don't need the vec around .fileList |
| 04:21 | mmarczyk | oh, Chousuke mentioned that already... noticed the moment I hit ret :-/ |
| 04:27 | rava | Anyone have trouble compiling a clj file in emacs with slime-compile-file? |
| 04:30 | defn | not I |
| 04:30 | defn | if that's C-k |
| 04:30 | defn | I never use the M-x slime-compile-file |
| 04:31 | mmarczyk | an alternate version: http://gist.github.com/408622 |
| 04:31 | defn | rava: im still working on your code |
| 04:32 | defn | mmarczyk: i like the destructuring inside the fn inside the fn |
| 04:32 | defn | ;) |
| 04:32 | mmarczyk | :-) |
| 04:32 | defn | i was using a ref in my version |
| 04:32 | defn | not as nice as yours :\ |
| 04:33 | defn | mmarczyk: the file-info-extractors thing is beautiful too |
| 04:33 | defn | really nice |
| 04:33 | rava | indeed |
| 04:35 | mmarczyk | :-) |
| 04:35 | defn | mmarczyk: im trying to improve on that, but it's just too good |
| 04:35 | defn | damn you, damn you to hell! |
| 04:35 | defn | rava: do you see how it all works |
| 04:36 | mmarczyk | :-D |
| 04:36 | rava | defn: file-info-extractors is fairly straight forward |
| 04:36 | mmarczyk | I had a version based on comp, partial, zipmap & juxt, but I thought it was ridiculous |
| 04:37 | mmarczyk | it's actually shorter, though |
| 04:37 | rava | defn: i THINK i've eval'ed the map reduce call, its a bit of black magic for my newbness |
| 04:37 | mmarczyk | updated the gist to include it, for weirdness' sake |
| 04:38 | defn | rava: do you understand the destructuring |
| 04:39 | vegai | mm, split works weirdly |
| 04:39 | mmarczyk | plus you could put type hints on % -- #^java.io.File % -- to avoid reflection... |
| 04:39 | vegai | ,(vec (.split #"," "aoe, aoecrh,aho,a")) |
| 04:39 | clojurebot | ["aoe" " aoecrh" "aho" "a"] |
| 04:39 | vegai | oh? |
| 04:39 | rava | yar the type hints are a nice touch |
| 04:39 | vegai | ,(vec (.split #"|" "aoe| aoecrh|aho|a")) |
| 04:39 | clojurebot | ["" "a" "o" "e" "|" " " "a" "o" "e" "c" "r" "h" "|" "a" "h" "o" "|" "a"] |
| 04:39 | vegai | aha! |
| 04:40 | vegai | ,(vec (.split #"\|" "aoe| aoecrh|aho|a")) |
| 04:40 | clojurebot | ["aoe" " aoecrh" "aho" "a"] |
| 04:40 | vegai | ah, I see :) |
| 04:40 | mmarczyk | ohhh, so I have hinted % in the gist :-) |
| 04:40 | mmarczyk | thought I haven't |
| 04:40 | defn | it makes it a bit less concise |
| 04:41 | mmarczyk | true |
| 04:41 | defn | but it's good auto-documentation :) |
| 04:41 | rava | lol, that last one is fairly nuts |
| 04:43 | defn | a nice lesson though |
| 04:43 | rava | indeed |
| 04:43 | defn | the partial zipmap [:foo :bar] is really concise |
| 04:43 | rava | the partial zipmap into the rest of the function calls is so very slick |
| 04:44 | defn | ;) |
| 04:46 | mmarczyk | that's the one thing I *really* miss from Haskell |
| 04:46 | mmarczyk | all functions taking one argument |
| 04:46 | mmarczyk | of course as soon as I'm actually writing Haskell |
| 04:46 | mmarczyk | I hate the fact that it's not a Lisp :-P |
| 04:48 | defn | i cant write code in other languages anymore |
| 04:48 | defn | i start every single bit of code with ( |
| 04:48 | defn | especially in ruby: |
| 04:49 | mmarczyk | yeah :-) |
| 04:49 | defn | (class Foo (def initialize (puts "omg"))) |
| 04:49 | mmarczyk | I don't recall ever typing an infix expression in a Lisp |
| 04:49 | mmarczyk | except maybe when mixing up repls with small prompts |
| 04:49 | defn | the incanter guys made it possible to do infix |
| 04:50 | mmarczyk | but I actually try to write prefix in other languages occasionally |
| 04:50 | defn | mmarczyk: how do you do prefix in other languages |
| 04:50 | defn | like ruby...how would you do that? |
| 04:50 | mmarczyk | oh, you just do it |
| 04:50 | mmarczyk | then the compiler complains ;-) |
| 04:50 | defn | ohhh, heh |
| 04:51 | mmarczyk | Haskell is seriously cool in many ways, though |
| 04:51 | mmarczyk | so I get over the syntax eventually, if I give it some time |
| 04:51 | mmarczyk | the effect seems regrettably to wear off between sittings ;-) |
| 04:51 | defn | i use xmonad -- i will go in and tinker with my config file -- i find some of the syntax awfully ugly, and the monadic stuff is a headache |
| 04:52 | mmarczyk | XMonad! |
| 04:52 | mmarczyk | part of my plan for the summer is to give that a shot |
| 04:52 | rava | odd... |
| 04:52 | defn | oh man -- do it. you will never look back. |
| 04:52 | mmarczyk | heh, I feel like you may be right :-) |
| 04:52 | defn | mmarczyk: recipe for success: urxvtd + urxvtc + xmonad |
| 04:52 | mmarczyk | but, um, what about a Web browser, say? |
| 04:53 | mmarczyk | wouldn't it be impractical to have that in the left half of the screen? |
| 04:53 | defn | you can resize |
| 04:53 | rava | anyone around familiar with compojure? |
| 04:53 | defn | M-h makes the left side smaller, M-l does the opposite |
| 04:54 | mmarczyk | rava: not really, but I might remember relevant SO questions and the like |
| 04:54 | defn | mmarczyk: you can also define layouts for specific windows, so when you start firfox it locks it into the position you prefer |
| 04:54 | defn | mmarczyk: you can't even imagine all the stuff you can do with it :) |
| 04:54 | rava | xmonad is amazingly cool |
| 04:54 | mmarczyk | defn: ohhh, that sounds really good |
| 04:54 | rava | check out stumpwm aswell |
| 04:55 | defn | mmarczyk: http://devinwalters.com/?page=3 |
| 04:55 | sexpbot | "'(Devin Walters)" |
| 04:55 | rava | like xmonad but written common-lisp |
| 04:55 | defn | xmonad will be undoubtedly faster |
| 04:55 | rava | (GET "/files" [] |
| 04:55 | rava | (str (print-json (file-list *enc-files-dir*)))) |
| 04:55 | mmarczyk | wow -- wow -- wow :-) |
| 04:55 | defn | ive used a lot of tiled wms, and xmonad was the only one that kept up with me |
| 04:55 | mmarczyk | thanks, for both pointers :-) |
| 04:55 | rava | that should be rendered to the :body no? |
| 04:56 | rava | it's printing to the log for some reason |
| 04:56 | defn | mmarczyk: actually that's sort of useless without something else ill show you... |
| 04:57 | mmarczyk | defn: oh? :-) |
| 04:57 | rava | actually, lemme bug #compojure on this one |
| 04:57 | spariev | ,(doc print-json) |
| 04:57 | clojurebot | "clojure.contrib.json.write/print-json;[[x]]; Prints x as JSON. Nil becomes JSON null. Keywords become strings, without the leading colon. Maps become JSON objects, all other collection types become JSON arrays. Java arrays become JSON arrays. Unicode characters in strings are escaped as \\uXXXX. Numbers print as with pr." |
| 04:57 | defn | mmarczyk: i have a cheat sheet so you can see what does what at a glance |
| 04:57 | defn | just have to find it |
| 04:58 | mmarczyk | defn: cool! |
| 04:58 | spariev | ,(print-json [1 2 3]) |
| 04:58 | clojurebot | java.lang.Exception: Unable to resolve symbol: print-json in this context |
| 04:58 | defn | brb |
| 04:59 | spariev | ,(clojure.contrib.json.write/print-json [1 2 3]) |
| 04:59 | clojurebot | java.lang.ClassNotFoundException: clojure.contrib.json.write |
| 04:59 | mmarczyk | rava: last time I tried Compojure was before 0.4, and then I believe GET expected to get the whole html |
| 04:59 | mmarczyk | not just the part to go in body |
| 04:59 | rava | i just want to return a json string |
| 04:59 | mmarczyk | yeah |
| 04:59 | mmarczyk | no idea why it would print to log instead :-( |
| 05:00 | mmarczyk | and where does print-json come from? |
| 05:00 | rava | clojoure.contrib.json.write |
| 05:00 | spariev | hm, it looks like print-json just, well, print it to strout |
| 05:00 | mmarczyk | aha! |
| 05:00 | mmarczyk | :-) |
| 05:01 | rava | that doesn't seem to make sense, i mean wouldn't that function make more sense to return a string? |
| 05:01 | spariev | rava: try something like (with-out-str (clojure.contrib.json.write/print-json [1 2 3])) |
| 05:02 | mmarczyk | or actually |
| 05:03 | mmarczyk | maybe try write-json |
| 05:03 | mmarczyk | with a (java.io.StringWriter.) argument |
| 05:04 | spariev | btw, I'm using clj-json, wrapper around jackson java lib, it kinda faster by my unscientific measurements |
| 05:04 | rava | where are you getting write-json? |
| 05:05 | mmarczyk | hm, maybe that's a new thing from 1.2 |
| 05:05 | mmarczyk | json-str then |
| 05:05 | mmarczyk | much simpler |
| 05:06 | mmarczyk | and it's in 1.2 also... hm |
| 05:06 | vegai | will it be horribly slow to add to a vector one by one in a (dosync...)? |
| 05:07 | rava | mmarczyk: print-json is in 1.1 aswell |
| 05:07 | Chousuke | vegai: probably. |
| 05:08 | mmarczyk | rava: yeah |
| 05:08 | mmarczyk | json-str should return as string |
| 05:08 | rava | there any way to see what threads are running in a repl and kill it? |
| 05:08 | mmarczyk | what print-json prints |
| 05:08 | mmarczyk | so that's what you'd want to put in your route, I guess |
| 05:08 | rava | i've a jetty instance running now in my emacs repl and trying to find a way to kill and restart the instance |
| 05:09 | mmarczyk | have you got it bound to a Var or sth? |
| 05:10 | Chousuke | vegai: or rather, it'll be as fast as adding to a vector one by one, plus the overhead of the STM |
| 05:10 | mmarczyk | http://stackoverflow.com/questions/2706044/how-do-i-stop-jetty-server-in-clojure |
| 05:10 | sexpbot | "How do I stop jetty server in clojure? - Stack Overflow" |
| 05:11 | rava | hmm.. |
| 05:11 | rava | (GET "/files" [] |
| 05:11 | rava | ((json-str (file-list *enc-files-dir*))) |
| 05:11 | rava | is the route now |
| 05:11 | rava | and i'm getting this in log: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn |
| 05:12 | spariev | looks like you've got one paren more than needed in ((json-str ... |
| 05:12 | mmarczyk | rava: one level of parens too many |
| 05:12 | mmarczyk | right. |
| 05:12 | rava | doh, this is what happens when you're running off of 2 hours of sleep 12 hours ago |
| 05:13 | mmarczyk | :-) |
| 05:16 | rava | woot |
| 05:16 | rava | its silly how long i've been hacking at this ... |
| 05:16 | vegai | (for [line (read-lines file)] (println line)) => no output |
| 05:17 | vegai | what am I doing wrong there |
| 05:17 | Chousuke | for is lazy |
| 05:17 | Chousuke | use doseq |
| 05:17 | vegai | aah |
| 05:18 | vegai | thank you, again |
| 05:23 | bartj | Chousuke: but, the "control" does return after executing "for"? so why is the output of "for" not printed? |
| 05:26 | Lajla | ,((set \a \b \c \d) \b) |
| 05:26 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$set |
| 05:26 | Lajla | ,((set "abcd") \b) |
| 05:26 | clojurebot | \b |
| 05:26 | mmarczyk | bartj: presumably it's being run from a script, in which case return values for expressions aren't printed by default |
| 05:27 | vegai | ,(.trim " a bc \n ") |
| 05:27 | clojurebot | "a bc" |
| 05:27 | vegai | ,(map .trim [" a bc \n "]) |
| 05:27 | clojurebot | java.lang.Exception: Unable to resolve symbol: .trim in this context |
| 05:27 | bartj | mmarczyk: ok, is there any way to print them then? |
| 05:27 | mmarczyk | or possibly it's a non-final expression in a function |
| 05:28 | mmarczyk | I mean, a "do" |
| 05:28 | mmarczyk | possibly implicit |
| 05:28 | mmarczyk | bartj: sure, wrap them in print :-) |
| 05:28 | mmarczyk | if you really want to see the Java-ish string representation, then (print (.toString ...)) |
| 05:28 | mmarczyk | ,(.toString (lazy-seq nil)) |
| 05:28 | clojurebot | "clojure.lang.LazySeq@0" |
| 05:29 | vegai | ah, I need to wrap .trim inside a clojure trim |
| 05:29 | vegai | what's the reason for this again? |
| 05:30 | mmarczyk | .foo-style symbols are treated specially only in the operator position |
| 05:31 | Chousuke | mmarczyk: you can use str instead of .toString |
| 05:32 | mmarczyk | Chousuke: ah, I thought it would force the seq |
| 05:32 | mmarczyk | not so, apparently |
| 05:32 | Chousuke | it's just a wrapper for toString/StringBuilder :) |
| 05:33 | mmarczyk | yup, good catch, thanks :-) |
| 05:40 | rava | thanks for the help. rest easy everyone |
| 05:50 | LauJensen | Hi all |
| 05:50 | esj | Good Morning Mr Jensen |
| 05:50 | unfo- | (hi) |
| 06:02 | angerman | When using the decomp-eigenvalue function from incanter, I get two lists one with the vectors and one with the values. |
| 06:02 | angerman | How would I get the vector that corresponds to the absolute maximum of the values? |
| 06:03 | angerman | basically some index-return on the max function |
| 06:03 | angerman | e.g. vectors = ( v1 v2 v3 v4 ) values = ( 1 2 4 3 ) |
| 06:04 | angerman | ahh. I've an idea, I compute the maximum, interleave them and filter for the one with the maximum value. and then run take 1 on them |
| 06:17 | hoeck | ,(apply max-key second (map vector [:v1 :v2 :v3 :v4] [1 3 4 2])) |
| 06:17 | clojurebot | [:v3 4] |
| 06:18 | hoeck | but I don't like the packing together the pairs in those solutions |
| 06:19 | angerman | well, |
| 06:20 | vegai | is there a nice way to update a map so that either a new value is inserted |
| 06:20 | vegai | or a new value is computed based on the old value if it exists |
| 06:20 | Chousuke | vegai: update-in |
| 06:20 | Chousuke | (update-in {:a 1} [:a] inc). though you need to handle the nil case separately |
| 06:22 | Chousuke | you can define a function called fnil like so: (defn fnil [f val] (fn [x] (if-not (nil? x) (f x) val))) and then do (update-in m [:key] (fnil inc 0)) |
| 06:22 | vegai | ok... |
| 06:23 | vegai | and how to coerce a string into a number? |
| 06:23 | Chousuke | what kind of a number? :) |
| 06:23 | angerman | hoeck: yep, that seems to work, though it takes the last (if multiple ones with the same key) ... |
| 06:23 | angerman | still kinda ugly :D |
| 06:23 | Chousuke | You can use the java static methods: Integer/parseInt etc. |
| 06:23 | vegai | Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number |
| 06:24 | vegai | to make this go away :) |
| 06:24 | vegai | yeah, that might work |
| 06:25 | Chousuke | I still wonder why fnil is not in core. it's very useful. |
| 06:38 | LauJensen | silly name though Chousuke, "fnil" :) |
| 06:47 | mmarczyk | http://groups.google.com/group/clojure/msg/f251cfd9baab440a |
| 06:47 | mmarczyk | :-) |
| 06:47 | mmarczyk | hi Lau |
| 06:50 | mmarczyk | I've been looking at "Approaching Productivity" again (apparently you're really onto sth with that post ;-)) and noticed that you're not using -> / ->> in your elisp! :-) |
| 06:50 | mmarczyk | http://gist.github.com/408702 |
| 06:51 | mmarczyk | there. I also have -> & ->> written as r5rs macros somewhere |
| 06:52 | mmarczyk | I *can't imagine* how I lived without these two. |
| 06:56 | defn | wait, what's fnil? |
| 06:57 | mmarczyk | see above |
| 06:57 | mmarczyk | or click the link ;-) |
| 07:00 | vegai | .split is weird for working differently based on the type of the first argument |
| 07:00 | vegai | ,(vec (.split #"," "1,2")) |
| 07:00 | clojurebot | ["1" "2"] |
| 07:00 | vegai | ,(vec (.split "1,2" ",")) |
| 07:00 | clojurebot | ["1" "2"] |
| 07:00 | vegai | java limitation? |
| 07:01 | vegai | or what... |
| 07:04 | mmarczyk | (.split foo ...) means "call method split on object foo with args ..." |
| 07:04 | mmarczyk | java.util.regex.Pattern has a difference implementation to that of java.lang.String |
| 07:04 | mmarczyk | different. |
| 07:07 | LauJensen | mmarczyk: hey, sorry for the late reply, my highlighter didn't pick up 'Lau' for some reason |
| 07:07 | LauJensen | odd |
| 07:08 | LauJensen | ah cool |
| 07:08 | mmarczyk | np :-) |
| 07:16 | LauJensen | In java terms, what is for(; ;) ? |
| 07:18 | hoeck | like while true { } |
| 07:18 | hoeck | an infinite loop |
| 07:18 | LauJensen | k |
| 07:18 | LauJensen | thx |
| 07:19 | LauJensen | Sure is nice to see Clojure atoms based on sun.misc.Unsafe, titled "The Unsafe service" |
| 08:03 | defn | mmarczyk: approaching productivity? |
| 08:04 | defn | mmarczyk: ah nevermind, you were referring to LauJensen's post |
| 08:04 | LauJensen | Chousuke: ping |
| 08:09 | Chousuke | LauJensen: pong |
| 08:09 | LauJensen | Chousuke: Im thinking of picking up Magit again and was wondering if you would share your top-10 hotkeys, workflow tricks etc ? |
| 08:11 | Chousuke | LauJensen: my use of magit is really simple. I mostly just use s/u for stage/unstage and tab to expand files to chunk view so I can stage individual chunks. and then I just commit and sometimes push/change branches |
| 08:12 | Chousuke | oh, and k is useful for deleting trash files in the status view as well |
| 08:12 | Chousuke | I haven't even tried to do anything more complicated with magit like rebases |
| 08:12 | Chousuke | I'm still more comfortable using the git command line UI for those |
| 08:13 | LauJensen | tcrayford: in magit? |
| 08:13 | tcrayford | nah, command line |
| 08:13 | tcrayford | -i is essential |
| 08:13 | LauJensen | Chousuke: Ok cool, commit is C-c C-c ? and push / pull is ? |
| 08:13 | tcrayford | LauJensen: C-h m describes the current mode, then just search for magi |
| 08:13 | tcrayford | *magit |
| 08:14 | Chousuke | actually "c" commits in the status view |
| 08:14 | bozhidar | P is push |
| 08:14 | bozhidar | F is pull |
| 08:14 | LauJensen | tcrayford: the reason Im asking Chousuke is to avoid the docs and learn first hand from a user |
| 08:14 | Chousuke | C-c C-c is just when you're finished typing the message |
| 08:14 | LauJensen | Ah ok, Egg copied that bit |
| 08:15 | LauJensen | Thanks a lot Chousuke and bozhidar , I'll give it a whirl :) |
| 08:15 | Chousuke | if you use menu mode in emacs you can get pretty far by just looking through the magit menus |
| 08:16 | bozhidar | no menus for me :-) |
| 08:16 | Chousuke | LauJensen: it's also useful to bind a key to 'magit-status |
| 08:17 | Chousuke | LauJensen: I have meta-f12 |
| 08:17 | LauJensen | F2 is all fired up and ready to go :) |
| 08:17 | Chousuke | also I apparently have set magit-save-some-buffers to nil |
| 08:18 | LauJensen | Chousuke: Isnt it desirable to have all buffers save once you pull up the status view ? |
| 08:18 | Chousuke | well, that depends |
| 08:18 | Chousuke | I switch over to the status view so often that it just annoys me |
| 08:20 | bozhidar | I have advised switch-to-buffer to save my buffers at switch anyways |
| 08:20 | bozhidar | I'm too paranoid about losing changes |
| 08:20 | bartj | what is the difference between "->" and "->>" |
| 08:21 | LauJensen | bartj: thread as second argument, or last argument |
| 08:21 | bartj | ,(doc ->>) |
| 08:21 | 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." |
| 08:21 | LauJensen | (-> 5 (+ 2)) = (+ 5 2), (->> 5 (+ 2)) = (+ 2 5) |
| 08:21 | tcrayford | ,(-> 1 (/ 2)) |
| 08:21 | clojurebot | 1/2 |
| 08:21 | tcrayford | ,(->> 1 (/ 2)) |
| 08:21 | clojurebot | 2 |
| 08:23 | tcrayford | haha |
| 08:23 | tcrayford | `gut status` |
| 08:24 | bartj | , (-> 5 (+ 2)) |
| 08:24 | clojurebot | 7 |
| 08:24 | LauJensen | ,(print (str \$ "(-> 5 (+ 2))")) |
| 08:24 | clojurebot | $(-> 5 (+ 2)) |
| 08:24 | sexpbot | result: 7 |
| 08:25 | bartj | , (->> 5 (+ 2)) |
| 08:25 | clojurebot | 7 |
| 08:25 | bartj | , (--> 5 (* 2) (* 3)) |
| 08:25 | clojurebot | java.lang.Exception: Unable to resolve symbol: --> in this context |
| 08:25 | bozhidar | for plus the order doesn't really matter |
| 08:26 | bartj | , (->> 5 (* 2) (* 3)) |
| 08:26 | clojurebot | 30 |
| 08:26 | LauJensen | bozhidar: I know, just thought it would be fun to let clojurebot start off sexpbot |
| 08:26 | bartj | , (-> 5 (* 2) (* 3)) |
| 08:26 | clojurebot | 30 |
| 08:27 | bartj | , (-> 5 (- 2) (- 3)) |
| 08:27 | clojurebot | 0 |
| 08:27 | bartj | , (->> 5 (- 2) (- 3)) |
| 08:27 | clojurebot | 6 |
| 08:27 | bozhidar | LauJensen: I noticed your intent, I was saying this because of bartj experiments |
| 08:27 | LauJensen | ah |
| 08:27 | LauJensen | bartj: there's also tryclojure.org I think |
| 08:27 | bozhidar | and SLIME of course ;-) |
| 08:28 | bozhidar | a SLIME REPL I meant |
| 08:30 | bartj | , (-> 5 (- 2)) |
| 08:30 | clojurebot | 3 |
| 08:31 | bartj | , (->> 5 (- 2)) |
| 08:31 | clojurebot | -3 |
| 08:31 | bozhidar | bartj: don't flood the channel with your experiments... |
| 08:32 | LauJensen | defn: wow, cool way to waste your life :) |
| 08:32 | defn | LauJensen: :) Just started on it -- I had never heard of Malbolge. I have a feeling this will take me a long..long time. Very interesting though... |
| 08:32 | bozhidar | defn: you should proceed with BrainFuck :-) |
| 08:33 | defn | bozhidar: Malbolge is way...way harder. |
| 08:33 | defn | (IMO) |
| 08:33 | bozhidar | defn: you're probably right, I just remember brainfuck was created for a similar purpose |
| 08:34 | defn | Malbolge was so difficult to understand when it arrived that it took two years for the first Malbolge program to appear. The program was not even written by a human being: it was generated by a beam search algorithm designed by Andrew Cooke and implemented in Lisp. |
| 08:34 | defn | ^lol^ |
| 08:34 | bozhidar | hahaha |
| 08:34 | LauJensen | defn: There's a 99 bottles of beer on the wall program written in Malbolge |
| 08:34 | bartj | thanks guys for explaining "->" and "->>" |
| 08:35 | defn | LauJensen: no way! Is it in that 99bottles github repo? |
| 08:35 | LauJensen | http://99-bottles-of-beer.net/language-malbolge-995.html |
| 08:35 | sexpbot | "99 Bottles of Beer | Language Malbolge" |
| 08:35 | defn | Oh...my...God... |
| 08:35 | LauJensen | but it looks like a Perl version, just with changed names |
| 08:35 | bartj | is there any use-case (experiment) you can think of for "->>" |
| 08:35 | defn | LauJensen: yeah that looks awfully perl-esque |
| 08:36 | tcrayford | bartj: if you're nesting lots of filter/map/reduce calls, ->> is useful |
| 08:36 | LauJensen | ,(->> (range 10) (filter odd?) (map inc)) |
| 08:36 | clojurebot | (2 4 6 8 10) |
| 08:36 | defn | I wonder if that crypto puzzle outside of the NSA could be solved with malbolge... |
| 08:36 | defn | Krypto, is it? |
| 08:37 | LauJensen | Malbolge, much like Perl, does not solve problems it creates them |
| 08:37 | tcrayford | I find that that above form easier to read than the nested version |
| 08:37 | defn | LauJensen: *chuckle* |
| 08:37 | defn | tcrayford: really? I rather like the nested version to be honest... |
| 08:37 | tcrayford | defn: I prefer using ->> a lot of the time |
| 08:38 | defn | tcrayford: I write everything nested, and then i use clojure-refactoring where it makes sense ;) |
| 08:38 | tcrayford | defn: you're actually using clojure-refactoring on stuff? cool. |
| 08:38 | bartj | can some one tell me why I cannot do this: "->>" |
| 08:39 | bartj | I get a "Unable to resolve symbol" on my system |
| 08:39 | tcrayford | you just entered ->> at the repl? |
| 08:39 | bartj | do I need to check the version of my clojure installation? |
| 08:39 | bartj | I mean on my system |
| 08:39 | tcrayford | bartj: use *clojure-version* |
| 08:39 | bartj | :major 1 |
| 08:39 | tcrayford | and minor? |
| 08:40 | defn | tcrayford: yeah i include it on all my little projects -- it's cool to use it on code i wrote all nested that contains java interop |
| 08:40 | defn | it's like...oh yeah.../that's/ what I meant |
| 08:40 | tcrayford | defn: are you unit testing that? I know refactoring-mode blows up occasionally |
| 08:41 | defn | tcrayford: it does occasionally explode and delete the preceding sexp or some craziness, but that's what C-_ is for :) |
| 08:41 | bartj | :minor 0 |
| 08:41 | bartj | {:interim true, :major 1, :minor 0, :incremental 0, :qualifier ""} |
| 08:41 | defn | ->> isn't in 1.0 is it? |
| 08:41 | tcrayford | defn: if you find stuff when it does eplode (and you're ok posting the code somewhere), then message me on github with what broke |
| 08:42 | tcrayford | nope |
| 08:42 | defn | that's a 1.1.0 isn't it? |
| 08:42 | tcrayford | pretty sure |
| 08:42 | defn | yeah |
| 08:42 | bartj | so I need to upgrade that's all, right? |
| 08:42 | tcrayford | defn: I'm more than welcome for bug reports, apart from those that involve the newline problem |
| 08:43 | defn | tcrayford: yeah i'll definitely do that, i should have been doing that all along, but i assumed you were aware, and i had been using your major mode which you stated you were trying to boil down to a minor mode so I figured it was just known beta limitations |
| 08:44 | tcrayford | defn: the other thing is that I'm considering moving refactoring-mode so that it changes files on disk instead of doing stuff with emacs. You got any thoughts on that? |
| 08:45 | defn | well, like I said, being able to just step back and undo in case something naughty happens is nice, and it's neat to see how something will look threaded and then just step back out of it |
| 08:45 | defn | i think for certain operations disk probably makes more sense, but for others maybe not, you know? |
| 08:45 | tcrayford | defn: aye. The problem with doing stuff on disk is that I'd need to rework how undo works |
| 08:46 | bartj | tcrayford: I just need to upgrade right? |
| 08:46 | defn | bartj: yes |
| 08:46 | defn | to 1.1.0 |
| 08:46 | bartj | cool, thanks |
| 08:46 | tcrayford | defn: I'm considering doing it for all the refactorings, to get rid of the newline problem |
| 08:46 | defn | tcrayford: im assuming that's where, wherever a \n exists, it explodes? |
| 08:46 | tcrayford | defn: yeah |
| 08:47 | tcrayford | it doesn't explode hugely, it just prints the \n as an actual newline in emacs |
| 08:47 | defn | that's sort of a surprise that you cant get around that |
| 08:48 | defn | what's the issue in making that work correctly? |
| 08:48 | defn | (if you dont mind me asking) |
| 08:48 | tcrayford | how I move data between emacs and clojure |
| 08:48 | defn | ahhh, do you remove the \n's and treat it like a one-liner sexp? |
| 08:48 | tcrayford | go look at the tests |
| 08:48 | defn | looking now... |
| 08:50 | tcrayford | the real downside of disk stuff is that I'd have to work out some system of stubbing out the filesystem AND namespaces so that I could test it. I'd hate to not have tests for this kinda stuff :/ |
| 08:50 | defn | yeah tests here are crucial |
| 08:52 | tcrayford | and the whole having undo be a seperate function thing :/ |
| 08:52 | defn | yeah, makes the problem harder... refactoring libraries are /hard/ |
| 08:52 | defn | you're a braver man than me |
| 08:52 | tcrayford | heh, I've been putting off doing the rename refactoring for *ages* because of this |
| 08:53 | defn | hehe, yeah i knew someone who was working on a refactoring library for ruby, and he got rename done, but...that's it |
| 08:53 | defn | lol |
| 08:53 | tcrayford | renames are damn near impossible in ruby anyway |
| 08:54 | defn | ive often wondered if turning ruby into s-exps would make refactoring "easier" |
| 08:54 | tcrayford | people have done it, but its still pretty much impossible in certain situations |
| 08:54 | defn | yeah |
| 08:55 | tcrayford | like, given three classes, A B & C, where A & B both have method "foo", and class C calls "foo" somewhere. If you want to rename foo from inside C, how do you know to rename A or B |
| 08:56 | defn | gotta follow those singletons to hell and back |
| 08:57 | defn | but the context there could change everything, sure |
| 08:57 | tcrayford | yep |
| 09:00 | tcrayford | defn: atm I'm going to work on having rename-fn refactor to disk, and see how that goes |
| 09:00 | defn | tcrayford: so without knowing how all the pieces fit together, could a "perfect" anti-pprint library of some sort be useful? |
| 09:01 | defn | in order to get it into a more malleable form prior to transform? |
| 09:01 | tcrayford | maybe |
| 09:02 | tcrayford | I think clojure.pprint works well enough for me right now |
| 09:02 | defn | i just look at what little ive done with the pprint lib for reformating long one-line sexps |
| 09:02 | defn | and i wonder about doing the opposite |
| 09:02 | tcrayford | what I *really* need is a clojure-reader that tags every sexp with metadata of offset from the start of the sexp (in the string) |
| 09:03 | defn | yell at hiredman and Chousuke :) |
| 09:03 | tcrayford | mm? |
| 09:03 | defn | ive just been told they're the reader gurus |
| 09:03 | tcrayford | I think its a lot of work, so meh for now |
| 09:04 | defn | perhaps they'd have a suggestion to some successful end |
| 09:04 | tcrayford | perhaps |
| 09:04 | tcrayford | chouser showed me how to use the compiler to get all bound vars out of a sexp the other day, is pretty cool |
| 09:05 | defn | tcrayford: yeah, either way, i have to say: great work. these are the sorts of projects (refactoring) that can make a tremendous difference in a language. |
| 09:05 | defn | tcrayford: whoa. that is cool. |
| 09:05 | defn | that's mad scientist talk, even. |
| 09:05 | defn | :) |
| 09:05 | tcrayford | defn: the problem is that you have to use eval, and that makes it pretty messy |
| 09:05 | bartj | one newbie question: why is it called "s-expression", I always thought clojure statements were just "expressions" |
| 09:06 | defn | bartj: bartj http://en.wikipedia.org/wiki/S-expression |
| 09:06 | sexpbot | "S-expression - Wikipedia, the free encyclopedia" |
| 09:06 | Chousuke | I think technically clojure expressions are a superset of s-exprs |
| 09:06 | tcrayford | seeing as they use things other than lists |
| 09:07 | chouser | tcrayford: wait, what requires using 'eval'? |
| 09:07 | tcrayford | chouser: that compiler analysis thing used eval |
| 09:07 | tcrayford | ,(->> (clojure.lang.Compiler/analyze clojure.lang.Compiler$C/EVAL |
| 09:07 | tcrayford | '(let [a 3 b 4] a)) .fexpr .methods first .locals keys (map #(.sym |
| 09:07 | tcrayford | %))) |
| 09:07 | clojurebot | EOF while reading |
| 09:07 | tcrayford | fail |
| 09:08 | chouser | that's not using eval |
| 09:08 | tcrayford | so when I run it, why do I get a warning about replacing vars in whatever namespace I run it in? |
| 09:08 | chouser | ah. yes, well... |
| 09:08 | tcrayford | if its analysing a `def` form |
| 09:08 | defn | btw, maybe this is a ridiculous question considering how long ago it was, but are there any videos of McCarthy's lecture when he presented lisp? |
| 09:09 | defn | like of the actual black and white presentation? |
| 09:09 | chouser | The compiler analysis phase does define vars, though it doesn't bind any values to them. |
| 09:09 | tcrayford | chouser: right, which ended up being problematic a lot of the time |
| 09:09 | chouser | I can believe that. hmph. |
| 09:10 | chouser | you can bind *ns* to something throw-away... |
| 09:10 | chouser | meh. I wonder if anything cleaner can be done for c-in-c. |
| 09:10 | tcrayford | I hope so |
| 09:11 | tcrayford | refactoring-mode does something similar (but I do the analysis myself, using recursion), which would be much better done via talking to the compiler |
| 09:11 | chouser | I believe it's done so that the definition of the var can refer to the var being defined. |
| 09:12 | chouser | but ... actually, I wonder if that's even necessary anymore. |
| 09:13 | tcrayford | I'm looking forward to c-in-c for this kinda stuff, should make it a bit easier to understand |
| 09:13 | chouser | yes |
| 09:13 | chouser | I think the next step, or at least the one I'd like to see, is a tool to convert a CompilerExpr tree to a tree of defrecord objects |
| 09:14 | tcrayford | are there actual plans for c-in-c yet, or is thinking about that on hold until 1.2 is released? |
| 09:14 | chouser | specifically, a tree of records that rhickey approves as being the official target for cinc when it is implemented. |
| 09:15 | chouser | once such a converter exists (and its output documented), work could proceed independently on both a analyzer producing that format using clojure instead of java code, and also various tools using that tree |
| 09:16 | defn | tcrayford: i know there's been talk about c-in-c for the last few months -- specifically i remember rich or someone close to the action saying "soon" |
| 09:16 | chouser | tools that could include emitters for other host platforms, lint-like tools, other code analysis tools, etc. |
| 09:16 | tcrayford | yep. I'm interested in writing a lint tool as well |
| 09:18 | chouser | the only reason I'm not working on a converter is because I'm supposed^W working on a book. |
| 09:18 | tcrayford | the joy of clojure has been a pretty good read so far though |
| 09:18 | chouser | great, glad you're enjoying it. |
| 09:21 | defn | chouser: ditto to tcrayford's comment -- lots of the right kind of depth |
| 09:21 | tcrayford | chouser: also I'm finding on lisp to be *really* good, even if it is in common lisp |
| 09:21 | chouser | yes, "on lisp" is solid. |
| 09:22 | tcrayford | though bits of it keep on flying over my head, I think I'm on my third go through now |
| 09:22 | chouser | before reading that, I wasn't sure why lisp was so venerated. After, I knew: I must have macros. |
| 09:23 | defn | before PG became Mr. 2.0 |
| 09:23 | tcrayford | is there a way to create a var on the fly? |
| 09:24 | defn | like...gensym you mean? |
| 09:24 | defn | or lower level? |
| 09:25 | tcrayford | no, something like (var 'foo), that actually returns a var object that I've just made |
| 09:25 | defn | oh, no idea.. |
| 09:25 | tcrayford | oh, you can do it with var |
| 09:25 | bartj | chouser: I wrote a glowing review of your book here: http://rubylearning.org/class/mod/forum/discuss.php?d=3839 |
| 09:25 | sexpbot | "A Ruby Learning Hub: Login to the site" |
| 09:25 | tcrayford | ,(var foo) |
| 09:25 | clojurebot | java.lang.Exception: Unable to resolve var: foo in this context |
| 09:25 | chouser | tcrayford: with-local-vars |
| 09:26 | chouser | writing that section this week. |
| 09:26 | bartj | chouser: Thank you a million times. I just love your book a million times (compared to Programming Clojure) |
| 09:26 | chouser | bartj: wow! thanks! |
| 09:27 | lpetit | bartj: Programming clojure starts to show its age, but for what I've read of it (a quarter, maybe), it's very well written. (I have not yet read chouser's one, though ;-) ) |
| 09:28 | tcrayford | http://gist.github.com/408827 for some reason defining that var on the fly always ends up with it on a line of 19 |
| 09:28 | bartj | lpetit: If I had money, I would pay you to go read it right now. Seriously. |
| 09:29 | chouser | first chapter is free. :-) |
| 09:29 | bartj | chouser: have you written any other books? :) |
| 09:29 | chouser | ha! no. |
| 09:29 | bartj | chouser: and your co-author fogus? |
| 09:30 | chouser | sorry, laughing was probably rude. This is hard work. |
| 09:30 | chouser | no, this is Fogus's first as well |
| 09:31 | bartj | chouser: I profusely apologize...I was just being greedy and cheeky to read all your books...Sorry again... |
| 09:31 | chouser | oh, please don't apologize. |
| 09:32 | bartj | chouser: like i said, i just wanted to read your other books...I was so impressed by your "Joy of Clojure" book. That is all. |
| 09:32 | bozhidar | chouser: when is the book expected - I don't see it for preorder on amazon |
| 09:33 | tcrayford | bozhidar: see manning.com |
| 09:33 | tcrayford | (which, funnily enough uses yahoo store) |
| 09:34 | bozhidar | fall 2010 - not very specific :-) |
| 09:34 | defn | it's on amazon? |
| 09:34 | defn | i thought it was only available via manning? |
| 09:34 | chouser | bartj: it was a perfectly reasonable question. |
| 09:34 | bozhidar | defn: it's not |
| 09:34 | chouser | bartj: so, do I need an enrollment key to read that link you posted? |
| 09:35 | bartj | chouser: is it ok to post it here? |
| 09:36 | bartj | Anyway, the enrollment key is: BPCE101 |
| 09:36 | chouser | I was just curious to see what you said, but it doesn't seem to let me. |
| 09:36 | tcrayford | chouser: I can gist it if you want |
| 09:36 | defn | chouser: actually, i dont know if you have any interest -- but there are quite a few "students" in rubylearning who post quite regularly. it's kind of a mixed bag, but im sure some of the folks would appreciate a cameo from the famous chouser :) |
| 09:36 | tcrayford | when I get rubylearning's terrible website working |
| 09:37 | bartj | tcrayford: can you gist the full page? |
| 09:39 | chouser | well, I'm giving up for now. Can't seem to get anything beyond "This course is not enrollable at the moment" |
| 09:39 | tcrayford | chouser: yeah, the course has started an all |
| 09:39 | tcrayford | bartj: shouldn't there be more exercises than week 1? |
| 09:39 | defn | chouser: it's a really poor site |
| 09:40 | bartj | tcrayford: I am afraid, I don't understand |
| 09:40 | tcrayford | on the rubylearning course? |
| 09:41 | defn | I am afraid also |
| 09:41 | tcrayford | I only see exercises for week 1 (which I completed ages ago), and I was under the impression that there were more weeks than that |
| 09:41 | defn | tcrayford: yeah i thought so too :\ |
| 09:41 | tcrayford | chouser: http://gist.github.com/408841 |
| 09:41 | defn | Michael Fogus will be online on our forum from 25-27 May 2010 to answer questions related to Clojure and his forth-coming book "The Joy of Clojure". |
| 09:41 | defn | ah, cool |
| 09:42 | bartj | tcrayford: yes there are |
| 09:42 | tcrayford | bartj: really? how do I get to them?? |
| 09:42 | tcrayford | oh, got it |
| 09:42 | bartj | er, you need to be enrolled in the course |
| 09:42 | tcrayford | I am |
| 09:42 | tcrayford | I'm debating dropping out though, the site is *so* bad |
| 09:43 | chouser | nice, thanks. |
| 09:43 | bartj | er, sorry guys may be it is just my taste but, I liked the site! |
| 09:44 | tcrayford | I'm not so worried about the looks, just the fact that navigating around it is really annoying, and working out what's going on on the course is annoying |
| 09:45 | bartj | tcrayford: you go here http://rubylearning.org/class/course/view.php?id=53 - which gives you a nice overview |
| 09:45 | sexpbot | "A Ruby Learning Hub: Login to the site" |
| 09:45 | tcrayford | bartj: see, when I clicked the link to the course I only ever got to week 1's stuff |
| 09:46 | bartj | beats me. i see four weeks listed here |
| 09:46 | tcrayford | yeah, that link you gave me has 4 weeks, but when I clicked on the link to the clojure course from the homepage I only ever got to week 1 |
| 09:47 | Chousuke | Someone needs to invent a device to control the sun's heat. I'm melting here ;/ |
| 09:47 | tcrayford | I think I'll learn more from working through "on lisp" anyway |
| 09:48 | Chousuke | and it's "only" 26 degrees celsius |
| 09:48 | bartj | tcrayford: can you post the link here please? |
| 09:48 | tcrayford | bartj: it seems to be fixed now, maybe I was doing something wrong before |
| 09:49 | defn | tcrayford: it's polite to stay on the list and help people out from time to time -- there are some pretty 'green' folks on there who have a real desire to learn clojure -- the more we can do to encourage them the better :) |
| 09:50 | defn | im preaching a bit, and it's not really directed at you, more of a PSA than anything |
| 09:50 | defn | although i think this community has had the right feeling from day one |
| 09:51 | tcrayford | I'm pretty lazy with sticking to stuff like that course atm, I prefer learning from myself/friends/colleagues/this channel |
| 09:51 | defn | tcrayford: yeah same here, but again, not everyone has been on IRC for 10 years, and some even find it scary or intimidating |
| 09:52 | defn | gotta keep that human connection alive! :) |
| 09:52 | tcrayford | defn: I've only really been on irc for a couple of months |
| 09:52 | defn | really? i've been on IRC since I was...gosh...13 |
| 09:52 | esj | defn: truedat, as an 'eager green' I'm most grateful for the skilled in this channel |
| 09:52 | defn | esj: it's difficult i think to learn the irc cultural dynamic |
| 09:52 | tcrayford | defn: I've only been into programming a couple of years, and the first year and a half were spent in hermit mode |
| 09:53 | defn | some folks pour their heart out on irc and get discouraged when everyone doesnt fall over to explain every detail -- i remember asking questions in #c and #c++ and basically getting laughed at |
| 09:53 | tcrayford | not to mention #emacs and #git :/ |
| 09:54 | defn | the first "good" experience I had on irc was in #ruby-lang -- i'd actually say (surprisingly) that the culture on IRC has really matured over the last few years in particular |
| 09:54 | defn | i think people finally got hip to the fact that helping other people learn about their favorite things was as beneficial to them as it was to the people they are helping |
| 09:54 | defn | s/are/were |
| 09:55 | esj | yup, until you've explained it, you don't understand it |
| 09:55 | underdev | yeah, fr33n0de rulzrz! |
| 09:55 | defn | but then again, i used to be on EFnet -- freenode is a whole 'nother animal of irc |
| 09:55 | underdev | ;) |
| 09:56 | esj | careful, you'll make CB and SB jealous |
| 09:57 | bartj | how do I know which function belongs to which library? |
| 09:58 | bartj | for example on my REPL, it says "Unable to resolve var" when I use the "re-split" function |
| 09:58 | tcrayford | (find-doc "re-split") |
| 09:58 | tcrayford | ,(find-doc "re-split") |
| 09:58 | clojurebot | nil |
| 09:58 | bartj | er, nil? |
| 09:59 | tcrayford | try that at a repl |
| 09:59 | bartj | yes did that |
| 09:59 | tcrayford | I get a printout of re-split |
| 09:59 | bartj | have currently loaded both clojure.jar and clojure-contrib.jar on the classpath |
| 10:01 | tcrayford | (vals (apply merge (map ns-publics (all-ns)))) gets you a list of all the vars currently loaded (I think), and you can go through it using filter |
| 10:01 | tcrayford | ,(filter #(.contains % "re-split") (map #(.toString %) (vals (apply merge (map ns-publics (all-ns)))))) |
| 10:01 | clojurebot | () |
| 10:03 | bartj | tcrayford: get an empty list |
| 10:04 | defn | ,(ns-public 'clojure.core) |
| 10:04 | clojurebot | java.lang.Exception: Unable to resolve symbol: ns-public in this context |
| 10:04 | defn | ,(ns-publics 'clojure.core) |
| 10:04 | defn | did i break clojurebot? :X |
| 10:04 | tcrayford | defn: clojurebot will timeout that, (I think) |
| 10:04 | tcrayford | ,(+ 1 1) |
| 10:05 | defn | uh oh... |
| 10:05 | tcrayford | haha |
| 10:05 | defn | ,*clojure-version* |
| 10:05 | tcrayford | that's funny, because ns-publics on clojure.core doesn't take any time whatsoever here |
| 10:05 | defn | yeah i've done it in here before i think |
| 10:06 | defn | hiredman: I think clojurebot choked... |
| 10:06 | arkahn | $(ns-public 'clojure.core) |
| 10:06 | sexpbot | clojure.core |
| 10:07 | tcrayford | $(ns-publics 'clojure.core) |
| 10:07 | defn | $(ns-publics 'clojure.core) |
| 10:07 | sexpbot | clojure.core |
| 10:07 | sexpbot | clojure.core |
| 10:07 | defn | whaaaa? |
| 10:07 | bartj | defn: was my question the culprit? |
| 10:07 | arkahn | $(filter #(.contains % "re-split") (map #(.toString %) (vals (apply merge (map ns-publics (all-ns)))))) ;credits tcrayford |
| 10:07 | sexpbot | DENIED! |
| 10:07 | spariev | defn, the bot crusher :) |
| 10:08 | defn | lol -- i want that for my official title |
| 10:08 | defn | ,(+ 1 2) |
| 10:08 | defn | man he is really dead...surprising |
| 10:08 | defn | clojurebot is battle-tested, mother approved |
| 10:09 | bartj | off home, while clojurebot someone administers CPR |
| 10:10 | defn | bartj: wanna wait one second so i can answer your question before you go? |
| 10:10 | tcrayford | defn: put an issue on hiredman's github repo for clojurebot |
| 10:10 | bartj | defn: definitely! |
| 10:12 | clojurebot | {sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, chunked-seq? #'clojure.core/chunked-seq?, find-protocol-impl #'clojure.core/find-protocol-impl, vector-of #'clojure.core/vector-of, object-array #'clojure.core/object-array, *compile-path* #'clojure.core/*compile-path*, max-key #'clojure.core/max-key, lis |
| 10:12 | clojurebot | 3 |
| 10:12 | defn | haha! |
| 10:12 | clojurebot | {:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"} |
| 10:12 | tcrayford | he lives! |
| 10:12 | defn | clojurebot: welcome back! |
| 10:13 | clojurebot | 2 |
| 10:13 | clojurebot | Excuse me? |
| 10:14 | bartj | defn: ? |
| 10:14 | defn | ,(ns-publics 'clojure.core) |
| 10:14 | defn | sorry all, just testing again to make sure it wasnt just lag on clojurebot's side |
| 10:15 | tcrayford | ,(+ 1 1) |
| 10:15 | tcrayford | yeah, seems to be dead |
| 10:15 | tcrayford | I'm surprised clojurebot doesn't fire up a thread for every request |
| 10:15 | defn | yeah... anyway, bartj -- tcrayford's advice is good |
| 10:16 | defn | (map ns-publics (all-ns)) should give you all the functions in all the namespaces |
| 10:16 | tcrayford | defn, don't forget to apply merge to that |
| 10:16 | defn | oh right |
| 10:17 | defn | bartj: (apply merge (map ns-publics (all-ns))) |
| 10:17 | defn | run that at your REPL |
| 10:17 | bartj | defn: yes |
| 10:17 | defn | bartj: or if you just want to see all of the functions, without their namespaces you could do: |
| 10:18 | clojurebot | {sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, chunked-seq? #'clojure.core/chunked-seq?, find-protocol-impl #'clojure.core/find-protocol-impl, vector-of #'clojure.core/vector-of, object-array #'clojure.core/object-array, *compile-path* #'clojure.core/*compile-path*, max-key #'clojure.core/max-key, lis |
| 10:18 | clojurebot | 2 |
| 10:18 | bartj | defn: I can't find "re-split" function listed when I do that |
| 10:18 | AWizzArd | A clojure fn similar to the (get ..) map, but which returns the key/value pair, and not only the value? |
| 10:18 | defn | (map str (map first (apply merge (map ns-publics (all-ns))))) |
| 10:19 | tcrayford | AWizzArd: I don't know of any, but you can write one pretty easily |
| 10:19 | defn | (sort (map str (map first (apply merge (map ns-publics (all-ns)))))) |
| 10:19 | defn | bartj: are you still on 1.0? |
| 10:19 | bartj | no 1.2 |
| 10:19 | AWizzArd | tcrayford: without iterating over the collection? |
| 10:20 | bartj | {:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"} |
| 10:20 | tcrayford | AWizzArd: yeah |
| 10:20 | AWizzArd | tcrayford: how? |
| 10:20 | defn | bartj: weird. |
| 10:20 | tcrayford | (defn a-clojure-fn [k mp] (conj [k] (k mp))) |
| 10:20 | defn | bartj: how are you running your REPL? |
| 10:20 | bartj | defn: java -cp "clojure/clojure.jar:clojure-contrib/target/clojure-contrib-1.2.0-SNAPSHOT.jar" clojure.main $1 |
| 10:20 | tcrayford | (a-clojure-fn :foo {:foo 1}) ;; ouputs [:foo 1] |
| 10:21 | AWizzArd | tcrayford: that does return the k which I provided, which will be = but not identical. |
| 10:21 | AWizzArd | I want something that is identical to the key, not just = |
| 10:21 | tcrayford | ,(identical? :foo :foo) |
| 10:21 | clojurebot | true |
| 10:22 | tcrayford | keywords are interned (so it works for keywords anyway) |
| 10:23 | bartj | defn: I am leaving now |
| 10:23 | AWizzArd | tcrayford: what if my keys are strings or instances of defrecords? |
| 10:23 | bartj | bye and thank you all very much guys! you guys are awesome. seriously. |
| 10:23 | AWizzArd | (identical? (MyRecord. 1 2 3) (MyRecord. 1 2 3)) ==> false |
| 10:23 | tcrayford | strings are fine though |
| 10:23 | AWizzArd | or when my keys are java.util.Date instances? |
| 10:24 | defn | i have no idea why he doesnt have split-with |
| 10:24 | tcrayford | yeah it doesn't work all the time. I don't think there's anything that I know about in clojure that does that |
| 10:24 | hoeck | AWizzArd: what about find? |
| 10:24 | AWizzArd | hoeck: ah yes, that was the fn I was looking for. |
| 10:24 | AWizzArd | I keep forgetting it. |
| 10:25 | defn | wait wait, what do you mean find? |
| 10:25 | tcrayford | ,(find {:foo 1} :foo) |
| 10:25 | clojurebot | [:foo 1] |
| 10:25 | defn | ahhhhh i see |
| 10:26 | hoeck | ,(meta (first (find {(with-meta 'a {:meta :t}) :a} 'a))) |
| 10:26 | clojurebot | {:meta :t} |
| 10:26 | hoeck | find returns the maps MapEntry, so it preservers key metadata |
| 10:26 | hoeck | *preserves |
| 10:28 | AWizzArd | for me it is important that I get the key which sits in the map, and with find I can do that |
| 10:28 | AWizzArd | ,(let [d1 (java.util.Date.), d2 (java.util.Date.), m {d1 10}] [(= d1 d2) (identical? d1 d2)]) |
| 10:28 | clojurebot | [true false] |
| 10:29 | AWizzArd | I can not just say [d2 (get m d2)], because I need it to be d1 |
| 10:29 | AWizzArd | (find m d2) ==> [d1 (get m d1)] |
| 10:30 | AWizzArd | hoeck: do you know if find is O(1)? |
| 10:30 | defn | ,(+ 1 2) |
| 10:30 | clojurebot | 3 |
| 10:30 | hoeck | its the same O as get |
| 10:32 | defn | would someone else try the ns-publics thing and see if it behaves the same? |
| 10:32 | AWizzArd | hoeck: ok fine, that makes sense |
| 10:32 | tcrayford | ,(ns-publics 'clojure.core) |
| 10:32 | tcrayford | ,(+ 1 2) |
| 10:32 | defn | k just checking. my nick is 'defn' so i just wanted to make sure that had absolutely nothing to do with it |
| 10:33 | defn | i dont know why it would but well...it's a keyword so |
| 10:33 | tcrayford | defn: have you reported that on clojurebot's repo yet? |
| 10:33 | defn | yeah just did |
| 10:33 | defn | i just wanted it to be properly tested before i reported intermittent lag as an issue |
| 10:34 | tcrayford | its better for people to know about it than not, even if nowt gets done |
| 10:35 | defn | yeah i know that deep in my hacker heart |
| 10:35 | defn | but i still hate being the bearer of bad news :) |
| 10:35 | tcrayford | so that's why you haven't bug reported much on refactoring :P |
| 10:35 | defn | :D |
| 10:36 | defn | you're going to be singing a different tune when you wake up to 100 emails from github tomorrow ;) |
| 10:36 | tcrayford | I'll be happy with that |
| 10:36 | tcrayford | I don't actually use refactoring-mode very much, so I don't see many bugs |
| 10:37 | defn | tcrayford: i cant say i use it /all/ the time -- once there is a minor mode id use it all the time |
| 10:37 | tcrayford | defn: coming right up |
| 10:40 | clojurebot | {sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, chunked-seq? #'clojure.core/chunked-seq?, find-protocol-impl #'clojure.core/find-protocol-impl, vector-of #'clojure.core/vector-of, object-array #'clojure.core/object-array, *compile-path* #'clojure.core/*compile-path*, max-key #'clojure.core/max-key, lis |
| 10:40 | clojurebot | 3 |
| 10:40 | tcrayford | defn: what key are you binding to refactoring-mode's menu? |
| 10:43 | tcrayford | I'm going with "C-c C-r" for the moment |
| 10:43 | tcrayford | defn: see github for a minor mode |
| 10:45 | Licenser | mmarczyk: neat code for the ident thing! |
| 10:46 | tcrayford | Licenser: see the issue on clojurebot regarding ns-publics and clojure.core. Not sure if that's your end or hiredman's though |
| 10:47 | Licenser | tcrayford: hiredmans since he does not use clj-sandbox ;) |
| 10:47 | tcrayford | ah, k |
| 10:47 | tcrayford | we had a 7 minute lag with clojurebot earlier doing that |
| 10:48 | Licenser | oha |
| 10:48 | Licenser | can you try that with sexpbot? |
| 10:48 | tcrayford | not sure how to invoke sexpbot |
| 10:48 | Licenser | $(+ 1 1) |
| 10:48 | sexpbot | result: 2 |
| 10:48 | tcrayford | $(ns-publics 'clojure.core) |
| 10:48 | sexpbot | clojure.core |
| 10:48 | Licenser | $(+ 1 1) |
| 10:48 | sexpbot | result: 2 |
| 10:48 | Licenser | hmm I see no lag |
| 10:48 | tcrayford | that's not even the right result for ns-publics |
| 10:49 | Licenser | :P |
| 10:49 | tcrayford | ,(ns-publics 'clojure.core) |
| 10:49 | tcrayford | (this will take a while) |
| 10:50 | Licenser | hmm it should time out usually |
| 10:50 | tcrayford | doesn't in this case |
| 10:50 | tcrayford | that expression executs instantly at the repl though |
| 10:50 | tcrayford | /s/excuts/executes |
| 10:51 | Licenser | hmm then it will be likely a clojurebot issue |
| 10:51 | tcrayford | yeah, I'll talk to hiredman next time he's aboot |
| 10:51 | tcrayford | though sexpbot fails with it as well (as seen earlier) |
| 10:52 | Licenser | $mail Raynes Why does sexpbot not return the right result for $(ns-publics 'clojure.core)? |
| 10:52 | sexpbot | Message saved. |
| 10:52 | tcrayford | that's neat |
| 10:53 | tcrayford | $mail hiredman Why does clojurebot take ages (but not time out) when running ,(ns-publics 'clojure.core)? |
| 10:53 | sexpbot | Message saved. |
| 10:53 | Licenser | ,(loop [i 1] (recur (inc i))) |
| 10:54 | Licenser | $(loop [i 1] (recur (inc i))) |
| 10:54 | chouser | oops |
| 10:54 | sexpbot | Execution Timed Out! |
| 10:54 | tcrayford | chouser: oops? |
| 10:54 | Licenser | hmm sexpbot times out |
| 10:54 | chouser | $(Thread/sleep 20000) |
| 10:54 | sexpbot | DENIED! |
| 10:54 | Licenser | then again clojurebot isn't back from the ns stuff |
| 10:54 | chouser | *sigh* |
| 10:54 | tcrayford | no its not |
| 10:54 | tcrayford | :/ |
| 10:55 | Licenser | chouser: I wrote that sandbox so simple tricks as sleep don#t work :P |
| 10:55 | chouser | I was thinking that sleep was a gentler test |
| 10:55 | chouser | useful for playing with thread-interaction stuff besides |
| 10:57 | clojurebot | {sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, chunked-seq? #'clojure.core/chunked-seq?, find-protocol-impl #'clojure.core/find-protocol-impl, vector-of #'clojure.core/vector-of, object-array #'clojure.core/object-array, *compile-path* #'clojure.core/*compile-path*, max-key #'clojure.core/max-key, lis |
| 10:57 | chouser | but since you can't use agents or futures either, I guess it doesn't matter. |
| 10:57 | clojurebot | Execution Timed Out |
| 10:57 | tcrayford | that was around 8 minutes again |
| 10:57 | tcrayford | :/ |
| 10:57 | tcrayford | timing out with loop works fine though |
| 10:58 | tcrayford | chouser: do you have any tips for reading on lisp? I've been struggling to understand some of the stuff in there |
| 10:58 | chouser | tcrayford: hm, none that I can think of. Maybe I should try reading it again. |
| 10:58 | tcrayford | did you just read it like a novel? |
| 10:59 | chouser | I think I read it on my palm device. |
| 10:59 | Licenser | tcrayford: I have the feeling that it is a formating thing |
| 11:00 | chouser | which has since died |
| 11:00 | chouser | presumably that's unrelated |
| 11:00 | jweiss | cemerick: i am still trying to figure out what's wrong w my clutch view server. put in some extra debugging to print out stuff - does this mean anything to you: No implementation of method: :read-json-from of protocol: #'clojure.contrib.json/Read-JSON-From found for class: nil |
| 11:00 | tcrayford | chouser: maybe it couldn't handle the power of lisp :/ |
| 11:01 | tcrayford | I have myself a printed copy, which is somewhat better, but its still hard work to actually understand everything |
| 11:01 | Licenser | see you later |
| 11:02 | chouser | toward the end I might have given up trying to understand every example in detail, just trying to understand the gist. It's been a while, I'm not sure. |
| 11:02 | tcrayford | aye, I don't really struggle until he gets to the query compier |
| 11:02 | tcrayford | s/compier/compiler |
| 11:03 | tcrayford | and then the continuations and prolog stuff goes over my head |
| 11:18 | notsonerdysunny | http://clojure.pastebin.com/6ymswkty |
| 11:18 | notsonerdysunny | I am a newbie to clojure and java |
| 11:18 | notsonerdysunny | I am trying to get slime and clojure working |
| 11:19 | notsonerdysunny | I saw the errors and realize that it is not looking for the clojure.jar in the correct directory .. |
| 11:19 | notsonerdysunny | can anybody help me to fix this..? |
| 11:19 | notsonerdysunny | can I take care of this with some java classpath environment variable? |
| 11:21 | Blackfoot | i recommend using lein for setting class path |
| 11:22 | Blackfoot | for example, http://github.com/jochu/swank-clojure |
| 11:22 | Blackfoot | but i have not used swank specifically |
| 11:31 | arohner | did defn get support for destructuring maps in the & args position, or am I crazy? |
| 11:31 | arohner | I'm trying to find documentation / github commit for it, and I can't |
| 11:31 | arohner | aha |
| 11:31 | arohner | http://github.com/richhickey/clojure/commit/29389970bcd41998359681d9a4a20ee391a1e07c |
| 11:32 | notsonerdysunny | Blackfoot: would you be able to help me as to how I could do that..? |
| 11:35 | alpheus | notsonerdysunny: as a total newb, I followed the instructions at http://github.com/jochu/swank-clojure last night with no problems |
| 11:38 | cemerick | the distinction between send and send-off is a little more subtle than blocking vs. nonblocking. I'm finding that using send-off for just about everything is better for my purposes, so as to "oversubscribe" the cores in my compute nodes, thereby ensuring full utilization. |
| 11:38 | alpheus | (doc require) mentions "classpath". Is that the same as the value passed to java in the "-cp" option? |
| 11:38 | clojurebot | "([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents define a library of Cloju |
| 11:39 | cemerick | e.g. if your send fn is a mix of 75/25 CPU/IO, you want three of those running on a 2-core box to max things out |
| 11:39 | cemerick | ...or maybe my thinking here is muddled. |
| 11:39 | cemerick | alpheus: in 99% of the cases, yes |
| 11:42 | alpheus | Thanks. I'm trying to use a clojure image started with lein and require sample code from a book that doesn't mention swank or lein. |
| 11:55 | arkahn | is there a way for a function to 1) create something the first time it's called and 2) have it persist and be available between invocations ? |
| 11:55 | arkahn | specifically, I want to have a file opened and available through function invocations |
| 11:59 | Chousuke | arkahn: put a reference to it in an atom or something |
| 11:59 | arkahn | Chousuke: ok - I wasn't sure what was idiomatic either, but I'll take that route. Thanks. |
| 12:00 | cemerick | a delay would probably be easier -- no explicit checking |
| 12:00 | Chousuke | arkahn: it's not particularly idiomatic. more idiomatic would be creating the file, returning it, and then passing it as a parameter later :P |
| 12:00 | arkahn | Chousuke: I can do that : ) |
| 12:00 | arkahn | cemerick |
| 12:01 | arkahn | : what's a delay? |
| 12:01 | cemerick | ,(doc delay) |
| 12:01 | clojurebot | "([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force or deref/@), and will cache the result and return it on all subsequent force calls." |
| 12:01 | arkahn | sweet |
| 12:02 | cemerick | so, (def some-open-resource (delay (init-resource))), and then just use @some-open-resource in the fn body |
| 12:03 | arkahn | cemerick: I'll check that out - thank you |
| 12:08 | arkahn | delay is interesting but I think I'll create a (BufferedReader. (FileReader. f)) ahead of time and pass that around. |
| 12:12 | alpheus | I expected that after evaluating (def trigger (delay (println "you got me"))) in the repl, I could evaluate trigger without printing anything (until force or deref was used). What's wrong with my understanding? |
| 12:34 | riddochc | Hey, doesn't emacs provide some function like "close-all-open-parens-or-bracets-or-etc" by some different name? Anybody know what that function is? |
| 12:34 | tcrayford | just use paredit and you'll be fine |
| 12:35 | alpheus | There's slime-repl-closing-return |
| 12:54 | bartj | er, are there any libraries to connect to webkit rendering engine using clojure? |
| 12:55 | Raynes | I think I've seen some Java stuff for that. |
| 12:56 | KirinDave | cgrand did a really good job on his most recent blog post. |
| 12:56 | clojurebot | whose job is it to rule the world |
| 13:04 | bartj | KirinDave: link? |
| 13:05 | jfields | why would you use (some identity coll) instead of (seq coll) when determining if there are any elements of coll? |
| 13:05 | jfields | (for example, the impl of merge-with) |
| 13:06 | KirinDave | bartj: http://clj-me.cgrand.net/2010/05/08/destructuring-records-prototypes-and-named-arguments/ |
| 13:06 | sexpbot | "Clojure and me » Destructuring, records, protocols and named arguments" |
| 13:09 | jfields | anyone care to write a (diff ) function that makes this true: (= {:a [100 250] :c [0 300] :d [220 0]} (diff {:a 100 :b 200 :d 220} {:a 250 :b 200 :c 300})) |
| 13:10 | jfields | I'm working on something, but haven't found anything I really like yet |
| 13:10 | cemerick | bartj: there's a gecko java wrapper |
| 13:10 | cemerick | and swt has webkit integration, I think |
| 13:11 | bartj | cemerick: thanks, I check it out |
| 13:12 | stuarthalloway | technomancy: you around? |
| 13:13 | bartj | cemerick: looks like it is jrex |
| 13:13 | cemerick | bartj: there's another one, too...don't remember the name tho |
| 13:16 | bartj | cemerick: I was leaning more towards webkit wrappers |
| 13:18 | stuarthalloway | "lein test" has a crippling perf bug, and I would love to discuss it with someone before pushing the fix |
| 13:18 | stuarthalloway | I'll just explain it then :-) |
| 13:19 | cemerick | bartj: I know that swt has support for using webkit as a backend to its Browser component, but that's as far as my understanding goes. |
| 13:19 | cemerick | there may be other java-webkit wrappers floating around, I have to imagine it's a common inclination |
| 13:20 | stuarthalloway | back in late January, the innocuous looking refactoring commit http://github.com/technomancy/leiningen/commit/a9936d22 causes the entire world to be recompiled between every test |
| 13:20 | bartj | cemerick: I am not actually looking to use a java component to display a webpage on an app |
| 13:20 | cemerick | bartj: what's the use case then? |
| 13:20 | stuarthalloway | this makes tests an order of magnitude slower, and doesn't make sense--code won't change while you are running your tests non-interactively |
| 13:21 | bartj | cemerick: this is for information extraction purposes - the task being getting the size of each rendered HTML element... |
| 13:21 | cemerick | ah, ok |
| 13:22 | bartj | cemerick: ... to deduce their importance and see where they "occur" on the web-page |
| 13:22 | cemerick | I'd certainly hope that a good wrapper would provide a pipe into the DOM, but I can see that being a tall order |
| 13:23 | chouser | I'm using rssowl these days, which appears to be a java app with gecko embedded rather seamlessly. |
| 13:23 | chouser | does that help? :-) |
| 13:25 | chouser | Dunno if it uses this or something else: http://jrex.mozdev.org/ |
| 13:25 | sexpbot | "JRex - The Java Browser Component" |
| 13:27 | bartj | chouser: that was probably rude. Finding a wrapper to a rendering engine is hard. :) |
| 13:29 | bartj | chouser: is rssowl open source? |
| 13:29 | bartj | I think it is definitely possible to use the webkit rendering engine from java because android uses webkit |
| 13:30 | KirinDave | Android also uses jni. |
| 13:37 | stuarthalloway | cemerick: I have submitted a patch for last-var-wins that limits its scope to clojure.core, per discussion here. Mostly happy? |
| 13:37 | cemerick | heh |
| 13:38 | cemerick | stuarthalloway: I'm satisficed, yes. |
| 13:38 | stuarthalloway | good enough for me |
| 13:39 | cemerick | Over time, I really really want to get to the point where ns declarations really are declarative. Not sure what the impl would look like for that, but that instinct remains constant. |
| 13:39 | ninjudd | stuarthalloway: what's a guy gotta do to get access to the assembla spaces? |
| 13:47 | stuarthalloway | ninjudd: lemme check |
| 13:48 | stuarthalloway | ninjudd: it is done |
| 13:49 | ninjudd | stuarthalloway: thanks |
| 13:51 | ninjudd | stuarthalloway: are you the same Stuart Halloway who wrote http://www.amazon.com/Component-Development-Java-TM-Platform/dp/0201753065? |
| 13:51 | sexpbot | "Amazon.com: Component Development for the Java(TM) Platform (9780201753066): Stuart Dabbs Halloway: Books" |
| 13:56 | technomancy | stuarthalloway: it's the :reload-all, isn't it. |
| 13:57 | lpetit | http://www.amazon.com/Stuart-Halloway/e/B002BWYVRI/ref=sr_ntt_srch_lnk_1?_encoding=UTF8&qid=1274464448&sr=1-1 |
| 13:57 | sexpbot | "Amazon.com: Stuart Halloway: Books, Biography, Blog, Audiobooks, Kindle" |
| 13:57 | lpetit | yep, or they are both with the same name and the same face :) |
| 13:59 | technomancy | stuarthalloway: thanks |
| 14:00 | jfields | Is there a function that will, given a map and a pred, return a map with all the entires that pass the pred? |
| 14:02 | alpheus | doesn't map do that? |
| 14:04 | jfields | alpheus: I don't think so. |
| 14:04 | Raynes | $(map (fn [[key val]] [val key]) {:key :val :key2 :val2}) |
| 14:04 | sexpbot | DENIED! |
| 14:04 | Raynes | Uh. |
| 14:05 | Raynes | What could possibly be denied in that. |
| 14:05 | Raynes | $(map (fn [[k v]] [v k]) {:key :val :key2 :val2}) |
| 14:05 | sexpbot | result: clojure.lang.LazySeq@f333e02e |
| 14:05 | Raynes | Oh. |
| 14:05 | Raynes | The key and val functions. |
| 14:05 | Raynes | $(into {} (map (fn [[k v]] [v k]) {:key :val :key2 :val2})) |
| 14:05 | sexpbot | result: {:val2 :key2, :val :key} |
| 14:05 | Raynes | jfields: ^ |
| 14:05 | jfields | raynes, thanks |
| 14:06 | jfields | I think I need filter not map, but the idea is the same. thanks. |
| 14:06 | ninjudd | lpetit: thanks, two clicks was too far for me to find that page on amazon |
| 14:08 | bartj | Raynes: I think clojurebot, sexpbot are not functional |
| 14:09 | bartj | , (+ 1 2) |
| 14:09 | clojurebot | 3 |
| 14:09 | Raynes | bartj: Huh? |
| 14:09 | bartj | , (map (fn [ [key val] ] [val key]) {:key :val :key2 :val2}) |
| 14:09 | clojurebot | ([:val :key] [:val2 :key2]) |
| 14:10 | bartj | Raynes: you need to prefix it with a comma |
| 14:10 | Raynes | I was using sexpbot, not clojurebot. sexpbot is very functional. The only problem is that key and val aren't whitelisted in clj-sandbox, something I'm remedying as we speak. |
| 14:13 | Raynes | And I think I've fixed that damned LazySeq problem. |
| 14:15 | Raynes | Yep, I did. |
| 14:15 | Raynes | $(map (fn [[k v]] [v k]) {:key :val :key2 :val2}) |
| 14:16 | Raynes | $(map (fn [[k v]] [v k]) {:key :val :key2 :val2}) |
| 14:16 | sexpbot | => ([:val2 :key2] [:val :key]) |
| 14:16 | Raynes | spacefail |
| 14:16 | Raynes | :) |
| 14:40 | ninjudd | technomancy: when you get a minute, i have something i wanted to show you |
| 14:43 | ninjudd | technomancy: with regard to leiningen hooks |
| 14:43 | Borkdude | Is there a guide somewhere how to upgrade an elpa installed swank-clojure to the next version? |
| 14:45 | Borkdude | brb |
| 14:46 | Borkdude | my swank-clojure-project doesn't work with a new lein project I just made |
| 14:47 | Borkdude | Emacs just keeps polling and polling |
| 14:47 | lancepantz | Borkdude: swank-clojure is actually deprecated |
| 14:47 | AWizzArd | Anyone here who is pretty familiar with the (current) Java implementation of sorted maps and sets? |
| 14:47 | lancepantz | just use lein swank, then slime-connect |
| 14:48 | rsenior | technomancy: is there any xref setups needed for the slime-who-calls function to work with the latest swank? |
| 14:48 | Borkdude | should I manually add the swank dependency to my project.clj still? |
| 14:49 | Borkdude | if I want to do lein swank |
| 14:49 | Borkdude | Just did a lein upgrade fyi |
| 14:50 | Borkdude | I mean, is there a reason why lein new doesn't add it automatically now? |
| 14:52 | Borkdude | lancepantz: I hope you mean swank-clojure-project |
| 14:55 | Borkdude | hmm, ok, I added it to my dev-dependencies. when I do slime-connect, I get: version differ (slime, swank), do you want to continue? |
| 14:56 | Borkdude | what is that about? |
| 15:02 | lancepantz | Borkdude: i get the same after upgrading in elpa, my guess it's because we're not using the master of lein-swank |
| 15:04 | rsenior | Borkdude and lancepantz I get that as well after the 1.2.1 upgrade |
| 15:05 | Borkdude | in elpa, if I want to upgrade something, like clojure-mode, can I just D the old one and I the new one? |
| 15:07 | rsenior | not sure if it's right or wrong, but I installed the new version, then later went in and removed the old |
| 15:08 | lancepantz | i have to mark it d, then execute, then package-list-packages again and install, but i use aquamacs which may be making it wonky |
| 15:11 | technomancy | lancepantz: there's a bug in package.el that makes it a little awkward; it's fixed in my fork of package.el, but the upstream maintainer is a slacker |
| 15:12 | lancepantz | i see |
| 15:13 | rsenior | technomancy: is there any additional setup needed to use slime-who-calls? beyond the regular slime/swank setup? |
| 15:13 | Borkdude | ah, also upgraded some other things now |
| 15:13 | technomancy | rsenior: shouldn't be |
| 15:13 | rsenior | I am getting a wrong-type-argument error from slime and am wondering if I'm doing something wrong |
| 15:14 | rsenior | let me past the backtrace into gist real quick |
| 15:14 | Borkdude | I upgraded slime also |
| 15:14 | Borkdude | but it still complains about the versions |
| 15:17 | rsenior | unfortunately there's some crazy characters below the 5th line that gist doesn't like, so I removed them http://gist.github.com/409296 |
| 15:18 | Borkdude | how can I see which slime version I'm actually using? |
| 15:27 | lancepantz | do you guys run clojure-mode in your slime repl? |
| 15:27 | lancepantz | when i enable it, enter is a line break instead of return |
| 15:32 | nachtalp | hmm, could anybody give me a clue why this doesn't succeed in extracting values from a map given a vector of keys? http://www.pastie.org/971576 |
| 15:36 | rsenior | nachtalp: your code works for me |
| 15:38 | Borkdude | nachtalp: also works here |
| 15:41 | nachtalp | rsenior, Borkdude: thanks, i just found out that it works for me in a fresh repl as well... strange, i thought i had my problem isolated... |
| 15:47 | Borkdude | still no clue, what version differ means when I do slime-connect, it mentions a version nr that is different from my slime, if I did the upgrade correct, that is |
| 15:52 | patrkris | rhickey: you there? |
| 15:52 | rhickey | yes |
| 15:53 | patrkris | rhickey: can I disturb you with a few questions about clojure's stm? :) |
| 15:53 | rhickey | maybe |
| 15:53 | rhickey | :) |
| 15:54 | patrkris | rhickey: thanks! just wanted to make sure I understand exactly why clojure's stm is obstruction-free. I have a theory and just want you to say yes or no to whether that (in part) makes it not-obstruciton-free. |
| 15:54 | rhickey | it's not obstruction free |
| 15:54 | Fossi | that was an easy answer |
| 15:55 | patrkris | rhickey: yes, I know. But I just wanted to make sure that I understand what makes it not obstruction-free. |
| 15:55 | patrkris | rhickey: One reason is that writing setting a ref during a transaction takes a lock on the ref, yes? |
| 15:56 | rhickey | all the locking and blocking are obstructions |
| 15:56 | patrkris | rhickey: well maybe more generally that Clojure's STM employs locks, which may cause other transactions to block and retry (bail). |
| 15:57 | patrkris | ok yes |
| 15:58 | patrkris | rhickey: well, thanks then :) I was just confused by the definition of obstruction-freedom and why clojure is not obstruction-free. I know I shouldn't be, but I'm born with a small brain. |
| 16:02 | Borkdude | does Clojure have a function that composes the or of two functions that take the same kind of args? like (or-comp f1 f2) => (fn [args] (or (f1 args) (f2 args)))? |
| 16:02 | AWizzArd | rhickey: Hi! I was looking for someone who is familiar with the implementations of sorted sets and maps, and just saw that you are here. Do you see an “easy way” to implement a mechanism to construct a sorted set/map much faster, by bypassing the sorting mechanism, when we can insert in already the correct order? |
| 16:04 | rhickey | AWizzArd: the sorted sets/maps are red-black trees. any literature on building them from sorted might apply |
| 16:07 | AWizzArd | okay |
| 16:26 | remleduff | Borkdude: My attempt is (defn or-comp [args & fns] (let [f (apply juxt fns)] (some true? (f args)))) ;) |
| 16:29 | Borkdude | remleduff, is juxt lazy? |
| 16:30 | Borkdude | I mean, is the result it returns a lazy seq, so it won't actually evaluate all the fns? |
| 16:30 | remleduff | No, I don't think so |
| 16:33 | remleduff | OK, take 2 :). (defn or-comp [args & fns] (let [results (for [fn fns] (fn args))] (some true? results))) |
| 16:35 | remleduff | OK, take 2 :). (defn or-comp [args & fns] (let [results (for [fn fns] (fn args))] (some (complement nil?) results))) |
| 16:35 | remleduff | I wish there was a truthy? function |
| 16:39 | Borkdude | remleduff: how am I supposed to provde the args, in a vector? |
| 16:39 | AWizzArd | why not (some #(% arg1 arg2) [fn1 fn2 fn3 fn4]) ? |
| 16:39 | AWizzArd | instead of or-comp |
| 16:39 | Borkdude | brilliant |
| 16:40 | remleduff | Because I was stuck in the "answering his question" mental space ;) |
| 16:41 | Borkdude | AWizzArd: but can I make a version of or-comp, without specifying the args? |
| 16:42 | Borkdude | (defn or-comp [fns] (apply some #(% ...) fns)) |
| 16:42 | remleduff | If you're ok with putting multiple args in a vector or something, do that then do (apply fn args) |
| 16:43 | Borkdude | I can do (comp f1 f2) without saying what the args of f1 and f2 are |
| 16:43 | Borkdude | I should also be able to do this with or-comp |
| 16:44 | bmason | I think I'm not understanding something about importing java classes... |
| 16:44 | bmason | I searched jarvana for the class I want to use, I found the correct package and got that set up as a lein dependency |
| 16:45 | AWizzArd | you can #(apply % args) or if you have not args you can use %& |
| 16:45 | bmason | it's pulling the jar down into libs, but I'm still not able to (import 'classname) from clojure... |
| 16:46 | AWizzArd | bmason: do you do (import 'ClassName) or (import 'the.package.name.ClassName) ? |
| 16:46 | bmason | (import 'javax.mail.internet.MimeMultipart) |
| 16:46 | AWizzArd | What happens after you typed this? |
| 16:46 | Borkdude | AWizzArd: how would you write comp-or then? |
| 16:46 | remleduff | Aha: (defn or-comp [& fns] (fn [& args] (some #(apply % args) fns))) |
| 16:47 | bmason | class not found |
| 16:47 | AWizzArd | bmason: then this class is indeed not on your CP. Have a look at (System/getProperty "java.class.path") |
| 16:47 | AWizzArd | Borkdude: I would not write it, but what remleduff presented looks fine. |
| 16:48 | Borkdude | AWizzArd: then I would still have to specify the args |
| 16:48 | AWizzArd | not at the moment when you call or-comp |
| 16:49 | AWizzArd | what remleduff showed you is something that produces a fn |
| 16:49 | bmason | AWizzArd: indeed, there is no mention of javax at all in my classpath |
| 16:49 | AWizzArd | (def your-or-fn (or-comp + - * /)) |
| 16:49 | AWizzArd | And later you could (your-or-fn 10 20 30) |
| 16:49 | bmason | AWizzArd: my project.clj has [javax/javaee-api "6.0"] under dependencies and it's successfully copying this from a repo to my libs folder... |
| 16:50 | AWizzArd | bmason: the expert for Leiningen is technomancy. |
| 16:50 | Borkdude | AWizzArd: maybe I missed something but remleduff 's or-comp takes args as an argument |
| 16:50 | bmason | AWizzArd: k :) |
| 16:50 | clojurebot | haskell is Yo dawg, I heard you like Haskell, so I put a lazy thunk inside a lazy thunk so you don't have to compute while you don't compute. |
| 16:51 | remleduff | Borkdude: The anonymous function that is returned by or-comp takes args, you don't need them when just calling or-comp |
| 16:51 | bmason | clojurebot is funny guy today |
| 16:51 | technomancy | bmason: is there a javax/mail/internet/MimeMultipart.class inside one of the jars in the lib directory? |
| 16:51 | AWizzArd | As I see it remleduffs or-comp takes fns |
| 16:51 | AWizzArd | not args |
| 16:51 | Borkdude | remleduff: which version are we talking about, can you type it again? |
| 16:51 | remleduff | (defn or-comp [& fns] (fn [& args] (some #(apply % args) fns))) |
| 16:52 | Borkdude | ah ok I think I indeed missed that one... sorry! |
| 16:52 | bmason | technomancy: will check |
| 16:52 | Borkdude | that version does indeed look fine, tnx remleduff and AWizzArd :) |
| 16:53 | bmason | technomancy: yes, that path exists inside the jar "java-api-6.0.jar" which is in my lib directory |
| 16:55 | bmason | technomancy: ok, I may not have properly reloaded the environment... now I get "Absent Code attribute in method that is not native or abstract in class file javax/mail/internet/MimeMultipart" when I do (import 'javax.mail.internet.MimeMultipart) |
| 16:56 | bmason | which I think means I'm missing a dependency... |
| 16:56 | AWizzArd | After the import, when you just type MimeMultipart in the repl it should return javax.mail.internet.MimeMultipart if the import worked. |
| 16:57 | bmason | yeah, the import is throwing an exception though... have to fix that first |
| 16:58 | bmason | technomancy: incidentally, is there a way to restart swank/slime with 1 command? right now adding a dependency is a multiple step process for me |
| 16:59 | AWizzArd | maybe javax.mail needs this support class? I don't remember it, on my system I can import that Multipart class |
| 17:00 | bmason | AWizzArd: http://dominikdorn.com/2010/05/maven-junit-classformaterror-absent-code-attribute/ |
| 17:00 | sexpbot | "Maven + JUnit + ClassFormatError: Absent Code attribute in method that is not native or abstract in class file | dominikdorn.com" |
| 17:00 | drewr | urg |
| 17:00 | danlarkin | ugh is right |
| 17:01 | danlarkin | no one likes those stupid link titles |
| 17:01 | AWizzArd | just /ignore sexpbot then ;) |
| 17:02 | bmason | ok... now adding javax/mail as a dep, I still get the absent code attribute error |
| 17:02 | bmason | how do I figure out what it needs? |
| 17:03 | remleduff | javax/mail or javax.mail/mail ? |
| 17:04 | bmason | [javax.mail/mail "1.4.1"] |
| 17:05 | bmason | it seems like voodoo magic to find the dependency with an error message like that |
| 17:06 | remleduff | Does java -verbose help at all? |
| 17:07 | bmason | hmm... how would I use that in context of a slime repl? |
| 17:08 | remleduff | I think you can do JAVA_OPTS=-verbose before you do lein swank |
| 17:08 | remleduff | It may not be any help at all though |
| 17:10 | bmason | remleduff: you mean like this? http://www.javalobby.org/java/forums/t76635.html |
| 17:10 | sexpbot | "Overwrite java parameters with environment variables or other mechanism???" |
| 17:11 | bmason | technomancy: does swank use the JAVA_OPTS variable when it starts the clojure repl? |
| 17:12 | bmason | that's great if it does... that would help me attach a JSwat session to it :) |
| 17:12 | technomancy | it does |
| 17:12 | bmason | SWEET |
| 17:13 | bmason | noted :) |
| 17:13 | technomancy | you can also set :java-opts in project.clj if you want them to apply to everyone using your project |
| 17:13 | technomancy | but it forces the JVM to fork, so you pay a perf price |
| 17:14 | bmason | oh, that's good to know |
| 17:20 | bmason | ok, so now I'm trying (import 'javax.mail.Multipart) and I get the absent code attribute error here as well |
| 17:21 | bmason | weird thing is, I thought that message had to do with a superclass not being imported... javax.mail.Multipart derives directly from java.lang.Object |
| 17:29 | remleduff | Did you restart swank after you added javax.mail to your project? |
| 17:29 | remleduff | bmason: ^^ |
| 17:30 | bmason | I'm sure I... lemme double check :) |
| 17:31 | bmason | remleduff: yeah, that's not the issue |
| 17:32 | bmason | I'm reading up more about what the error actually means |
| 17:32 | remleduff | Possibly, the problem is that javax.mail needs to be loaded _before_ javaee-api |
| 17:33 | remleduff | But lein I think just looks at the order the jar files are in your lib directory when adding them to the classpath |
| 17:34 | remleduff | So try renaming mail-1.4.1.jar to something like 00mail-1.4.1.jar to see if it helps |
| 17:35 | bmason | ok, I think the issue may be the jar I got |
| 17:35 | bmason | apparently there are some jars floating around in MVN repos that only have the API stubbed out, with no implementation: http://weblogs.java.net/blog/ludo/archive/2007/01/java_ee_5_apis.html |
| 17:35 | sexpbot | "Java EE 5 APIs now in a Maven repository... | Java.net" |
| 17:35 | remleduff | That's not confusing |
| 17:35 | bmason | oh no, not at all |
| 17:36 | bmason | and it's its not like I've wasted several days trying to figure it out either |
| 17:36 | bmason | nor am I bitter... moving on :) |
| 17:36 | remleduff | haha |
| 17:37 | bmason | I guess I need to find out what the correct jars are then |
| 17:37 | bmason | http://jarvana.com/jarvana/search?search_type=class&java_class=javax.mail.internet.MimeMultipart |
| 17:37 | sexpbot | "javax.mail.internet.MimeMultipart - Class Search - Jarvana" |
| 17:37 | bmason | pretty big list to go through, and I'm not familiar with java conventions |
| 17:38 | danlarkin | I hate you sexpbot!!!!! |
| 17:39 | bmason | what was the point of those titles? |
| 17:39 | bmason | just to give people context on links? |
| 17:39 | AWizzArd | bmason: you should ask Raynes (: |
| 17:39 | bmason | :D |
| 17:40 | remleduff | bmason: The way I read it, those classes are provided by whatever application server your service runs in |
| 17:40 | remleduff | The jars you have are just stubs to allow it to compile, you can't actually use it outside of something like glassFish or BEA Weblogic |
| 17:41 | bmason | remleduff: that makes sense I suppose... but I need something to do development with |
| 17:42 | bmason | so the question is where do I find a complete implementation |
| 17:43 | bmason | anyone know what "plugin" means in the context of maven repos? |
| 17:43 | bmason | all the jetty stuff has plugin icons next to it... maybe that means it's a full implementation |
| 17:51 | remleduff | Actually, I think javax.mail is a complete implementation. It's the javaee-api that is stubs |
| 17:51 | remleduff | But you probably actually have to run a web server and deploy to it to do testing |
| 17:51 | bmason | sweet |
| 17:51 | bmason | yeah I got it |
| 17:52 | remleduff | What did you do, remove javaee-api entirely? |
| 17:52 | bmason | javax.mail has what I need, but the javaee-api stubs were overriding them |
| 17:52 | bmason | yeah, I just removed javaee-api |
| 17:53 | remleduff | This is why "enterprise Java" has always seemed like such a strange goal to strive for to me ;) |
| 17:53 | bmason | :-D |
| 17:54 | bmason | yeah... I plan to get more into Java |
| 17:54 | bmason | easy way to get a day job, and it will have fringe benefits for my clojure programming |
| 17:55 | bmason | cus yeah... things are a little rough around the edges |
| 18:11 | defn | ,(ns-publics 'clojure.core) |
| 18:11 | defn | ,(+ 1 2) |
| 18:11 | lancepantz | rejected. |
| 18:11 | defn | nah, i submitted an issue on this earlier today but hiredman just closed it with no comment |
| 18:11 | defn | his bot, i guess |
| 18:12 | lancepantz | ,(println "hi") |
| 18:12 | defn | it'll come back in about 5min or so |
| 18:12 | lancepantz | ns-publics crashes it? |
| 18:12 | lancepantz | atleast it doesn't barf a bunch of exceptions to the channel :) |
| 18:12 | defn | nah, not a crash, just very slow to return for some odd reason |
| 18:12 | lancepantz | hmm |
| 18:15 | defn | any second now... |
| 18:19 | clojurebot | {sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, chunked-seq? #'clojure.core/chunked-seq?, find-protocol-impl #'clojure.core/find-protocol-impl, vector-of #'clojure.core/vector-of, object-array #'clojure.core/object-array, *compile-path* #'clojure.core/*compile-path*, max-key #'clojure.core/max-key, lis |
| 18:19 | clojurebot | hi |
| 18:19 | clojurebot | 3 |
| 18:27 | scottj | What's required to make a runnable jar with lein? I mean, do you create a -main function, lein jar, and then java -cp foo.jar what-class-goes-here? |
| 18:28 | AWizzArd | scottj: read about jar files, specifically the manifest file |
| 18:28 | AWizzArd | when you mention the right main class there you can simply do java -jar foo.jar |
| 18:28 | AWizzArd | or doubleclick the .jar |
| 18:31 | technomancy | scottj: set the ns containing the -main function as :main in project.clj, then do lein uberjar |
| 18:31 | defn | scottj: also note that you want to use the standalone.jar |
| 18:31 | defn | since it includes clojure |
| 18:32 | Raynes | bmason: Indeed, to give context on those links. sexpbot has pretty sophisticated url scraping, in order to make it suitable for channels like this one. It doesn't follow github or paste links and such. |
| 18:34 | Raynes | danlarkin: He's pretty fond of you. You've broken his heart. |
| 18:34 | bmason | lol |
| 18:34 | sexpbot | danlarkin: </3 :( |
| 18:34 | stribb | hi there |
| 18:35 | stribb | I'm still very much learning my way around clojure.core and wondered if you were willing to critique this line? I want it to be idiomatic (and ideally shorter) |
| 18:35 | stribb | http://pastebin.org/262500 |
| 18:37 | stribb | that is, (apply str (cons \newline (flatten (interpose \+(repeat 3 (repeat (* width 3) \-))))) |
| 18:38 | Raynes | $(apply str (cons \newline (flatten (interpose \+(repeat 3 (repeat (* width 3) \-))))) |
| 18:38 | sexpbot | EOF while reading |
| 18:38 | Raynes | $(apply str (cons \newline (flatten (interpose \+(repeat 3 (repeat (* width 3) \-)))))) |
| 18:38 | sexpbot | DENIED! |
| 18:38 | stribb | oops, maybe add another right paren |
| 18:39 | Raynes | Probably width. |
| 18:39 | Raynes | $(apply str (cons \newline (flatten (interpose \+(repeat 3 (repeat (* 5 3) \-)))))) |
| 18:39 | sexpbot | => "\n---------------+---------------+---------------" |
| 18:39 | Raynes | Yep. |
| 18:40 | stribb | to my eyes it's so full of lispisms that it hides the meaning. apply, flatten, cons are obscuring the thing I'm trying to show |
| 18:41 | stribb | I'm translating http://norvig.com/sudoku.html and here's the relevant line in Python |
| 18:41 | sexpbot | "Solving Every Sudoku Puzzle" |
| 18:41 | stribb | line = '\n' + '+'.join(['-'*(width*3)]*3) |
| 18:41 | danlarkin | sexpbot: your html parsing is so impressive |
| 18:42 | joshua-choi | Question: Is there a function for forcing a lazy sequence to fully evaluate? (I need to do this because resolve uses a re-bind-ed var.) |
| 18:42 | moshisushi | it's not possible to do pattern matchin (out-of-the-box, that is) in clojure, right? |
| 18:42 | Raynes | danlarkin: When I said sophisticated, I was referring to the blacklisting. :p |
| 18:43 | joshua-choi | moshisushi: Clojure has support for Java's regular expressions. The literal syntax is #"...". |
| 18:43 | Raynes | I need to get around to writing in something that checks the title and URL for similarities, in case of redundant titles. |
| 18:43 | remleduff | joshua-choi: doall ? |
| 18:44 | joshua-choi | remleduff: Eh. I need the whole evaluated sequence, not to do some side effect. |
| 18:44 | moshisushi | joshua-choi: hum.. i mean pattern matching as in Haskell / ML |
| 18:44 | pjstadig | ~meap |
| 18:44 | clojurebot | Manning missed the opportunity to call it Manning Early Access Trial |
| 18:44 | joshua-choi | moshisushi: Ah. Don't know as much about that. Clojure does have destructuring in let and let-like forms, though. |
| 18:46 | joshua-choi | remleduff: I am super frustrated, because I found that the source of a bug I've been searching for the past four hours is because 1. map is lazy and 2. resolve uses *ns*. If you have (map resolve vars) in one namespace and happen to evaluate the sequence in another, you will get a lot of strange NullPointerExceptions. :( |
| 18:46 | remleduff | doall is intended to do that, it returns the fully realized sequence |
| 18:46 | Raynes | $learn meap http://www.manning.com/fogus/ |
| 18:46 | sexpbot | My memory is more powerful than M-x butterfly. I wont forget it. |
| 18:47 | joshua-choi | remleduff: Oh, does it? Excellent. I confused it with doseq. |
| 18:47 | joshua-choi | I'm still seething about that bug though |
| 18:47 | remleduff | Yeah, a lot of people have been caught by map and for being lazy |
| 18:47 | remleduff | Worth it in the end though |
| 18:48 | Borkdude | maybe it should be called smth with "force" |
| 18:48 | Borkdude | it's the first thing I would search for |
| 18:48 | Borkdude | force-all |
| 18:49 | joshua-choi | remleduff: No, I don't have a problem at all with lazy map; I love it. My problem is much more with binding-context-sensitive resolve. Functions that depend on variables are a huge source of accidental complexity in Clojure. :( |
| 18:49 | joshua-choi | Oh well, I'm just glad I figured it out. :) |
| 18:49 | joshua-choi | (And when I say "functions that depend on variables", I mean mutable variables to be bound.) |
| 18:50 | remleduff | Yeah, I think binding is my current uncertainty with clojure |
| 18:51 | remleduff | Your other option if you had wanted to keep laziness is to do (let [*ns* *ns*] (map... etc)) |
| 18:52 | joshua-choi | Yeah. I'm thinking that I probably want to not use resolve at all if I can help it |
| 18:52 | remleduff | Borkdude: force is already with delay (which I've not used yet) |
| 18:54 | duncanm | hmm, i'm running jvisualvm on a batch job that i wrote in clojure |
| 18:54 | duncanm | the loaded class count just keeps going up and up |
| 18:54 | duncanm | is that a good thing? bad thing? |
| 18:54 | remleduff | Do you use "eval" a lot? |
| 18:55 | remleduff | If the class count goes up and not down, you can run out of PermGen |
| 18:55 | clojurebot | AOT genclass is http://paste.lisp.org/display/70665 and http://clojure-log.n01se.net/date/2008-11-18.html#14:19 |
| 18:55 | stribb | bah, I hate my broadband |
| 18:55 | duncanm | remleduff: i don't use any eval |
| 18:55 | Borkdude | remleduff: that's true, but there is some similarity between lazy seq and delay/force maybe? |
| 18:56 | Borkdude | I only just read about it |
| 18:56 | remleduff | gotta run, later all, happy weekend :) |
| 18:56 | duncanm | hmm |
| 18:56 | Borkdude | ok bye remleduff |
| 19:01 | danlarkin | $((fn this [] (try :foo (finally (this))))) |
| 19:01 | sexpbot | Execution Timed Out! |
| 19:02 | pjstadig | $meap |
| 19:02 | sexpbot | Command not found. No entiendo lo que estás diciendo. |
| 19:02 | pjstadig | $recall meap |
| 19:02 | sexpbot | Command not found. No entiendo lo que estás diciendo. |
| 19:02 | danlarkin | ((fn this [] (try :foo (finally (this))))) |
| 19:02 | danlarkin | ((fn this [] (try :foo (finally (this))))) |
| 19:03 | danlarkin | $((fn this [] (try :foo (finally (this))))) |
| 19:03 | danlarkin | $((fn this [] (try :foo (finally (this))))) |
| 19:03 | danlarkin | $((fn this [] (try :foo (finally (this))))) |
| 19:03 | danlarkin | $((fn this [] (try :foo (finally (this))))) |
| 19:03 | sexpbot | Execution Timed Out! |
| 19:03 | sexpbot | Execution Timed Out! |
| 19:03 | sexpbot | Execution Timed Out! |
| 19:03 | sexpbot | Execution Timed Out! |
| 19:04 | KirinDave | ... |
| 19:05 | KirinDave | poor sexpbot |
| 19:05 | Raynes | He's spammed it in PM, and got it stuck in a loop. |
| 19:05 | danlarkin | poor us to have to suffer its link titling! |
| 19:05 | Raynes | Eh? |
| 19:05 | stribb | ok, cheerio chaps |
| 19:06 | Raynes | More people like it or don't mind it than people dislike it. |
| 19:07 | pjstadig | i think the link titling is a bit spamish |
| 19:07 | Raynes | How so? |
| 19:07 | bmason | Raynes: or they just don't want to hurt sexpbot's feelings |
| 19:07 | Raynes | Not nearly enough links are posted in here, and the titles aren't nearly long enough to be "spamish". |
| 19:07 | pjstadig | if i want to see a title, i will click on the link |
| 19:08 | pjstadig | usually there is enough context when someone posts a link to know what it is about |
| 19:08 | Borkdude | as long as it's not doing ads, I'm find with the titles... and it saves me a click if the title doesn't sound interesting to me |
| 19:08 | Raynes | If people want it off, I'll happily turn it off, but several people have told me it's useful in here, and that's why it's on. |
| 19:08 | AWizzArd | you can just /ignore the bot |
| 19:08 | Raynes | If rhickey wants it off, I'll turn it off. I'm not unfair. |
| 19:08 | bmason | :-) |
| 19:08 | pjstadig | people want it off |
| 19:08 | Raynes | It just doesn't seem to bother anyone. :\ |
| 19:08 | Raynes | Until now anyway. |
| 19:09 | Raynes | pjstadig: I mean more than two. |
| 19:09 | Raynes | Or Rich. Rich is more than two. |
| 19:09 | pjstadig | how many? |
| 19:09 | Raynes | In a poll, the person with the most votes wins. |
| 19:09 | pjstadig | we'll get a petition |
| 19:09 | bmason | lol |
| 19:09 | Raynes | Go for it. |
| 19:09 | scgilardi | polling is not idiomatic in clojure |
| 19:10 | Borkdude | Raynes: why don't you make $upvote title, when it's positive, the titles appear ;) |
| 19:10 | pjstadig | first you have to tell me how many we need to get |
| 19:10 | Borkdude | and of course $downvote title |
| 19:10 | bmason | maybe it will be a lazy poll |
| 19:10 | Raynes | pjstadig: 15-20. Even chouser said he doesn't mind it/hasn't formed an opinion. |
| 19:10 | Raynes | You aren't actually going to start a petition, are you? |
| 19:11 | duncanm | i know how to write Scheme macros, but i don't know them in Clojure |
| 19:11 | duncanm | i'm tyring to write a macro so that (write some-form-here) expands into (.add writer some-form-here) |
| 19:11 | bmason | (defmacro name form) |
| 19:11 | bmason | ,(doc defmacro) |
| 19:11 | clojurebot | "([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Like defn, but the resulting function name is declared as a macro and will be used as a macro by the compiler when it is called." |
| 19:11 | duncanm | i tried macroexpanding to test, how do i make sure i get the binding of 'writer' correctly? |
| 19:12 | duncanm | i want it to bind to the local binding of 'writer', not some global binding |
| 19:12 | zakwilson | The docs for defmacro are not very helpful for someone not familiar with CL-style macros. |
| 19:12 | bmason | is writer a stream? |
| 19:12 | pjstadig | i'm not sure we need two bots in here |
| 19:12 | pjstadig | maybe we should have a bot cage fight |
| 19:12 | Raynes | I'll also point out that clojurebot has some rather random comments sometimes. At least sexpbot's are useful to /some/ people. ;) |
| 19:13 | duncanm | bmason: it's an XMLEventWriter |
| 19:13 | Raynes | sexpbot has been here for like 2 months. :\ |
| 19:13 | pjstadig | so you're saying that clojurebot's comments are not useful to anyone? |
| 19:13 | Borkdude | duncanm: (defmacro dude [w f] `(.add ~w ~@ f)) ? |
| 19:14 | Borkdude | sorry, no space between ~@ and f |
| 19:14 | Raynes | pjstadig: I'm talking about the comments that aren't invoked purposely. clojurebot says stuff when people say certain things. If we're going to have this conversation, come to #clojure-casual so we stop disrupting conversation here. :( |
| 19:14 | bmason | yeah, Borkdude's suggestion would work if you want to provide the writer as an argument |
| 19:14 | duncanm | Borkdude: i don't want to explicitly pass the 'w' |
| 19:15 | duncanm | bmason: i have (let [writer ..., write #(.add writer %)] ...) in my code right now |
| 19:15 | duncanm | and i think that #(...) is generating a lot of unnecessary code, cuz this is being called inside a loop |
| 19:15 | bmason | so you're saying a var bound in the surrounding context isn't available? |
| 19:15 | danlarkin | no dudes come to #clojure-awesome |
| 19:15 | danlarkin | it's way better |
| 19:16 | AWizzArd | duncanm: btw, you can add a type hint there |
| 19:16 | duncanm | AWizzArd: but that same Fn will still get generated every time, right? |
| 19:16 | bmason | oh, well "let" doesn't do a binding... that may be your problem |
| 19:16 | AWizzArd | yes |
| 19:17 | Raynes | danlarkin: Thanks for clojure-json by the way. sexpbot uses it all over the place. <3 |
| 19:17 | Borkdude | wasn't &env invented for this problem? |
| 19:19 | bmason | danlarkin: might be easier to see what you're doing with a full example |
| 19:20 | hiredman | ~foo |
| 19:20 | clojurebot | foo is is Short, Self Contained, Correct (Compilable), Example http://sscce.org/ |
| 19:24 | remleduff | $eval *ns* |
| 19:24 | sexpbot | DENIED! |
| 19:24 | Raynes | I hate that "Hey, you can't change your nick until you identify" but you can't identify until you change your nick. |
| 19:26 | remleduff | joshua-choi: I think I lied earlier about (let [*ns* *ns*]...) actually doing anything you'd want |
| 19:28 | remleduff | That's fine if you're using *ns* locally, but wouldn't have any effect when calling resolve |
| 19:49 | kencausey | I don't suppose anyone has any idea if it is possible to run a clojure/compojure app under GoDaddy basic web hosting? The mention Java in some places, JSP in others, I'm not much of a Java guru and am not clear on whether I would be able to run a clojure app in the environment. Anyone have any experience here? |
| 19:54 | lancepantz | kencausey: http://help.godaddy.com/article/67 |
| 19:54 | sexpbot | "Can I deploy my application using a war file? - Search the Go Daddy Help Center" |
| 19:55 | lancepantz | looks like you better have it how you want it at 1am, messed up |
| 19:58 | kencausey | thanks, am I safe in assuming they have new enough versions for it to work? they tend to lag a bit |
| 20:00 | lancepantz | yeah, build a war file that complies with the servlet spec and it shouldn't be a problem |
| 20:01 | lancepantz | i have a basic example with compojure 0.4 on github, http://github.com/lancepantz/lein-war-example |
| 20:01 | kencausey | ok, thanks |
| 20:25 | _brian2_ | noob question> Hi , I'm trying to grok the relationship between handlers and routes in compojure, ( http://clojure.pastebin.com/rijB4Fag ) according to the author the new compojure defers handlers to Ring, but uses routes, which do more or less the same thing, (returning a response map), however as far as I can tell, you cant call a handler function in a route |
| 20:41 | joshua-choi | remleduff: Yeah, I figured as much. I would really like someone close to Hickey to write how binding's large disadvantages don't outweigh whatever advantages it does give. But now I think I'll watch out for this error better. |
| 20:58 | remleduff | _brian2_: Which are you calling a handler and which are you calling a route? |
| 20:59 | _brian2_ | on the pastebin, app is the handler, and defroutes are routes, as I undersand it |
| 21:02 | remleduff | handlers take a request map, and return a response map. defroutes, returns a handler. The route macros return various things and has a multimethod that can format it into a response map, but they don't use straight ring maps |
| 21:03 | remleduff | You could wrap! your routes with app though in your example |
| 21:04 | remleduff | But you'd only get hello world after that ;0 |
| 21:04 | remleduff | There's a #compojure channel as well |
| 21:04 | _brian2_ | oh, cool! |
| 21:09 | _brian2_ | remleduff : at first, (I probably need to read more about the request map), but I just want to send user input into a database retrieval function |
| 21:10 | _brian2_ | Its just 10 categories of finite responses I was going to use routes, but thats probably not the best way |
| 21:10 | _brian2_ | ? |
| 21:10 | remleduff | Ring works by having a list of handlers, they each get a shot at the request map and return a response map if they want to handle it |
| 21:10 | remleduff | defroutes abstracts that, the (GET) macro returns a handler |
| 21:13 | _brian2_ | ok, but like (GET "/" [] app) ; where 'app' is handler compojure doesn't seem to like this |
| 21:14 | remleduff | GET creates handlers |
| 21:14 | remleduff | It doesn't call them |
| 21:14 | _brian2_ | ok |
| 21:16 | _brian2_ | so I can call a an ordinary function (GET "/" [] funct[state1] ) ? |
| 21:17 | _brian2_ | that returns some renedring? |
| 21:17 | _brian2_ | rendering |
| 21:17 | remleduff | Yep |
| 21:18 | _brian2_ | oh, ok. Thanks! |
| 21:19 | _brian2_ | remleduff : thank you |
| 22:11 | lancepantz | alexyk: jiraph is now using lein and on clojars |
| 22:16 | remleduff | Do you know of a good tutorial about graph databases, including when you'd want to use one? |
| 22:18 | alexyk | lancepantz: awesome! you guys won |
| 22:19 | alexyk | t believe which other functional language supports tokyo cabinet and google protocol buffers too |
| 22:19 | alexyk | :) |
| 22:20 | lancepantz | remleduff: ignoring the implementation, http://neo4j.org/doc/ has some good resources |
| 22:20 | sexpbot | "neo4j open source nosql graph database » Documentation" |
| 22:20 | alexyk | lancepantz: I was thinking of using the interoperable format to speed up huge walks, and looked for a compiled language with both bindings |
| 22:20 | alexyk | alas ocaml has neither |
| 22:20 | lancepantz | remleduff: this one is informative http://dist.neo4j.org/neo-technology-introduction.pdf |
| 22:21 | alexyk | but some language git them :) |
| 22:21 | alexyk | got them |
| 22:21 | lancepantz | remleduff: note that jiraph has different pros and cons than neo4j, namely that it does not support transactions and is roughly 10x faster than the benchmarks published |
| 22:22 | alexyk | jiraph rocks |
| 22:22 | remleduff | Thanks :) |
| 22:22 | lancepantz | alexyk: c++ :) |
| 22:22 | alexyk | lancepantz: well, that's like an assembly... FP! |
| 22:23 | alexyk | some formidable and glorious language! |
| 22:23 | alexyk | to which we all aspire to |
| 22:23 | lancepantz | hahaha |
| 22:23 | alexyk | when we're not going drinking |
| 22:23 | alexyk | ok it's Haskell |
| 22:23 | alexyk | and it just got an LLVM back end which makes it numerically beat C |
| 22:24 | alexyk | so I'll need to teach Haskell to read map and set extensions and then it'll eat jiraphs for breakfast |
| 22:24 | alexyk | first I need to learn it though :) |
| 22:24 | alexyk | I like interop |
| 22:25 | lancepantz | alexyk: it has tc and protobuf support? |
| 22:25 | alexyk | lancepantz: yep! |
| 22:25 | alexyk | http://hackage.haskell.org/package/tokyocabinet-haskell |
| 22:25 | alexyk | http://hackage.haskell.org/package/protocol-buffers |
| 22:26 | alexyk | the protobufs understand extensions, but I guess I need to teach it what map and set are |
| 22:27 | alexyk | lancepantz: so I guess geni will run on HAppS stack soon :) |
| 22:27 | alexyk | and be hosted at patch-tag.com :) |
| 22:28 | lancepantz | hahaha |
| 22:28 | lancepantz | haskell just looks like gobldey gook to me |
| 22:34 | alexyk | but, liebke joined! :) |
| 23:04 | riddochc | Opinions requested: which of the editors with Clojure support *least* requires the use of a keyboard? |
| 23:07 | riddochc | I tried emacs again yesterday for the first time in a few years, and it just isn't very accessible for someone who's mostly limited to using pointer-based interfaces. |
| 23:11 | riddochc | Oh, well. Trying netbeans+enclojure now... |
| 23:17 | bmason | if I have a java object with methods getCount and getPart(n) is there an idiomatic way to convert the parts to a sequence? |
| 23:19 | bmason | e.g. in java it would be for (i = 0; i < obj.getCount(); i++) {obj.getPart(i);} |
| 23:19 | bmason | I'd prefer not to have to iterate a variable, but it looks like that's the interface I'm given... |
| 23:20 | riddochc | bmason: I'd probably make loop/recur returning a lazy-seq, given the lack of any other iterator over your collection. |
| 23:21 | bmason | k |
| 23:28 | riddochc | Alternatively... hm. you could (map #(.getPart %) (range ...)) |
| 23:29 | riddochc | Or something similar, mapping over the seq of numbers up to .getCount. |
| 23:55 | bmason | riddochc: I like that |