#clojure logs

2010-11-08

00:41zakwilsonAre there Conj videos yet?
00:46cemerickzakwilson: http://twitter.com/#!/stuartsierra/status/544111341871105
00:47zakwilsoncemerick: Ahh. It sounds like there was a lot of cool stuff there. I'm (over) eager to see the footage.
00:48cemerickit's coming :-)
00:48cemerickMay be a while yet, but I'm glad it's in-process.
00:48cemerickI'm still sore about the video from ILC 2008 not getting out there. :-(
00:50ppppaulhow would i convert \+ to +
00:51amalloy&(symbol \+)
00:51sexpbotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String
00:51ppppaul:D
00:51amalloy&(symbol (str \+))
00:51sexpbot⟹ +
00:56RaynesThat retarded bug should be fixed now.
01:12ppppaul,(symbol +)
01:12clojurebotjava.lang.ClassCastException: clojure.core$_PLUS_ cannot be cast to java.lang.String
01:12ppppaul,(symbol '+)
01:12clojurebot+
01:13ppppaul,(symbol "+")
01:13clojurebot+
01:13rata_how does I execute a class generated with :gen-class and compiled with leiningen?
01:13ppppaulmagic
01:13rata_cd classes; java -cp . app doesn't work
01:14amalloyrata_: lein uberjar
01:14amalloyjava -jar myproj.jar
01:14rata_even when it's in :aot and not in :main?
01:14RaynesYou can't 'execute' a class without a main method.
01:15rata_it has a main method
01:15rata_but it's not in project.clj as :main
01:15rata_it's in aot
01:15RaynesThen :main needs to be set to the namespace that -main is defined in.
01:16rata_Raynes: yes, but I don't want to put it in :main... it's not at all the main program
01:16rata_it's just to test something
01:17RaynesYou *have* to if you want to execute it. You can't run something without a main method.
01:17RaynesI suppose you could run the class directly.
01:18Raynesjava -cp classes your.main.Class?
01:18rata_it doesn't work so
01:19amalloyrata_: even with a fully-qualified classname?
01:19rata_it works now :) I had to put clojure.jar and clojure-contrib.jar in the classpath (even when they are compiled into classes/)
01:19rata_amalloy: its namespace is just app
01:22RaynesYou know you don't have to AOT compile stuff all of the time, right?
01:23RaynesI don't know what you're doing, of course. Just a note. If you're AOT compiling just to be compiling, you're doin' it wrong. :p
01:23RaynesAOT is mostly for special interop stuff.
01:23rata_yes, I just wanted to AOT this tiny app
01:24RaynesAlrighty. Just checking. :>
01:24rata_it's to test how long it takes to run from the terminal as an app and to profile it with profiler4j
01:25rata_what's the idiomatic way to convert an string to a number (integer in this case)? (Integer. "1")?
01:59Raynesraek: &| (Integer/parseInt "1") |&
01:59sexpbot⟹ 1
02:00rata_that's better than (Integer. "1")?
02:00ppppaulhmm
02:00RaynesYes.
02:00ppppaulclojure doesn't have it's own?
02:01ppppaul,(find-doc "integer")
02:01clojurebot-------------------------
02:01clojurebotclojure.pprint/*print-base*
02:01clojurebotnil
02:01clojurebot The base to use for printing integers and rationals.
02:01clojurebot-------------------------
02:01clojurebotclojure.pprint/*print-radix*
02:01clojurebotnil
02:01clojurebot Print a radix specifier in...
02:01Raynesrata_: There is also read-string, but it reads any object rather than just integers, and if you get your integer from user input, it can be dangerous.
02:01Raynesppppaul: Where Java isn't broke, Clojure doesn't fix it.
02:02ppppaul(int 1)
02:02ppppaul,(int 1)
02:02clojurebot1
02:02ppppaul,(int "1")
02:02clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character
02:02ppppaul,(int \1)
02:02clojurebot49
02:02ppppaulwell...
02:02ppppaul(doc int)
02:02clojurebot"([x]); Coerce to int"
02:03ppppaul(symbol "1")
02:03ppppaul,(symbol "1")
02:03clojurebot1
02:03ppppaul,(+ (symbol "1") 1)
02:03clojurebotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Number
02:03ppppaul,(+ (int (symbol "1")) 1)
02:03clojurebotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Character
02:03ppppaulblah
02:05ppppaul(doc ints)
02:05clojurebot"([xs]); Casts to int[]"
02:05ppppaul(ints "1")
02:05ppppaul,(ints "1")
02:05clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to [I
02:05ppppaul,(ints 1)
02:06clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to [I
02:06ppppaulconfusing
02:06replaca,(ints [1 2 3 4])
02:06clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to [I
02:07ppppaul(int '1)
02:07ppppaul,(int '1)
02:07clojurebot1
02:08ppppaul,(+ (int '1) 1)
02:08clojurebot2
02:08ppppaulcoooool
02:08ppppaul,(+ (int (symbol 1)) 1)
02:08clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
02:08ppppaulawww
02:08ppppaul,(+ (int (quote (symbol 1))) 1)
02:08clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Character
02:09rata_thanks Raynes :)
02:09rata_good night guys
02:09rata_see you
02:09ppppaulwhat am i doing wrong?
02:09replaca,'1
02:09clojurebot1
02:09ppppaul,(quote 1)
02:09clojurebot1
02:09replacappppaul: no symbol there
02:10ppppaul,(quote (symbol 1))
02:10clojurebot(symbol 1)
02:10ppppaul,(+ (int (quote 1)) 1)
02:10clojurebot2
02:10ppppaulthe '1' is a symbol or a number?
02:10replacanumbers are quoted all by themselves, so '1 doesn't do anything
02:11replaca,'"hello"
02:11clojurebot"hello"
02:11replacappppaul: strings too
02:11ppppauli'm just wondering cus i am converting a string to symbols, and want to use some of them as numbers
02:11ppppaul,(map symbol (rest (split "1+2+3+4" #""))))
02:11clojurebotjava.lang.Exception: Unable to resolve symbol: split in this context
02:12ppppaul,(map symbol (rest (clojure/split "1+2+3+4" #""))))
02:12clojurebotjava.lang.Exception: No such namespace: clojure
02:12ppppaul,(map symbol (rest (clojure.string/split "1+2+3+4" #""))))
02:12clojurebot(1 + 2 + 3 + 4)
02:12ppppaulwhat i'm doing isn't crazy, is it?
02:13chouser,(class (first (map symbol (rest (clojure.string/split "1+2+3+4" #""))))))
02:13clojurebotclojure.lang.Symbol
02:13replaca,(Integer/valueOf (name (symbol "1")))
02:13clojurebot1
02:13replacatry that
02:14ppppaulok
02:14chouser,(map read-string (next (clojure.string/split "1+2+3+4" #"")))
02:14clojurebot(1 + 2 + 3 + 4)
02:14chouser,(class (first (map read-string (next (clojure.string/split "1+2+3+4" #"")))))
02:14replacappppaul: normally you would ceck the string for integer-ness before going to a symbol or number
02:14clojurebotjava.lang.Integer
02:15ppppauli validate the string with regest
02:15ppppaulregex
02:15ppppaulthen i parse it
02:15ppppauli'm writing up a 24 game
02:15chouserppppaul: you saw read-string there?
02:15replacappppaul: yeah, nothing wrong with that (though sometime the regex can get you in trouble), it's just less common
02:16ppppauli love regex
02:16replaca:)
02:16ppppaul,(re-find #"(?:\d[\\+-\\*\\])+\d" "6*7+8-4")
02:16clojurebot"6*7+8-4"
02:16ppppauli can't test it with "\" though
02:16ppppaulit breaks
02:17ppppaulleast in emacs
02:17ppppaul,(re-find #"(?:\d[\\+-\\*\\])+\d" "6*7+8\4")
02:17clojurebot"6*7+8"
02:17chouser,(re-find #"(?:\d[\\+-\\*\\])+\d" "6*7+8-4\\2")
02:17ppppaul:(
02:17clojurebot"6*7+8-4\\2"
02:17ppppaulmy user isn't going to type in "\\"
02:17replacappppaul: regexs are great when the problem is really a regex problem
02:18replacagoodnight chouser!
02:18ppppauli've been doing a lot of JS automation scripting.... got regex coming out of my ass
02:18replaca,(map class (map read-string (next (clojure.string/split "1+2+3+4" #""))))
02:18clojurebot(java.lang.Integer clojure.lang.Symbol java.lang.Integer clojure.lang.Symbol java.lang.Integer clojure.lang.Symbol java.lang.Integer)
02:18ppppaullol
02:18ppppaulcoooooool
02:19replacajust expounding on chouser's work :)
02:19ppppaul(doc read-string)
02:19clojurebot"([s]); Reads one object from the string s"
02:19replaca,(map class (map read-string (next (clojure.string/split "11+222+3333+4444" #""))))
02:19clojurebot(java.lang.Integer java.lang.Integer clojure.lang.Symbol java.lang.Integer java.lang.Integer java.lang.Integer clojure.lang.Symbol java.lang.Integer java.lang.Integer java.lang.Integer ...)
02:19ppppaulnice, i'll use that
02:20replacabut that's not really what you want, though you may be able to tokenize with a regex, depending on the complexity of your language
02:20ppppauli think that's what i want. get numbers and symbols out of the string
02:21ppppaulregex is just for validation
02:21ppppauli could do re-seq though
02:22ppppaul,(read-string \1)
02:22clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String
02:22replacappppaul: well, each digit was pulled separately
02:22ppppaulthat's cus of your regex
02:22ppppaul#"" splits on char
02:22replacaright
02:22ppppaul#"\d+" would get the full numbers
02:23replaca,(map class (map read-string (next (clojure.string/split "11+222+3333+4444" #"\d+"))))
02:23clojurebot(clojure.lang.Symbol clojure.lang.Symbol clojure.lang.Symbol)
02:23ppppaul24 game just uses single digits, so that's what i want
02:23replacaahh, ok
02:23ppppaulyou aren't matching the +s
02:23replacaI know :)
02:23ppppaulgotta have a regex more like mine
02:24ppppaul#"(\d[\\+)+
02:24ppppaul#"(\d[\\]+)+
02:24ppppaul#"(\d[\\]+)+"
02:24ppppaulsomething like that
02:24ppppaul#"(\d[\\]+)+\d"
02:24ppppaul#"(\d[\\]+)+\d+"
02:24replacayeah, it's too late for me to do even simple regexs :)
02:24ppppaullol
02:25ppppaul,(map class (map read-string (next (clojure.string/split "11+222+3333+4444" #"(\d[\\+])+\d"))))
02:25clojurebot(java.lang.Integer java.lang.Integer java.lang.Integer)
02:26ppppaul,(map class (map read-string (next (clojure.string/split "11+222+3333+4444" #"(\\+"))))
02:26clojurebotUnclosed group near index 4
02:26clojurebot(\\+
02:26clojurebot ^
02:26ppppaul,(map class (map read-string (next (clojure.string/split "11+222+3333+4444" #"\\+"))))
02:26clojurebot()
02:26ppppaul,(map class (map read-string (next (clojure.string/split "11+222+3333+4444" #"\+"))))
02:26clojurebot(java.lang.Integer java.lang.Integer java.lang.Integer)
02:27replacathe prob with split is the it doesn't get the separators
02:27ppppaul,(map class (map read-string (clojure.string/split "11+222+3333+4444" #"\+")))
02:27clojurebot(java.lang.Integer java.lang.Integer java.lang.Integer java.lang.Integer)
02:27ppppaultrue
02:27ppppaulwould have to make 2 passes
02:27ppppauli just need 1 pass for my problem
02:27replacayup
02:28ppppaul:D
02:28replacaof course,
02:28replaca,(into [] "1+2+3")
02:28clojurebot[\1 \+ \2 \+ \3]
02:28replacadoes about the same
02:29replaca,(map class (map (comp read-string str) "11+222+3333+4444"))
02:29clojurebot(java.lang.Integer java.lang.Integer clojure.lang.Symbol java.lang.Integer java.lang.Integer java.lang.Integer clojure.lang.Symbol java.lang.Integer java.lang.Integer java.lang.Integer ...)
02:30replacafor instance
02:30replaca,(map (comp read-string str) "1+2+3+4")
02:30clojurebot(1 + 2 + 3 + 4)
02:30ppppaulinto is giving characters...
02:30ppppaulhhmmmmmmm
02:31replacayeah, you don't even need the into there
02:31replacacause a string *is* a sew of chars
02:31ppppaul(doc comp)
02:31clojurebot"([f] [f g] [f g h] [f1 f2 f3 & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
02:31replaca== #(read-string (str %))
02:31ppppaulyeah, i see
02:32ppppaul,(map (comp read-string str class) "1+2+3+4")
02:32clojurebot(class class class class class class class)
02:32ppppaullol
02:32ppppaulthey are all strings, i don't know if that's better than symbols
02:32ppppauli think symbols would be better for me
02:32replacayou need the class on the lft
02:33ppppaul,(map (comp class read-string str) "1+2+3+4")
02:33clojurebot(java.lang.Integer clojure.lang.Symbol java.lang.Integer clojure.lang.Symbol java.lang.Integer clojure.lang.Symbol java.lang.Integer)
02:33replacano they're not
02:33ppppaulooooooooooh
02:33replaca,(map (comp class read-string str) "1+2+3+4")
02:33clojurebot(java.lang.Integer clojure.lang.Symbol java.lang.Integer clojure.lang.Symbol java.lang.Integer clojure.lang.Symbol java.lang.Integer)
02:33ppppaulcomp is cool
02:34ppppauli'll use this method
02:34replacait's cooler in haskell, which has syntax for it :)
02:34ppppaul:D
02:35ppppaulnow i need to convert from infix to postfix notation
02:35ppppauloh
02:35ppppaulmaybe i don't
02:35replacait depends if you have operator precedence or not
02:36Raynesppppaul: sexpbot is working again, fyi. :)
02:36Rayness/working/running/
02:36sexpbot<Raynes> ppppaul: sexpbot is running again, fyi. :)
02:36ppppaulsexbot lot
02:36ppppaullove
02:36ppppauli think there is operator precedence
02:37ppppaulclojure has infix notation
02:37ppppauli saw it
02:37ppppaulcan't find it on clojuredocs, though
02:39ppppaulmaybe i'm wrong... there is some dude with an infix git project, though
02:39Raynesppppaul: https://github.com/fogus/unfix
02:41ppppauli don't think i can use this stuff since it's outside of core
02:42Raynesreplaca: Syntax for what? Function composition?
02:42ppppauli looked at the infix code, holy crap it's complicated
02:42ppppauli need to take "1+1+1+1" and get an answer out of it "4"
02:43replacayeah, sure and partials too
02:43ppppaulbut with *+\-
02:43Raynesreplaca: Haskell doesn't have syntax for function composition. I'm pretty sure '.' is an ormal function.
02:43Raynesnormal*
02:43replacawell, yeah, but the overall syntax of the language makes that so
02:43RaynesUm, okay.
02:44replacasame with partials -> you can just not supply all the args and you've got a partial
02:44ppppauli've done partials
02:45replacathe the design of the language means you use composition and partials a lot more in Haskell
02:45replacafwiw
02:45ppppauli've heard
02:46ppppaulmaybe i should just ignore precedence?
02:47ppppaul(%6 (%4 (%2 %1 %3) %5) %7)
02:48ppppaulhow hard do you think it would be to include precedence?
02:49ppppaul,(seventh [1 2 3 4 5 6 7)
02:49clojurebotUnmatched delimiter: )
02:49ppppaul,(seventh [1 2 3 4 5 6 7])
02:49clojurebotjava.lang.Exception: Unable to resolve symbol: seventh in this context
02:50ppppaul,(firrst [1 2 3 4 5 6 7])
02:50clojurebotjava.lang.Exception: Unable to resolve symbol: firrst in this context
02:50ppppaul,(nth 7 [1 2 3 4 5 6 7])
02:50clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
02:50ppppaul,(7 [1 2 3 4 5 6 7])
02:50clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
02:51ppppaul(doc nth)
02:51clojurebot"([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."
02:51amalloy(nth [1 2 3 4 5 6 7] 7)
02:51amalloyexcept 7 will be out of range
02:52amalloy,(nth [1 2 3 4 5 6 7] 5)
02:52clojurebot6
02:52ppppaulclojure needs a tenth
02:52ppppauljust like common-lisp
02:52ppppaulneeds a forty-secondth too
02:52ppppaulmaybe a towel function as well
02:52amalloyppppaul: we could use caadar too
02:53ppppaulcaadar is just weird now
02:53ppppauli thought clojure was supposed to have something like ressst
02:53amalloyyeah, because it's absurd
02:53ppppaul(doc first)
02:53clojurebot"([coll]); Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil."
02:53Raynes&(nnext [1 2 3 4])
02:53sexpbot⟹ (3 4)
02:54ppppaul,(fiiirst [1 2 3 4 5 6]_
02:54clojurebotEOF while reading
02:54ppppaul,(fiiirst [1 2 3 4 5 6])
02:54clojurebotjava.lang.Exception: Unable to resolve symbol: fiiirst in this context
02:54ppppaul,(fffirst [1 2 3 4 5 6])
02:54clojurebotjava.lang.Exception: Unable to resolve symbol: fffirst in this context
02:54ppppaul(doc nnext)
02:54Raynes&(ffirst [1 2 3])
02:54sexpbotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
02:54clojurebot"([x]); Same as (next (next x))"
02:54ppppaulthere aren't enough
02:55ppppaulhow can we call clojure a real lisp without ffffffffnnnnnext
02:55ppppaulgoing to have to make my own
02:57ppppaulanyone been doing euler problems?
02:58ppppaulsome are really easy, like... they ask for a single number
02:59ppppaulthat's a one symbol problem
04:00jrphas anyone gotten lein-vimclojure working?
04:01jrphttp://pastie.org/1281103 this confuses me. I have classpath issues, but java seems to work fine?
04:15esjbah. which cat dragged Monday in ?
04:16bartjesj, quote from a movie?
04:16bartjesj, or garfield ? :)
04:17esjprobably :) I thought I'd made it up, but usually it turns out somebody else has thought of all the good lines before
04:17Raynes$isgd http://programmers.stackexchange.com/questions/4433/who-is-the-most-interesting-programmer-in-the-world/4454#4454
04:17sexpbotRaynes: http://is.gd/gPuza
04:17Raynes$learn interesting http://is.gd/gPuza
04:17sexpbotMy memory is more powerful than M-x butterfly. I wont forget it.
04:17esjRaynes: lol.
05:49Raynes,(Thread/sleep 10)
05:49clojurebotnil
07:04klangIn sbcl, (time (foo)) returns the number of processor cycles and the amount of memory used (among other things). Is there any thing similar in clojure?
07:12nimredis new clojure-contrib's ./modules/complete/target/complete-$VERSION-bin.jar what old clojure-contrib's ./target/clojure-contrib*.jar was ?
07:35_bobopen #illumos
07:35_bobjoin #opensolaris
07:42sid3khi all. I'm going to install java for just clojure development. is it ok to use openjdk?
07:45sid3kany ideas, suggestions?
07:46bleeppurpleI have run clojure on fedora using openjdk
07:47bleeppurpleand then use lein as build tool
07:50klangI am using openjdk with clojure on ubuntu, without any problems.
08:03sid3kklang: bleeppurple thanks
08:03bleeppurpleno probs
08:05rdeshpandehello
08:17sid3kI've cloned clojure contrib repo and typed "mvn package" on the directory
08:17sid3kit has put lots of log lines with no errors
08:18sid3kbut there is no file like "clojure-contrib*.jar"
08:18sid3kI'm following this article: http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html
08:19sid3kany ideas? I'm not familiar with java world but mvn make me sick
08:20bleeppurplewait a minute....
08:20sid3kI have no mvn experience with no trouble ....
08:21chousersid3k: you looked in the dir "target" ?
08:21sid3kthere is no target dir
08:24bleeppurplewhere are you on the tutorial?
08:24sid3kon the mvn package command
08:26sid3kit builds lots of packages with no errors but doesn't create target directory
08:26bleeppurpletry lein self-install
08:27bleeppurplehave you installed lein script right?
08:27sid3kreadme offers mvn install command
08:28bleeppurplei have a few problems building contrib with mvn...used lein instead
08:28sid3kbleeppurple: I want to install manually
08:29bleeppurpleOk
08:29sid3kbtw readme tells that an uberjar containing all compiled modules at modules/complete/target directory
08:29sid3kI guess target dir was changed
08:31bleeppurpleim trying to build...see what i get
08:32sid3karright
08:38bleeppurplemine built successfully....
08:40sid3kinto which directory?
08:41sid3kto ./target or ./modules/complete/target/ ?
08:41sid3kbleeppurple:
08:42bleeppurple2nd 1...
08:44chouseroh, I bet my ./target dir is old, sorry
08:44bleeppurpleas complete-$VERSION-bin.jar
08:45sid3kall right, I completed the installation and reached my fresh clojure environment. thanks guys
08:45lenwhi all - i have a (defmulti process class) what do i say on the defmethod for an array of strings - if such a thing is possible ?
08:46lenwor for any array of incoming type ?
08:46chouser,(class (into-array String []))
08:46clojurebot[Ljava.lang.String;
08:47lenwso the same defmethod for String will match the array of String ?
08:47chousernope
08:47chouser(defmethod process (class (into-array String [])) [x] (str "is a string " x))
08:48chouserer
08:48sid3kbtw I saw a performance comparision of clojure and nodejs that claims clojure 2x faster than nodejs and also asynchronous callbacks are dirty
08:48chouser(defmethod process (class (into-array String [])) [x] (str "is a string-array " x))
08:48lenwhehe yes thanks a mill chouser
08:49sid3kmy question is, does clojure offers multiple threads for concurrent web apps?
08:49chousercould use (Class/forName "[Ljava.lang.String;") if you think that's clearer.
08:49sid3kor is there any clojure feature for coding asynchronous, concurrent web apps like comet servers?
08:51sid3kbecause millions of users would make stream at the same time, we need a single threaded solution for comet or web socket
08:51sid3kany ideas?
08:51clojurebotTitim gan éirí ort.
08:51sid3k*for a beginner
08:52lenwchouser: the first looks clearer imho :)
08:59chousersid3k: the default behavior of ring on most (all?) servers is to give each client request its own thread for the duration of a request+response
08:59chousersid3k: is that what you're asking?
09:00sid3kchouser: yeah, and this behavior is not a huge disadvantage
09:01chousernot at all, in fact it works well with Clojure's approch to concurrency.
09:02sid3kchouser: here is the article I was mentioning
09:02sid3k<chouser> not at all, in fact it works well with Clojure's approch to
09:02sid3kah wrong paste sorry
09:02sid3khttp://dosync.posterous.com/22397098
09:02tufflaxI don't understand what get-in does. Can anyone explain?
09:02tufflax&(doc get-in)
09:02sexpbot⟹ "([m ks] [m ks not-found]); Returns the value in a nested associative structure, where ks is a sequence of ke(ys. Returns nil if the key is not present, or the not-found value if supplied."
09:02sid3kchouser: are you familiar with comet or websockets?
09:03chousersid3k: a bit, sure
09:03sid3kif response lasts 30 seconds, we can't use threads
09:03chouserwhy's that?
09:03chousersid3k: on most modern OSs, threads are pretty cheap.
09:03sid3kthat means a thousand thread for a thousand user because
09:04sid3kthink about facebook's instant messenger
09:04chouseryes, if you're sure that's a problem for your usage profile, do consider aleph.
09:05sid3kthe thing I'm trying to ask is, does clojure provide one-threaded concurrency like javascript's callbacks?
09:06klangRepeating a question from earlier: In sbcl, (time (foo)) returns the number of processor cycles and the amount of memory used (among other things). Is there any thing similar in clojure?
09:06chousersid3k: you certainly can do that, yes.
09:06sid3kchouser: how?
09:07sid3kusing what?
09:07chousertufflax: get-in (and update-in, and assoc-in) are for nested collection, like multi-dimentional arrays.
09:07chousersid3k: functions.
09:07sid3kah great
09:07sid3kwith what?
09:07chouserusing functions, just like javascript does
09:07sid3kasynchronously?
09:07sid3kwithout threads?
09:07chouserwell, you're always going to need at least one thread, right?
09:07sid3kyep
09:08sid3ki'm correcting: asynchronously, with just one thread?
09:08chouserand if you've got multiple clients actively sending at once, you wouldn't mind one thread for each, right?
09:08chouserit's just idle connections that you're rather not assign a thread to?
09:08chouser& (get-in [[1 2 3] [4 5 6] [7 8 9]] [2 1])
09:08sexpbot⟹ 8
09:08Chousukeklang: I'm not aware of anything simple like that but probably you could use a java profiler.
09:08sid3kI would mind
09:09chousertufflax: like that ... [2 1] are essentially coordinates into the 2D "grid" of numbers.
09:09tufflaxI read the source, now i get it. The doc string was not very clear imo.
09:09tufflaxThanks though.
09:10Chousukehmm
09:11chousersid3k: why?
09:11Chousuke&(->> [[1 2 3] [4 5 6] [7 8 9]] 2 1)
09:11sexpbotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
09:11Chousuke&(macroexpand '(->> [[1 2 3] [4 5 6] [7 8 9]] 2 1))
09:11sexpbot⟹ (1 (2 [[1 2 3] [4 5 6] [7 8 9]]))
09:11chouserChousuke: you'd need ->< :-)
09:11Chousukeheh
09:11Chousukeseems so
09:12solussdchouser- just finished 'the joy of clojure' meap this-morning. good book, thanks!
09:12sid3kchouser: because comet needs totally asynchronous architecture
09:13sid3kcheck out python's tornado framework friendfeed uses
09:13chousersolussd: thanks, glad you liked it.
09:13sid3kthey run it with just 4 instances using nginx for millions of users streaming consistently
09:13chousersid3k: what I mean is, what harm would you suffer if multiple active clients used multiple real threads?
09:13sid3kyou can't do it by opening threads for users
09:15klangChousuke: hmm, ok .. not simple but workable
09:15sid3kchouser: consider you're coding facebook's instant messenger. a billion user will going to send a request which is streaming for 30 seconds your server
09:16chousersid3k: are you aware of how Clojure's agent's behave? That might interest you.
09:16sid3khow can you open a thread for a user? can't you see the insanity?
09:16Chousukeklang: also check out the clojure debugging toolkit (http://georgejahad.com/clojure/cdt.html). I haven't used it myself but it looks nice :)
09:17sid3kchouser: I'm not aware of, of course. this is why I'm asking because the comparision with nodejs was claiming that clojure uses threads for concurrency
09:17sid3kif there is no another solution for concurrency, it's not good
09:18chousersid3k: agents are built into clojure. take a look http://clojure.org/agents
09:19sid3kchouser: what is the goal of agents for this discussion?
09:20sid3khave you read my facebook example?
09:23belun(doc let-fn)
09:23clojurebotI don't understand.
09:23belun(doc letfn)
09:23clojurebot"([fnspecs & body]); Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body. fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+)"
09:27chousersid3k: agents provide a combination of work queues and thread pools so that incoming work (client requests) can be assigned to threads without having too many running threads for how many cores you've got.
09:27klangChousuke: I have a fear for debuggers .. but thanks, simple metrics for the resources used, like in the sbcl case, would be sufficient.
09:28sid3kchouser: sounds cool
09:28chouserusing 'send', if you've reached you max number of threads, the work queues up until more threads are available.
09:36tufflaxWhen I type (macroexpand ...) in my repl, the result gets evaluated too, so I can't really see the structure of it. How do I stop that from happening?
09:38chouser(macroexpand '(foo)) ; don't forget to quote the form like that
09:39tufflaxoh ok
09:40sdeobaldAnyone familiar with the internals of clojars around? http://clojars.org/repo/all-poms.txt seems to be lying to me, but perhaps I'm just reading it wrong.
09:40tufflaxThat expands it once, but what if I want it completely expanded, but not evaluated?
09:40sdeobaldOf course I was. Wups.
09:42chousertufflax: that's not actually how the clojure compiler works, but there's a thing in contrib that sorta simulates what happens.
09:42tufflaxhm ok, thank you!
09:42jarpiain,(clojure.walk/macroexpand-all '(or nil false true))
09:42clojurebot(let* [or__3470__auto__ nil] (if or__3470__auto__ or__3470__auto__ (let* [or__3470__auto__ false] (if or__3470__auto__ or__3470__auto__ true))))
09:42jarpiain,(macroexpand '(or nil false true))
09:42clojurebot(let* [or__3470__auto__ nil] (if or__3470__auto__ or__3470__auto__ (clojure.core/or false true)))
09:42chouserjarpiain: thanks, I can never remember it.
09:46_bobchouser: can I ask a question on agents?
09:47_bobI am looking into Clojure because I saw a presentation on them by mr Hickey
09:47_bobhowever I recently read a bogpost
09:47_bobhttp://webcache.googleusercontent.com/search?q=cache:Htvhj0QHWaMJ:measuringmeasures.com/blog/2010/8/16/clojure-workers-and-large-scale-http-fetching.html+&amp;cd=1&amp;hl=en&amp;ct=clnk
09:47_bobit has been removed from the blog I just saw
09:48chouser_bob: you can ask
09:48_bobso I don't know if the critisism of agents was valid
09:49_bobhis key argument agains agents: Clojure agents block on failure
09:49chouser_bob: interesting. as of 1.2, there are a couple different error-handling modes
09:51chouser(doc set-error-mode!)
09:51clojurebot"([a mode-keyword]); Sets the error-mode of agent a to mode-keyword, which must be either :fail or :continue. If an action being run by the agent throws an exception or doesn't pass the validator fn, an error-handler may be called (see set-error-handler!), after which, if the mode is :continue, the agent will continue as if neither the action that caused the error nor the error itself ever happened. If the mode is :fail, t
09:51_bobDo agents block on failure?
09:52chouser_bob: so in :continue mode, the agent doesn't block on error
09:56chouser_bob: that blog entry does seem to still be there: http://measuringmeasures.com/blog/2010/8/16/clojure-workers-and-large-scale-http-fetching.html
10:07chouser_bob: he's also complaining about partition which has been solved with partition-all
10:08_bobchouser: yes that is also commented on in the comments on the blog
10:08chouserand about an agent thread pool that is not user-configurable. There has been some discussion about how to change that, and imagine it'll happen at some point, perhaps a user-provided pool.
10:08_bobI am sorry I missed your previous replies, lost my connection for a few minutes
10:09chouser_bob: so in :continue mode, the agent doesn't block on error
10:09chouser_bob: that blog entry does seem to still be there: http://measuringmeasures.com/blog/2010/8/16/clojure-workers-and-large-scale-http-fetching.html
10:10_bobchouser: ok, good I found it strange I got an error on the link
10:10_bobchouser: good to hear the agents don't block
10:21lrenndoes slime-interrupt not work? Is there a way to kill along running function started in the slime repl?
10:35vibrant_hell-o
10:36vibrant_there is no equivalent of Java WeakHashMap in Clojure?
10:40cemerickvibrant: why not use WHM itself, if you want it?
10:41vibrantcemerick; yeah i guess that is an option. i'm writing a game so i'd like to have a map holding all players by ID, and then a map holding all units by ID, and then each player has a map containing his units. so when i remove a unit i'd have to remove it from the player's set of units.
10:41vibrantbut i guess it's not that much work after all manually heh.
10:42cemerickI'm just saying, if it does what you want, use it.
10:42vibrantyea youer' right.
10:43cemerickIt is definitionally not possible to make a persistent flavor of it, so an "equivalent" can't really exist (if that implies a functional data structure).
10:44vibrantyea and that's evil.
10:48cemerickvibrant: I wouldn't say that, especially when there's no viable alternative for certain use cases.
10:49cemerickdanlucraft: Congrats on the redcar buzz – it seems to have come into its own :-)
10:52nimredwhen running M-x slime this is what i get : http://clojure.pastebin.com/CxSmy9zD
10:52nimredis it OK ?
10:56cemerickchouser: http://groups.google.com/group/clojure-maven-plugin/browse_frm/thread/ec87a43c3bfac1b6
10:58apgwozdid stuart ever make his "simplicity ain't easy" slides available?
10:59pdloganapgwoz: I think I saw them yesterday in a tweet?
10:59cemerickapgwoz: yes, see his twitter feed
11:02apgwozoh. i must have missed that.
11:02apgwozthanks!
11:05fogus_pdlogan: Fighting the dynamic vs static fight! Good luck with that. ;-)
11:05pdlogansomeone pull me back from the brink...
11:11fogus_I find the dynamic vs static discussions to be incredibly boring these days. (does that help?)
11:13cemerickGenerally, I listen to both sides, and say, "all of the above, please" :-P
11:14cemerickPerhaps that makes me naive *shrug*
11:16pdloganagree with all of the above. I tried to stay out of the main debate and point out a couple 2-3 flaws... er, nevermind.
11:16cemerickpdlogan: sounds like I missed something…link?
11:18pdloganit was mostly @stevedekorte taking the side of the dynamic and @psnively taking the side of the static
11:19cemerickah
11:19cemerickthen maybe I didn't miss much :-)
11:19cemericktwitter arguments/debates are exhausting
11:19chousercemerick: yes, pompath
11:20cemerickchouser: stellar :-) Feel free to weigh in on that thread if you haven't already. Seeing "live" demand may motivate an implementor.
11:20cemerickAnd by all means, describe it differently if need be.
11:20pdloganyeah, not really much substance - a lot of talking past each other, false claims, people contradicting themselves, etc.
11:20chousercemerick: ok. busy at the moment, will try to weigh in later
11:21cemerickchouser: sure, np. I don't feel that use case, so I worry about misrepresenting/misunderstanding requirements, workflows, etc.
11:22cemerickpdlogan: There's often a "tastes great / less filling" air to such things. :-)
11:22pdlogancemerick: exactly so
11:30nimredwhen running M-x slime this is what i get : http://clojure.pastebin.com/CxSmy9zD
11:30nimredis it OK ?
11:31cemericknimred: there is no progn in clojure
11:32cemerickhrm, or funcall or read-from-string
11:32apgwozcemerick: (defmacro progn [& body] `(do ~@body))
11:32cemericknimred: Clojure is not a Common Lisp impl :-)
11:32apgwozbut, i digress
11:35nimredcemerick where does this progn come from ?
11:36cemericknimred: oh, you're not inputting that?
11:37nimredof course not
11:37ordnungswidrighi, did anybody implement aco in clojure? (ant colony optimization)
11:37nimredwhere did i say i was inputing it ?
11:37apgwoznimred: that's from emacs
11:37nimredcemerick 18:07 < nimred> when running M-x slime this is what i get : http://clojure.pastebin.com/CxSmy9zD
11:38nimredcemerick i just ran M-x slime
11:38apgwoznimred: can you paste your slime related emacs config?
11:38nimredand http://clojure.pastebin.com/CxSmy9zD is output following M-x slime...
11:38cemericknimred: Clearly, I misunderstood you.
11:38apgwoznimred: the better way might be to run swank elsewhere, say with lein swank and then do M-x slime-connect
11:38nimredcemerick sure anyway since yesterday nobody understand me here
11:39cemerickPlenty of people have come in asking why Clojure fails to run various CL programs, etc.
11:41nimredapgwoz trying what you suggest me --> Versions differ: 2010-11-07 (slime) vs. 20100404 (swank). Continue? (y or n)
11:41apgwozit should be fine, so type y RET
11:41nimredwhen running M-x slime-connect once i ran lein swank in my test-program dir
11:41amalloyapgwoz: it doesn't actually wait for a RET
11:41apgwozamalloy: fair enough :)
11:42nimredapgwoz Connected. May the source be with you!
11:42apgwoznimred: excellent!
11:43apgwozthe only way to run M-x slime with clojure is to specifically set it up. Judging by the output you had, it looks like it's setup to run some common lisp
11:44nimredapgwoz no : isn't (setq inferior-lisp-program "~/.clojure/clj-env-dir") enough ?
11:44apgwozi *don't think* so, but i could be wrong.
11:45apgwoznimred: i find it more convenient to do slime-connect though, so..
11:45nimredapgwoz so which way to directly run slime with clojure ?
11:47apgwoznimred: technomancy would know better, he the author of swank-clojure
11:48apgwozs/he/he's/
11:48sexpbot<apgwoz> nimred: technomancy would know better, he's the's author of swank-clojure
11:52nimredis new clojure-contrib's ./modules/complete/target/complete-*.jar what old clojure-contrib's ./target/clojure-contrib*.jar was ?
11:57nimredis new clojure-contrib's ./modules/complete/target/complete-*.jar what old clojure-contrib's ./target/clojure-contrib*.jar was ?
11:58Bootvis(nth i [e1 ... en]) is O(1), right?
12:04amalloyBootvis: well...yes, because it always throws an exception. but if you reverse the order of the parameters, i think it's log32(n), which is practically 1
12:05nimredis new clojure-contrib's ./modules/complete/target/complete-*.jar what old clojure-contrib's ./target/clojure-contrib*.jar was ?
12:08amalloynimred: calm down. irc is not google - it may take more than five minutes for someone who knows the answer to your question to notice you've asked it
12:13nimredBSIYBGBA
12:13Bootvisamalloy: thanks
12:19nimredpppaul is new clojure-contrib's ./modules/complete/target/complete-*.jar what old clojure-contrib's ./target/clojure-contrib*.jar was ?
12:28nimredamalloy first time i asked this question is about 8 hours ago. Still no answer. Your 5 minutes are far aaway...
12:35cemericknimred: complete-1.3.0-alpha3.jar (for example) is only 1.8K; there is no corollary to 1.2.0's contrib jar. complete (AFAIK) simply offers a way for maven/lein to transitively depend upon all of the separate module's artifacts.
12:37nimredwhy isn't there any more clojure-contrib.jar ?
12:37cemericknimred: depending upon complete has the same effect
12:37cemerickAlthough it's likely to go away eventually in the 1.3.0 cycle.
12:42nimredso what do i have to set emacs swank-clojure-extra-classpaths to ?
12:53nimredis swank-clojure-extra-classpaths recursive ?
12:55nimredcan it be set to ~/opt/clojure-contrib or do i have to copy *.jar from contrib to some directory and set swank-clojure-extra-classpaths to this new directory ?
13:26rata_hi
13:29jlaskowskihi
13:29jlaskowskiwhere is definition of fn* in the source code?
13:29jlaskowskiI'm reading clojure/src/clj/clojure/core.clj
13:30jlaskowskiand spot fn* a few times
13:30amalloyjlaskowski: it's a primitive used by the compiler
13:30amalloymostly there's no reason for you to use it
13:30amalloysame for let*, and mostly anything ending with * :P
13:30jlaskowskiI can see it when macroexpand-all
13:31amalloyyes
13:31amalloybut it does'
13:31amalloynt have any clojure code
13:31amalloyit's all in java
13:31jlaskowskithat's even better :)
13:31amalloyyou can go looking in src/jvm
13:32jlaskowskigot it
13:32jlaskowskifound it
13:32jlaskowskijvm/clojure/lang/Compiler.java:static final Symbol FN = Symbol.intern("fn*");
13:32amalloyyep
13:32jlaskowskithanks amalloy
13:33amalloyif you try to read the compiler code you'll go blind, though :)
13:33jlaskowskiI'm not sure I can go blind after having spent a couple of monads trying to figure out monads in Clojure :-)
13:34chouserwhat some call blindness, others call enlightenment
13:34amalloyspent a couple of monads?
13:34jlaskowskis/monads/months
13:34jlaskowskisorry
13:34vibrantis it wise to hold maps in sets?
13:34amalloyheh, np
13:34vibranti mean is it going to incur a lot of comparisons when there are many of them?
13:35amalloyvibrant: no, it shouldn't be a problem
13:35jlaskowskiyou see, I don't see a difference between monads and months :-0
13:35amalloythey're all hashtables, so as long as they're persistent maps/sets rather than the java.util modifiable kind it should be just as cheap as storing anything else
13:36jlaskowskithanks again for your help
13:38amalloydoes swank-clojure support jumping to the definition of a symbol? if so, what's the emacs keybinding for it?
13:39replacaamalloy: M-.
13:40amalloysweet! it works, even when the symbol is defined in lib/someLibrary.jar
13:41replacahow about that! :)
13:44rata_what's the interface for that ability of vectors to be called as a fn giving them the index?
13:46raekrata_: IFn
13:46raekor more accurately, clojure.lang.IFn
13:46rata_raek: but that's just to behave as a fn, not the ability to give them an index
13:46rata_I thought it may be ILookup
13:46amalloyrata_: that's what they do when called as a function
13:47rata_and what's ILookup?
13:47amalloy&(supers (class []))
13:47sexpbot⟹ #{clojure.lang.IMeta clojure.lang.Seqable java.io.Serializable clojure.lang.IObj java.lang.Comparable java.util.RandomAccess clojure.lang.IFn clojure.lang.Indexed clojure.lang.APersistentVector clojure.lang.Associative java.util.concurrent.Callable clojure.lang.Reversible clojure.lang.IEditableColle... http://gist.github.com/668073
13:48amalloyrata_: that's used for (get vector index), i believe
13:48cemerickrata_: ILookup exists to support keyword lookups
13:48rata_and Indexed?
13:49cemerickintroduced in particular for reification of fast keyword lookup of slots in defrecords
13:49amalloyrata_: clojure.lang.APersistentVector contains the actual code for looking up by index
13:49cemerickrata_: efficient random access
13:50rata_cemerick: that's what I need :)
13:50amalloy(it basically just delegates to nth, which is defined in PersistentVector
13:50rata_and every Indexed can be called as (obj index)?
13:50defnmost mature rails-like framework for clojure at this point in time?
13:51defnConjure, maybe?
13:51amalloydefn: moustache? i don't know much about it or rails, but it always seems to cme up when people mention rails, so...
13:51cemerickrata_: No, only implementing IFn or some derivative allows you to treat an instance as a function like that
13:51cemerickIt just so happens that most Indexed collections are also fns.
13:51rata_Indexed then doesn't imply IFn?
13:52cemerickcertainly not
13:52rata_ok
13:52cemerickIndexed only implies interop with nth
13:52raekmoustache is a very neat Ring routing lib. I wouldn't call it a rails-like framework, but Ring + Moustache + Enlive covers the VC of MVC, I think
13:53defnyeah ive used moustache
13:53defnim just looking for something more frameworky
13:53defni know...dirty word
13:53raekConjure is the only one I'm aware of
13:53defnThat was my understanding as well
13:54fogus_defn: Conjure is rated the most frameworky by a popular vote!
13:54defnjust thought I'd ask around
13:54defnfogus_: I'm a code archaeologist
13:54fogus_defn: yay! We need more of you.
13:54defnThat's why I care about "scaffolding"
13:55cemerick(inc fogus_)
13:55sexpbot=> 1
13:55defnhaha oh god I forgot I suggested someone build a karma plugin
13:56amalloyyeah, ivey put it in. bad defn
13:57amalloy(dec defn) ; :)
13:57sexpbot=> -1
13:58amalloysexpbot: can't recognize a joke when you see one?
13:58defn:(
13:59amalloy(inc defn)
13:59sexpbot=> 1
13:59defn:D
13:59fogus_(inc fogus_)
13:59sexpbotYou can't adjust your own karma.
13:59fogus_Oh well
13:59amalloywait what happened to 0? did someone silently inc him?
13:59defn(inc fogus)
13:59sexpbot=> 1
14:00amalloywaittaminute, (inc) is using => instead of ⟹
14:03amalloy$karma amalloy
14:03sexpbotamalloy has karma 0.
14:04leifw(inc sexpbot)
14:04sexpbot=> 1
14:04amalloyheh
14:04leifwany change he's smarter than that? can I use proper functions?
14:04leifw*chance
14:04amalloyhe's not
14:04amalloyinc, dec, karma is all you get for the karma plugin
14:05tonylping
14:07fogus_$karma fogus_
14:07sexpbotfogus_ has karma 1.
14:07fogus_so cool
14:07clojurebotGabh mo leithscéal?
14:09tonyllol that is a nice tool
14:10amalloy$karma
14:11tonyl$karma amalloy
14:11sexpbotamalloy has karma 0.
14:12pjstadig$karma sexpbot
14:12sexpbotsexpbot has karma 1.
14:12amalloytonyl: i deserve a (dec) for $karma. i was seeing if he'd barf on that. i suspect he threw a NPE, but of course he hides those if they're not in an eval
14:12bhenryhow come it couldn't be (karma sexpbot) instead of the $ trick?
14:13amalloybhenry: $foo is sexpbot's general syntax for commands. (inc|dec foo) is a convenient alias
14:13amalloy$inc bhenry
14:13sexpbot=> 1
14:14tonyl$inc sexpbot
14:14sexpbot=> 2
14:14bhenryoh okay
14:15bhenryis karma persistent or in memory?
14:15danlarkinthis... is annoying
14:15amalloybhenry: persistent
14:15pppaul$inc sexpbot
14:15sexpbot=> 3
14:16pppaulwhat does karma do?
14:16pjstadigannoy people
14:16tonyl:P
14:16amalloymostly, yeah
14:16clojurebotNo entiendo
14:17pppaulit would be cool if clojurebot used Esperanto
14:18tonylwhy?
14:18clojurebothttp://clojure.org/rationale
14:19pppaulwhy not/
14:19pppaul?
14:19pppaul$help
14:19sexpbotYou're going to need to tell me what you want help with.
14:19pppaul$help getting women
14:19sexpbotTopic: "getting" doesn't exist!
14:20tonyli'm just wondering about the specific language, why not japanese or italian?
14:20pppaulEsperanto!
14:21pppaulan icon language would be cool too, but i don't know if it would display well
14:21tonylhehe
14:21pppaulalso, i would like to add broken-english to the languages clojurebot should speak
14:21leifwlol
14:21tonylor pirate
14:25pdloganI notice the java interop for a specific library has trouble resolving methods when using the double-dot shortcut ..
14:25pdloganbut rewriting them out more step-wise they resolve fine. is this a known problem (or feature)?
14:26pdlogan(the jericho html parser, if anyone's interested)
14:26amalloypdlogan: that *shouldn't* be a problem, but .. is semi-deprecated now that we have ->
14:27pdloganoh I see
14:28pppaullove the ->
14:28amalloypdlogan: would you mind gisting a snippet that works with (.foo (.bar baz)) but not with (.. baz bar foo)?
14:29pdloganumk the -> works fine
14:29pdloganamalloy: sure
14:32pdloganamalloy: ok - here's one https://gist.github.com/0b1de72a59cfd98deaf5
14:32pdlogan(note I've seen the same problem without the use of % though)
14:33amalloypdlogan: when you're using .. you should use getX, not .getX
14:33pdlogancrikey - I knew that.
14:33pdloganerk
14:33pdloganbeen a while
14:33hiredmanif the method name in the exception has a dot in it, that means you have too many dots
14:35pdloganI welcome the ->
14:36amalloyyeah. -> and ->> are magic
14:36vibrantso.. what's the difference between refs and atoms?
14:36pppaul(doc atom?)
14:36clojurebotPardon?
14:37amalloyvibrant: atoms are atomic only to changes from within the (swap!) function
14:37pppaul$dec clojurebot
14:37sexpbot=> -1
14:37vibrantamallo; and refs can take part in transactions?
14:37amalloyvibrant: right, with (dosync)
14:37tonyl(doc clojure.inspector.atom?)
14:37clojurebotjava.lang.ClassNotFoundException: clojure.inspector.atom?
14:37vibrantamallo; ok, so i need refs since i need to change multiple objects atomically. thanks.
14:38pppaulyup
14:38amalloyvibrant: right. or a single atom holding all the objects
14:38pppaulthat's a big atom
14:38amalloyi stay away from refs when i can, personally, since atoms are cheaper
14:38vibrantyea it would be more fuss i guess.
14:38vibranti have to store a map of units, a map of players, and each player has a map of units inside him.
14:39vibrantso i'd make each player a ref and each unit a ref i thought.
14:39vibrantand the global maps would be refs too i guess.
14:39amalloyhrm. i'd make each map a ref, not each unit in the map
14:39amalloythe fewer mutable things you have, the better :P
14:40tonyl,(use '(clojure.inspector atom?))
14:40clojurebotjava.io.FileNotFoundException: Could not locate clojure/inspector/atom?__init.class or clojure/inspector/atom?.clj on classpath:
14:40leifwmaybe an agent?
14:40vibrantamalloy; ok but then if i have a map of units, and then a map of players, and i change a unit
14:40vibrantthen if a player in the other map also has that uniti
14:41vibrantthen those are two different units then right?
14:41vibrantand i want to have one 'instance' of a unit and if i modify it i want it to change both in the global unit map and within some player's unit map (if that player has that unit)
14:42vibrantor any better way to accomplish this?
14:42leifwthen maybe each unit should be an atom
14:43vibrantleifw; yeah, but that could lead to some race conditions i guess. if i modify multiple units with regard to some events that happen and should be theoretically atomic.
14:43leifwthen you don't need a transaction, you just swap a unit with an altered unit, and if both the global map and a player's map hold references to it, you're ok
14:43vibrantdoesn't sound like a big problem though.
14:43amalloyvibrant: it's hard to design without knowing more about your layout. you want a global map describing unit types, and each player has a map of {unit-type. number} or something?
14:44leifwpersonally, I like working with agents a lot more
14:44vibrantamalloy; i want a global lookup table of units by ID so {id -> unit}, and each player owns multiple units so basically {id -> unit} too (for a subset of the global ids map)
14:44leifwI'd just model the whole game state as a single agent
14:44leifwwell wait
14:45leifwthen normalize your data: keep the global lookup table, and then for each player, just keep a set of ids
14:45anonymou1e89i'm trying to call a function after using load-file, if I don't know the namespace of the file that I'm loading beforehand what would be the way to call a function defined in that loaded file?
14:45amalloyvibrant: yeah, i agree with leifw here
14:45vibrantoh, sounds good.
14:45leifwthat way you don't have the same unit referenced in two places
14:46amalloyand then you don't have any race conditions or synchronicty issues. you can use either an atom of a map, or a map of atoms
14:46vibrantok so we went down to one atom for the big unit map, plus one atom for big players map, and each plaer keeps a set of IDs
14:46leifwI'm still not sure about your problem of modifying multiple units in a transaction
14:46amalloyyou have a map of players too?
14:46leifwwhat sorts of modifications are we talking about here?
14:47vibrantleifw; if they're in one big unit map which is an atom then it's no longer a problem.
14:47amalloyleifw: not a problem if the whole unit map is a single atom
14:47leifwfair enough
14:48vibrantamalloy; yeah. the map of actual users playing the game.
14:48vibranteach user can have multiple units.
14:48tonylanonymoule89: clojure.contrib.ns-utils/get-ns
14:48amalloyvibrant: is that more or less a constant? or can users join/quit at will?
14:48tonylmaybe that would help
14:48leifwI assume the sets of units can change, can the units themselves change as well (like, I dunno, decrease HP or something)?
14:49vibrantamalloy; haven't thought about quitting but they can join for sure.
14:49vibrantleifw; yeah they can change
14:50vibrantin fact i might put all units and players and everything else into one big map.
14:50vibrantwhich would be an atom.
14:50vibranti'd just have to give them unique IDs
14:50vibrantor maybe not, since i wouldn't be able to iterate on them by type.
14:50vibrantat least not efficiently.
14:50pppaulis the apply in clojure different from the apply in lisp?
14:50hiredmanjava.util.UUID
14:51leifwhaha I would still use an agent for the whole game state, and then implement functions for it like (shoot [state unit1 unit2]) and (join [state player units])
14:51leifw,(doc apply)
14:51clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
14:51vibrantlefiw; yea but agents are asynchronous no?
14:52leifwyeah, but they process the events they receive serially
14:52amalloyyeah, an agent might not be such a bad idea here
14:52leifwit just makes sense to me that you'd have some sort of game state, which reacts to user events
14:52nimredhas swank-clojure dead ?
14:52leifwhaving it in a separate thread is nice too, and if you use an agent, you don't even need to think about threading, but you get it
14:53hiredmanwell
14:53hiredmanwith a single agent you don't have to think about threading because you are single threaded
14:53vibrantleifw; yeah but it's a game server which holds state for all clients.
14:53vibrantleifw; and should update the state on-line i think.
14:54leifwvibrant: you can have your clients watch the agent
14:54leifwI dunno, you're building a game server, which is inherently an async object, why not model it with an async language construct
14:55leifwbut I digress, an atom will work fine, though I suggest you look in to agents and decide if you like them any better
14:56hiredmanthe issue with using a single instance of a clojure reference type to hold all your state is you have a single timeline which means no concurrency
14:56vibrantleifw; i just finished reading that chapter in joy of clojure :)
14:57hiredmanif you want to be cool and concurrent you must allow for simultaneity
14:57vibranthiredman; yeah you're right. so i'd have to make separate atoms for each unit then.
14:58hiredmansomething like ants.clj
14:58leifwhiredman: I was thinking about that; I don't think there's much concurrency in this problem. As I understand it, he has a game state, which changes as the result of actions in the game, but these actions may involve complicated sub-parts of the game state, which we can't predict very well.
14:58leifwfor example (I am picturing this as something like starcraft), a bomb goes off, and you want lots of units' HP to decrease at the same time
14:59vibrantleifw; well watching atoms would be nice though. each player would just watch the units in his viewport, and get notifications from Clojure itself without me interfering.
14:59leifwthough things like unit movement should probably be concurrent
14:59technomancynimred: swank-clojure.el is dead, yes.
14:59hiredmanleifw: what if multiple players throw multiple bombs at once?
14:59vibrantleifw; and i'd just update the watched units as the player/units move.
15:00vibrantworst part i'm using a java physics library right now. and it's a big clunky blackhole.
15:00hiredmanleifw: with a single reference each bomb's effects are applied one after the other, in a linear ordering
15:00leifwI am mostly comfortable with those actions getting serialized, because it's unlikely that the users clicked at *exactly* the same time
15:01leifwor, in real life, it is unlikely that multiple bombs go off at exactly the same time
15:01vibrantwell if it's a big bomb fight
15:01vibrantthen there will be a lot of bombs going off :)
15:01leifwI am liking this game more and more
15:02leifwcan you just make bomberman please
15:02ohpauleezhow far out is the decimal point on time? :)
15:02vibrantquestion is if the cost of maintaining those atoms for each unit outweighs the cost of lack of concurrency or not.
15:03vibrantleifw; well i've waited 15 years to make this game so i'm not about to simplify it hehe
15:03leifwooh, I am even more excited
15:03leifwso, here's a scenario:
15:03hiredmanleifw: it's not about the bombs going off, it's about the effects of the bomb going off, the point is if you want an accurate simulation you cannot keep a single timeline
15:03leifwI throw a bomb, and you throw down some area-of-effect shield thing
15:04vibranthehe
15:04leifwhiredman: sure you can, if you can process the events fast enough
15:04hiredmanno
15:04hiredmanprocessing events quickly is not a substitute for multiple timelines
15:04leifw*we* have a single timeline, unless you're that deep in theoretical physics
15:04hiredmanabsolutely not
15:05vibrantleifw; if it's going to be a multiplayer server ran on a 16-core server
15:05vibrantthen hiredman has a point.
15:05vibrantand if it's in Clojure on top of Java :)
15:05vibrantso it'll have it's slowness.
15:05hiredmanat this point I think my not arguing with idiots on the internet policy kicks in
15:06leifwsorry, I don't mean to argue, I actually want to know why multiple timelines are necessary
15:07hiredmanhttp://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey
15:09cemerickhiredman: just because someone is wrong or isn't convinced of something doesn't make them an idiot :-(
15:09pppaulreally?
15:09leifwI've read this before
15:09leifwin general I agree, I just think this problem doesn't fit the model
15:09hiredmanthe proposition that processing events quickly is the samething as concurrently processing events does
15:10leifwsuppose you throw a bomb and I throw some shield thingy around the same group of units
15:10leifwwhat you would like is for one of them to take effect on all those units before the other
15:10hiredmanleifw: I meant it, I will no longer dicuss this topic with you
15:11leifwok, fuck you too
15:11hiredmanno need to get nasty
15:11leifwlikewise
15:12vibrantmy game is already causing controversy
15:12vibranthooray!
15:12leifwhaha you win, vibrant
15:12rata_is there any way to know what ns$f$fn__955$fn__957$fn__959 in my code is?
15:12leifwrata_, nested anonymous functions inside ns/f
15:13amalloyrata: it's a closure inside ns/f
15:13amalloyleifw's answer is better tho
15:13pppaul(doc eval)
15:13clojurebotDENIED
15:13pppaulooooooh
15:13pppaul(eval '(+ 1 2 3))
15:13rata_yes, but which one? is there any way to know which number is assigned for every anon fn?
15:13pppaul,(eval '(+ 1 2 3))
15:13clojurebotDENIED
15:13amalloyrata_: no
15:14amalloygive your anonymous functions names, and then you can: &|(fn a [])|&
15:14sexpbot⟹ #<box4317$eval5884$a__5885 net.licenser.sandbox.box4317$eval5884$a__5885@157f347>
15:14nimredtechnomancy swank-clojure.el but not swank-clojure ?
15:14rata_ok
15:15pppaulnimred, did you get clojure working?
15:15nimredpppaul yes and no
15:15pppaulcool
15:15nimredtechnomancy then what is https://github.com/jochu/swank-clojure for ?
15:15pppaulit should work on the command-line at least. rlwrap clojure
15:16leifwanyway, vibrant, I'll continue my example, hopefully it'll be helpful to you: what I imagine is that you want either the bomb or the shield to happen first, for all of the affected units. If you opt for a concurrent approach, you will in that case want some sort of ordering on the events
15:17leifwso just...be careful
15:17nimredpppaul clojure itself works fine and has always worked fine for me
15:18nimredclojure withing emacs...
15:19vibrantleifw; yeah that's a good point, but this will be a game with conventional arms so i don't imagine any magical shields.
15:20amalloyvibrant: body armor, kevlar, tree cover...
15:20leifwnimred: as I understand it (which is probably completely wrong), swank-clojure.el is gone, but swank-clojure is still there. you use swank-clojure in your running clojure session (I usually just use lein swank), and then connect to it with M-x slime-connect using the traditional slime.el
15:22technomancyleifw: yeah, that's the idea
15:22vibrantamalloy; yea but if someone is wearing armor then it's not like he suddenly throws it on a number of units like in the shield example
15:23leifwvibrant: do you have any physics in this?
15:24vibrantleifw; yeah but i'm thining of throwing it away since it's top-down. and the whole value is in multi-player interactions (alliances, trade, etc. not only guns)
15:24amalloyvibrant: whatever. there are tons of examples where this sequentiality is useful. say you order your units to take cover from incoming gunfire, or something
15:24apgwoztechnomancy: at the conj, you presented from emacs. what were you using?
15:25technomancyapgwoz: little lib called epresent; it's on my guthub account
15:25technomancyworks off org-mode docs
15:25apgwozah, nice.
15:25apgwozi'll check it out
15:25apgwozthanks
15:25technomancyit's kinda simplistic; may work if your formatting requirements are light.
15:26tonylwhat stage is the game? I would like to test it, if it's possible
15:26vibrantleifw; hehe well i got a flying triangle shooting bullets at walls 2 days ago. but now it's only a triangle again and it's barely flying.
15:26vibranttonyl ^ read above :)
15:26leifwmraw :(
15:27vibrantbut i moved to client-server architecture so that's the reason for the regression.
15:27tonyl:P offer still stands when you have something :)
15:27vibrantonce i have players interacting somehow and chatting maybe i'll put it up as an applet.
15:27vibrantanyone has experience with clojure in applets? :)
15:27pppaulnimred how long have you been using emacs?
15:28pppauli want some swank
15:30nimredpppaul as you should guess i am a beginner
15:30apgwoztechnomancy: i don't have much in the way of formatting requirements, though I suppose there probably isn't a way to force monospace is there?
15:30pppaulnimred, i think emacs has a pretty high learning curve
15:30apgwozoh wait. org-mode supports monospace, so it might work
15:31nimredpppaul what is a pretty high learning curve ? (sorry for my bad english)
15:31pppaulnimred getting clojure working in emacs is as simple as pointing the inferior-lisp var at how you run clojure on the command line (clojure), and then M-x inferior-lisp
15:32technomancyapgwoz: monospace (with font-lock of any arbitrary Emacs mode) is one of the few things that works great. =)
15:32pppaulemacs takes a while to learn, though
15:32nimredleifw are your settings somewhere ? (personnal page, github, bitbucket...)
15:32apgwoztechnomancy: amazing
15:32cemericknimred: what tools are you more familiar with?
15:32apgwoztechnomancy: i'll certainly be taking a closer look under the hood here
15:33technomancyapgwoz: I'm not the original author, but I added the font-lock support and published it to the git hubs.
15:33cemericknimred: There is clojure support for a variety of editors and IDEs: http://www.assembla.com/wiki/show/clojure/Getting_Started
15:33leifwnimred: I have my dotfiles on github, which includes my emacs dir
15:33nimredcemerick what do you mean writing "tool" ?
15:33leifwbut...you probably don't want to look at it
15:33vibrantnimred; i'm using intellij IDEA with la clojure and it's pretty good.
15:34cemericknimred: I mean…if you're more used to vi, eclipse, netbeans, intellij, or textmate, those might be a better fit for you than emacs (which seems to be giving you a fair bit of trouble)
15:34technomancyanother option would be to follow the official instructions instead of some random blog you found =)
15:35technomancyjust throwing it out there
15:35apgwoztechnomancy: yup, i think i encountered this a few years ago. i tried another one too (then) that didn't work very well
15:35nimredtechnomancy official only describes elpa way. I do not want elpa.
15:36technomancyok, your choice.
15:36nimredbe sure if official would have described from scratch i would have follow offical
15:37nimredleifw https://github.com/search?type=Users&amp;language=&amp;q=leifw+emacs&amp;repo=&amp;langOverride=&amp;x=0&amp;y=0&amp;start_value=1
15:38leifwnope
15:38pppaul(doc apply)
15:38clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
15:38leifwhold up, I'm pasting just the relevant bits
15:38pppaulwhy does apply have 3 args?
15:38pppaul,(apply + '(1 2))
15:38clojurebot3
15:39cemerickpppaul: so you can provide optional individual args and then an argseq
15:39cemerick,(apply + 1 2 [3 4])
15:39pppauloh
15:39clojurebot10
15:39nimredleifw ?
15:39leifwnimred: here you go https://gist.github.com/668222
15:39pppauli guess that is pretty common
15:40leifwthose are just the clojure-relevant parts of my emacs dir
15:40cemericktechnomancy: There's got to be a fable or saying to suit this. Somewhere between "give a man a fish…" and "beggars can't be choosers", or something. :-)
15:42leifwnimred: fair warning, I used elpa like the cool kids
15:42leifw(err, for most of it)
15:42hiredman~#93
15:42clojurebot93. When someone says "I want a programming language in which I need only say what I wish done," give him a lollipop.
15:43cemerickhiredman: where are those pulled from?
15:43hiredmanhttp://www.cs.yale.edu/quotes.html
15:43tonyl~#42
15:43clojurebot42. You can measure a programmer's perspective by noting his attitude on the continuing vitality of FORTRAN.
15:43cemerickhiredman: this'll be good, thanks :-)
15:44nimredleifw :/
15:44nimredlooks like there is not a lot of emacs user there...
15:44leifwactually, no, I used elpa for everything but clojure stuff, for whatever reason the elpa packages were old when I set this up and I haven't fixed them
15:44cemerickI think Peter Norvig has a bunch of quotables like this somewhere on his site as well.
15:44hiredmanhttps://github.com/hiredman/clojurebot/commit/cffd9b688b6b2f0a8a07c12a42d2dda14d7c17ed#L1R16 very literally pulled from there
15:45leifwso, yeah, go use that if you must not have elpa
15:47fogus_Just learned that you can directly destructure a Matcher... I just can't seem to get it to work. :-(
15:47apgwozfogus_: does it destructure into the matched groups?
15:48fogus_Seems to... but alas
15:48hiredmaninteresting
15:48hiredmanwonder how thats done, Matcher doesn't implement any of the interfaces
15:48amalloyfogus_: really?
15:49pdlogan~#11
15:49clojurebot11. If you have a procedure with ten parameters, you probably missed some.
15:49apgwozah, it works with re-matches
15:49pppaulLOL @#11
15:49fogus_hiredman: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L731
15:49pdlogan(reminds me of get. oops. did I jusst say that out loud?)
15:49pdloganer, git
15:49pppaul!#1
15:49pdloganoops
15:49hiredmanhuh, neat
15:49pppaul~#1
15:49clojurebot1. One man's constant is another man's variable.
15:49apgwoz,(let [[a b] (re-matches #"(\d+) (\d+)" "12 34")] (prn a) (prn 2))
15:49clojurebot"12 34"
15:49clojurebot2
15:50hiredman(doc re-matches)
15:50pppaulapqwoz, what are you aiming for?
15:50clojurebot"([re s]); Returns the match, if any, of string to pattern, using java.util.regex.Matcher.matches(). Uses re-groups to return the groups."
15:50apgwoz,(let [[a b] (re-matches #"(\d+) (\d+)" "12 34")] (prn a) (prn b))
15:50clojurebot"12 34"
15:50clojurebot"12"
15:50amalloyre-matches returns a vector, so this isn't surprising
15:50apgwozamalloy: true :)
15:50pppaulre-seq
15:50fogus_apgwoz: what amalloy said
15:51hiredmanwhat in clojure returns a Matcher?
15:51fogus_,re-matcher
15:51clojurebot#<core$re_matcher clojure.core$re_matcher@8f3052>
15:51amalloy&(re-matcher #"\d+" "blah 1")
15:51sexpbot⟹ #<Matcher java.util.regex.Matcher[pattern=\d+ region=0,6 lastmatch=]>
15:51hiredman(doc re-matcher)
15:51clojurebot"([re s]); Returns an instance of java.util.regex.Matcher, for use, e.g. in re-find."
15:52fogus_,(let [[date d m y] (re-matcher #"(\d{1,2})\/(\d{1,2})\/(\d{4})" "12/02/1975")] [date d m y])
15:52clojurebotjava.lang.IllegalStateException: No match found
15:53fogus_HRPMH! Seems like that should work
15:53apgwozbut how is that any different than using re-matches?
15:53amalloyfogus_: matcher doesn't do a find until you tell it to
15:53fogus_apgwoz: That particular example would not, but the general case would be nice
15:54apgwozfogus_: are you thinking maybe about named groups?
15:54apgwozin which case you could use the keyword destructuring, etc?
15:55amalloy,(let [[date d m y] ((comp re-find re-matcher) #"(\d{1,2})\/(\d{1,2})\/(\d{4})" "12/02/1975")] [date d m y])
15:55clojurebot["12/02/1975" "12" "02" "1975"]
15:55amalloyfogus_: ^^?
15:55fogus_whoa!!!
15:55hiredmanjava regexes don't have named groups
15:55fogus_hmmm, but re-find returns a vector
15:56apgwozhiredman: not according to the docs for Pattern \k<name>
15:56apgwozhiredman: though, i'm looking at java 7's docs, so it's being added :)
15:56amalloy,(let [[date d m y] (doto (re-matcher #"(\d{1,2})\/(\d{1,2})\/(\d{4})" "12/02/1975") re-find)] [date d m y])
15:56fogus_, (let [[date d m y :as foo] ((comp re-find re-matcher) #"(\d{1,2})\/(\d{1,2})\/(\d{4})" "12/02/1975")] foo)
15:56clojurebot["12/02/1975" "12" "02" nil]
15:56clojurebot["12/02/1975" "12" "02" "1975"]
15:57hiredmanapgwoz: sure, when ever that gets released
15:57amalloyfogus_: hey you're right, it works on the re-matcher
15:57apgwozwell, then i'm still stumped at what composing re-find and re-matcher gets you over re-matches
15:58apgwozin terms of destructuring
15:58amalloyapgwoz: lets you reuse the matcher to find all matches in the string
15:58amalloyi suspect is what fogus_ is looking for
15:59vibrantthis java lib is so annoying. any clojure lib for geometry/collision detection?
15:59apgwozwell, yes, re-matcher would give you a "compiled" regex to reuse. of course
15:59amalloyapgwoz: not just that. re-matches will only find the first match in a string
16:00woodworm`hi
16:00amalloyre-matcher will iterate through all matches in a string with repeated calls to re-find
16:00apgwozah, so it's more like an iterative search
16:00amalloymaybe. i dunno what fogus wants it for, but you asked what you gain: this is it
16:01apgwozamalloy: right. i know i asked. thanks for explaining.
16:01fogus_I just want to see if it works. :p
16:01vibrantleifw; u dead?
16:02woodworm`I have a set with a single element which is an instance of a record. contains? on it returns false when it should return true. I can see that equals (=) returns true and hash is also the same (on the element and my look up key). .contains works as expected. The funny thing is, I cant reproduce this problem in isolation. Any ideas on what the issue is?
16:04amalloywoodworm`: why are you using contains? on a set? just call it directly: &|(#{5 1} 5)|&
16:04sexpbot⟹ 5
16:04leifwvibrant: yeah I was on email for a bit
16:04leifwwhat's up
16:04leifwI am also about to go get some food
16:04vibrantleifw; http://briancarper.net/blog/520/making-an-rpg-in-clojure-part-one-of-many
16:04vibrantabout agents and refs etc.
16:06leifwthis is not you, I take it
16:07leifwok
16:07vibrantno, i didn't manage to put together a 20 page article in 10 minutes hehe
16:07leifwyeah, I see the problem
16:07amalloyis there a way to use {:keys [blah]} sorta in reverse? eg i have 4 locals, and want to create a map whose keys are the keyword-ized names and values are the current local values?
16:08leifwI think if instead of lots of agents banging on a single ref, you have the whole game as one agent that gets sent messages from a bunch of places, maybe it wouldn't be so bad?
16:08leifwdunno
16:08amalloysuch a macro looks fairly easy, but i don't want to write it if it already exists
16:08fogus_amalloy: It worked like you hinted earlier: https://gist.github.com/668275
16:08leifwI've got to go though
16:08leifwhope it works out well for you
16:08leifwand uhh, find me at some point when you finish it
16:09vibrantok, cu.
16:09amalloyfogus_: cool. i'm as pleased as you are to find that you can destructure Matcher objects
16:10fogus_Although the mutable tidbit is hideous!
16:11amalloyyessss
16:11amalloyfogus_: but that's what re-seq is for
16:11woodworm`amalloy: thanks for the suggestion.
16:12fogus_amalloy: Right. JoC actually mentions to avoid using Matchers directly... this is one more reason to do so.
16:12amalloyyeah
16:21rata_someone sees why I'm getting a StackOverflow here? https://gist.github.com/668294
16:21rata_or as an added question, does anyone know how to improve the performance of that function?
16:22rata_(the "complex" fn doesn't take long to run)
16:23bobo_rata_: you should probably use loop/recur instead for recursion
16:23bobo_or wait, i was confies by the names
16:23rata_I'm using loop/recur
16:23rata_:)
16:23bobo_get-complex != get-complezes
16:25rata_yes
16:27nimredwhich way to not display this annoying message in minibuffer "Polling "/home/nimred/tmp/slime.6853".. (Abort with `M-x slime-abort-connection'.)" ?
16:33ohpauleezrata_: You must be holding on to head somewhere, but I'm not spotting it
16:33ohpauleezJust looking over the gist, things look ok to me
16:33amalloyohpauleez, rata_: same here
16:33amalloylooks fine but must be holding onto head
16:33ohpauleezto speed it up, you can use transients as long as this stays pretty isolated
16:34ohpauleezie: if you're just building up groups, totally go for transients
16:34rata_if I'm calling get-complexes from the REPL, am I holding onto head?
16:34devinushas there been any work porting clojure to VMKit ?
16:35rata_ohpauleez: I'm just building groups... how do I use transients?
16:35devinussupposedly VMKit runs eclipse already
16:35ohpauleezrata_: https://gist.github.com/594584
16:35ohpauleezlook at step-seq!, which is pretty similar to your call
16:36ohpauleezessentially change the let to 'transient', change conj to conj! and add persistent! to your if statement
16:37cemerickfogus_: do you know the rationale for Matchers being destructurable? That just seems like a bad idea…?
16:37ohpauleezIf that still isn't fast enough ping me
16:37rata_ok, done it :)
16:37ohpauleezrata_: pretty easy, right?
16:37ohpauleez:)
16:37rata_yes :) I like it
16:37technomancyrata_: you were asking about telling apart compiled representations of functions; https://github.com/Seajure/serializable-fn may interest you
16:38tonylping?
16:38clojurebotPONG!
16:38rata_technomancy: I'll check it. thanks :)
16:38rata_ohpauleez: but I still have the StackOverflow problem
16:39ohpauleezYeah, I can't spot it. It might be the REPL
16:39rata_I thought using tail-recursion with loop/recur could never produce a StackOverflow
16:39amalloyrata_: ot cam
16:39amalloybah
16:39amalloyit can't
16:40amalloyso something you're doing inside the loop must be doing it, or else the repl trying to show it might be
16:41rata_then I don't get what's wrong here... I'm just calling get-complexes from the REPL, that's all
16:41ohpauleezrata_: How big is the collection you're passing to it?
16:42amalloyrata_: if the collection is super-huge, then last-complex might be overflowing
16:42rata_ohpauleez: it's a map of 1000 key-value pairs
16:43rata_amalloy: how might it be doing that?
16:43ohpauleezhmm, that's not too big. But I suspect you're holding on to a head reference somewhere. I can't spot it, but that is a common cause of this problem
16:43nimredleifw what does ~/.clojure/ext content ?
16:43amalloya lookup in the set could be traversing a tree. but i don't think 1k should be a problem at all
16:44rata_amalloy: in this case last-complex has always just one Integer within the set
16:45rata_ohpauleez: holding onto the head here shouldn't be a problem, as the fn is using loop/recur and that's a problem for lazy seqs... isn't it?
16:46ohpauleezlet me pull your gist back up, hang on
16:47rata_the maximum input is a map with 977 key-value pairs
16:48rata_more than that is an stack overflow
16:48ohpauleezwhere did you find that?
16:49rata_calling the fn from the repl with different inputs
16:49ohpauleezwell, that's sort of awesome because here's why...
16:50ohpauleezsplit the collection in half, and process on two threads, then join the results
16:50ohpauleezor use a lazy-seq
16:50ohpauleez(assuming you have a function to generate the map for you
16:50ohpauleez)
16:51rata_yes, I have a fn to generate the map
16:51ohpauleezalso, you might find a speedup in chunk-rest over rest, not too sure
16:51rata_btw, it's amazing the difference between this fn and what it was half an hour ago... 7400 msecs vs 1200 msecs
16:51ohpauleezawesome! glad to hear it!
16:51rata_:)
16:54rata_the problem with splitting the collection in half is that "agents" that belong to the same complex can stay in different halfs
16:54rata_(what's the right word for "stay" there?)
16:55tonyldelay?
16:56rata_anyway, I could split it and give the whole expr to both, then join the results and use distinct to remove the duplicated complexes
16:57rata_even so, the stack overflow problem remains
17:02vibranthow to return non-nil values from a sequence?
17:03bhenry(remove nil? your-sequence)
17:03bhenryvibrant ^
17:04bhenry,(remove nil? '(1 nil 2 nil 3 nil 4 nil))
17:04clojurebot(1 2 3 4)
17:04alpheus,(filter identity '(1 nil 2 nil 3 nil 4 nil))
17:04vibrantthx
17:04rata_or (keep identity coll)
17:04clojurebot(1 2 3 4)
17:05vibrantoh yea, keep is sexy
17:05tonylindeed
17:06amalloyrata_: you could improve your code a bit by using when instead of if when there's no else clause, and by using (or x y) instead of (if x x y)
17:06amalloyneither of those should fix your problem but they'll make it nicer
17:08rata_amalloy: but I don't have any if there without else clause
17:08vibrantanything like map-non-nil which maps and only returns non-nil values from the func that is mapped?
17:09amalloyoh wow, so you don't. writing (if (cond) (then) (else) with no newline after (cond) is really confusing
17:09rata_vibrant: keep
17:09vibrantrata; hah :)
17:09vibrantnow it's even more sexy.
17:10amalloyrata_: using (empty?) is also discouraged; i'd use (if (seq remaining) (let...) groups)
17:11rata_amalloy: yes... I'm used to writing it so when the then clause is a small form
17:11amalloyrata_: i mean, that's not a crime, but it certainly confuses the heck out of me
17:12rata_amalloy: why is it discouraged? it's very descriptive and has no performance problem
17:12amalloyusing empty?
17:12rata_yes, using (if (seq ...) ...) isn't very descriptive
17:13ohpauleezI think it's discouraged if what you're really expecting is nil, and then you should use nil?
17:13amalloyrata_: http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/empty?
17:14rata_I'm expecting '(), because remove and rest return '()
17:14RaynesIs there a map function that maps into subsequences? (sub-map (partial + 3) [1 2 [3 4]]) -> [4 5 [6 7]]
17:14bhenryamalloy: rata_ i think (not (empty? …)) is discouraged, but empty? alone is fine.
17:14RaynesThat would be so useful.
17:15bhenryRaynes: write it. : P
17:15Raynes:p
17:16rata_does anybody else know why this isn't tail-recursing? https://gist.github.com/668294
17:16bhenryi wrote this to map keys in nested maps. https://gist.github.com/662618
17:16bhenrydon't know if it's any good, but it works
17:17rata_lazy-seq works with transients?
17:17pppaulmaybe use next, rata_
17:18rata_but next returns nil instead of '()
17:18pppaulyeah
17:18pppauli thought that was what you wanted
17:18pppauli dono, i just joined so i don't know what the conversation is about %_%
17:18rata_no, I like '()
17:18rata_pppaul: https://gist.github.com/668294
17:19rata_what does chunk-rest?
17:22rata_does lazy-seq work with transients? or is it unsafe?
17:28rata_ohpauleez: with lazy-seq it doesn't stack-overflows and it runs in just 19 millisecs! that's impressive!
17:28rata_no, wait
17:29ohpauleezthat sounds like you have no data
17:29ohpauleezdouble check
17:30rata_yes, a zero was missing... it was just a map with 100 key-value pairs
17:30rata_with 1000 it still overflows
17:30vibranthow to return a seq with the first element copied to the end of it? like [1 2 3 4] -> [1 2 3 4 1]?
17:32vibrantoh ok, concta
17:32rata_vibrant: one way could be (concat coll [(first coll)])
17:32vibrantcat
17:32vibrantyea just found this obvious answer :) i was trying to use into but that prepended for a list.
17:33Chousukedon't use that too much though
17:33Chousukeyou'll blow your stack :P
17:33vibrant(defn points->lines [pointseq]
17:33vibrant (partition 2 (interleave pointseq (concat pointseq [(first poitseq)]))))
17:34vibranti'm converting a list of points defining a polygon to a list of lines
17:34vibranterr rest pointseq should be there
17:34Chousukeseems fine then
17:35rata_I've appended the lazy-seq version... both overflow :(
17:35rata_https://gist.github.com/668294
17:35vibrantit's damn elegant, Clojure is
17:36rata_vibrant: yes :)
17:36rata_the lazy-seq version is just a bit slower than the one using transients, but I think I prefer the lazy one
17:36vibranthm.. apply doesn't work with Java static methods?
17:37rata_but the stack overflow is still there
17:37ohpauleezrata_: I too like using laziness. It looks logical and concise
17:38rata_yes
17:38apgwoztechnomancy: do you know if tables work in epresent?
17:38ohpauleezrata_: http://georgejahad.com/clojure/cdt.html
17:38pppaulhas anyone used {:test ...} and (test ...)?
17:39ohpauleezWith the laziness you definitely shouldn't be getting overflows
17:39ohpauleezI'm at work and have to finish some things up, but if you push this entire thing to github, feel free to ping me
17:39ohpauleez(in case you don't figure it out)
17:40apgwoztechnomancy: nevermind, doesn't look like it. seems to be psuedo org-mode syntax
17:40rata_ohpauleez: the entire thing is in github... this is part of a library I'm developing
17:40ohpauleezlink me
17:40rata_and it doesn't has to do with holding onto the head, because it overflows with dorun too
17:41rata_http://github.com/rhz/kapjure
17:41rata_sorry... you need the line
17:42rata_ohpauleez: https://github.com/rhz/kapjure/blob/master/src/kappa/language.clj#L60
17:42ohpauleezthanks
17:43rata_that's the old version though... the super-slow one
17:43ohpauleezkeep poking at it, and I'll ping you later when I'm back in commission to see where you are with it
17:43rata_ok, thank you a lot :)
17:45leifwoh here's something that's bugged me for some time now
17:45leifwif I define a function with :pre and :post conditions, is there a way to disable them when I want code to run fast?
17:46leifwfor example, I have some math utilities that I gave pre and post conditions to check my sanity, but they get run extremely frequently, and those conditions make up a significant overhead
17:47leifwshort of commenting them out and re-evalling them, is there something like *warn-on-reflection* I can change that will affect the interpreter that way?
17:47vibrantany clean way to circumvent the fact that apply doesn't work on java static methods?
17:47leifwvibrant: example?
17:47vibrantleifw; it should work?
17:48leifwdunno, what's the error you get?
17:48leifwI was just going to try what you're trying myself
17:50pdloganleifw: you probably have to wrap the java method invocation in a function.
17:50vibrantCaused by: java.lang.Exception: Unable to find static field: linesIntersect in class java.awt.geom.Line2D
17:51vibrantI guess it doesn't know which one to pick since there are many methods with that name
17:51vibrantjust different signatures
17:51ohpauleezleifw: There is another contract library around somewhere on github, because of these issues and a few others with :pre and :post. I haven't used it, but I've looked through it
17:52leifwyeah, I think you need to wrap it in something that calls linesIntersect in first position with all positional arguments present, so it can determine which one to select
17:52ohpauleezfogus_'s trammel: https://github.com/fogus/trammel
17:53ohpauleezit essentially decouples the contracts from the function
17:53leifwso (apply (fn [l1 l2] (Line2D/linesIntersect l1 l2)) lines)
17:53ohpauleezwhich is nice
17:53leifwwhich isn't really as nice as you'd hope
17:53ohpauleezleifw: ^^
17:53leifwmaybe (defmacro apply-static [f & more] ...)
17:53Chousukenoooooooooooooooooo
17:54leifwif you expand the apply at macro expansion, maybe it works?
17:54Chousukeapply can't be expanded
17:54leifwohpauleez: thanks, I'll look
17:54pppaulapply-macro
17:54pppaul(doc apply-macro)
17:54clojurebotHuh?
17:54Chousukeunless maybe if you have a literal vector
17:54Chousukewhich makes the apply pointless
17:54leifwyeah I guess so
17:55leifwwell
17:55Chousukeanyway, hm
17:55vibrantpppaul; looks nice :)
17:55leifwusing the anonymous function wrapper is the only correct way I can think of, in that case
17:55Chousukeyou can always wrap that method in a named function
17:55tomswEvening all. Does anyone know if it's possible to create a class with gen-class with some state accessible to all instances?
17:56Chousukeor destructure the line vecotr and call the static method afterwards
17:56leifwohpauleez: do you have a link?
17:56pppaulapply-macro is my favourite!
17:56ohpauleezleifw: It's up above (fogus_'s trammel: https://github.com/fogus/trammel)
17:57leifwoh haha did not see that
17:57leifwthanks
17:57ohpauleeznp :)
18:01vibranthumm.. so how do i return a vector from an anonymous function? this doesn't work, treating the vector as a function #([(.x %) (.y %)])
18:01Derandervibrant: (vec [2 3])?
18:02leifwvibrant: #(identity [elem ents])
18:02leifwor that
18:02vibrantoh yea just guessed hehe
18:02Deranderidentity is probably better
18:02Deranderbut I dunno
18:02leifwI seem to remember identity being suggested as idiomatic, but both work fine I'm sure
18:02tomsw(constantly [a b c])?
18:02leifwhah nice
18:02Derander,(constantly [1 2 3])
18:02clojurebot#<core$constantly$fn__3551 clojure.core$constantly$fn__3551@1eee6b2>
18:03leifwignores arguments though
18:04romain_pHi, can someone tell me what is wrong with the following:
18:05tomswoops. how about #(do [ ... ])? It's short (although sounds too imperative)
18:05romain_p(defn make-lines [data]
18:05romain_p"Generates a collection of svg line elements based on the supplied data points"
18:05romain_p (for [idx (count data)
18:05romain_p prev-val (nth data idx)
18:05romain_p this-val (nth data (inc idx))
18:05romain_p :when (and prev-val this-val)]
18:05romain_p (make-line idx prev-val (inc idx) this-val)))
18:05leifwromain_p: paste it please
18:05leifwerr, pastebin it please
18:05romain_pleifw: ok, will do
18:06leifwromain_p: but I think, if make-line is something you expect to run (and it isn't running), you're being bitten by the fact that for is lazy
18:06leifwromain_p: wrap it in dorun or something to force it to execute
18:06vibranti want to implement nth for an arbitrary java class, is there some protocol already containing nth or should i write one?
18:06romain_pthe error I get is "cannot create ISeq from Integer" or something
18:07leifwromain_p: you want [idx (range (count data)) ...]
18:07KirinDavechouser: You around?
18:09romain_pleifw: really? I just wanted an index
18:09leifwthe for loop is going to try to iterate over (count data), which is an integer
18:10romain_pleifw: i copied the whole source over at http://pastebin.ca/1985803
18:10romain_pleifw: OK
18:11vibrantwow, my nth is overriding the orginal one.
18:11leifwI expect you want this: https://gist.github.com/668451
18:11leifw,(doc for)
18:11clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of e...
18:12vibranthttp://pastebin.ca/1985804 any idea how to make (nth Vec2instance) work if Vec2 is a Java class?
18:12leifwromain_p: "binding-form/collection-expr pairs"... every other element in the for loop's binding forms vector needs to be a collection
18:13hiredmanvibrant: you can't
18:13romain_pleifw: I want almost this, but not quite.
18:13hiredmannth works on certain interfaces, and certain classes
18:13romain_pI need the :when test to avoid an OOB exception
18:13vibranthiredman; oh, shitty. so any elegant way to make it 'just work'? or do I have to convert manually if I want to use it in place of a vector?
18:14romain_p(or do I?)
18:14hiredmanif you have control of the java class you can have it extend one of the interfaces
18:14leifwromain_p: just don't let idx range that far?
18:14leifwhold on there's a better way to do this
18:15vibranthiredman; well.. i don't want to butcher java classes. i thought it'd be possible to do it externally after reading a bit about protocols. so i'll just convert i guess.
18:15hiredmannth is not a protocol yet
18:15vibrantok
18:18romain_pleifw: tx, that does it (of course if you have a more elegant solution...)
18:18leifwI'm working on it, I forgot the name of a function but I'll have a more elegant one soon
18:20leifwromain_p: https://gist.github.com/668451
18:21leifwpartition does what you want
18:21leifwactually, I'm missing the rebinding and the index, just a sec
18:22romain_p,(doc partition)
18:22clojurebot"([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a ...
18:23leifwall better
18:23leifwrefresh that page
18:24technomancypartition's docstring needs "you probably want partition-all" appended to it
18:24romain_pleifw: OK, I refreshed it.
18:24leifwoh right, partition won't return the last thingy, you can drop that :when condition
18:25leifwin this case, you *do* want partition, not partition-all
18:25romain_pNow I'll need to spend some time with the docs :_
18:25romain_p:)
18:25romain_pthanks, it's much terser anyway
18:25leifwrefresh one more time, should still work
18:26technomancywow, an actual use case for partition... first time for everything I guess =)
18:26leifwheh technomancy :)
18:26Deranderpartition is my new inject
18:26DeranderI'm trying to find a use case for it and I don't fully understand it
18:26Deranderinject == reduce*
18:26Deranderas soon as I find one I'm sure everything will look like a candidate for parttion
18:27leifwI've really only used it with interleave to create what I usually know as zip
18:27romain_pleifw: yup, still works
18:27leifwsweet
18:28leifwclojure has this annoying quality where it thinks "zip" is something totally different from what I think it is
18:28romain_pgotta get some shut-eye, but thanks a lot!
18:29Derander,(partition 2 [1 2 3 4)
18:29clojurebotUnmatched delimiter: )
18:29Derander,(partition 2 [1 2 3 4])
18:29clojurebot((1 2) (3 4))
18:29Derander,(partition 2 2[1 2 3 4 5 6])
18:29clojurebot((1 2) (3 4) (5 6))
18:29Derander,(partition 2 2 [1 2 3 4 5 6])
18:29clojurebot((1 2) (3 4) (5 6))
18:29Derander,(partition 2 3 [1 2 3 4 5 6])
18:29clojurebot((1 2) (4 5))
18:29Deranderhuh. interesting
18:29leifw,(partition 3 2 [1 2 3 4 5 6])
18:30clojurebot((1 2 3) (3 4 5))
18:30vibrantwow this is elite, i just wrote a ray caster to detect line-of-sight in 20 lines of code, as opposed to a version I saw in Java in 100 lines.
18:30leifw,(partition 3 2 [1 2 3 4 5 6 7])
18:30clojurebot((1 2 3) (3 4 5) (5 6 7))
18:33DeranderI am le tired
18:33studybot_,(partition 2 3 [1 2 3 4 5 6])
18:33clojurebot((1 2) (4 5))
18:35leifwDerander: me too, might have something to do with this class though
18:35DeranderI just never sleep :P
18:40WilduckSo, I just picked up "joy of clojure" and got to the section on the .. macro, but someone mentioned it was deprecated. Should I ignore this section then?
18:40KirinDavechouser: Ping?
18:41leifwWilduck: yes, -> is better
18:41leifw,(doc ..)
18:41clojurebot"([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on t...
18:41WilduckI guess I have to wait untill chapter 8 to learn about this then...
18:42Derander,(doc ->)
18:42clojurebot"([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts ...
18:43Derander,(doc ->>)
18:43clojurebot"([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 fi...
18:49KirinDaveHum
18:49KirinDaveAnyone here use error-kit?
18:49KirinDaveI'm having a weird error with it.
18:50ohpauleezKirinDave: Ironic isn't it. I have indeed used it, but have moved to using conditional
18:51KirinDaveohpauleez: Conditional?
18:51ohpauleezcondition*: http://richhickey.github.com/clojure-contrib/condition-api.html
18:51ohpauleezit's sort of a round 2 for error-kit
18:55technomancyit's more like round 2 for exceptions
18:55KirinDaveWhich is preferred?
18:55KirinDaveAnd more importantly, does it have something like continues?
18:55KirinDaveThat's something I use heavily
18:55ohpauleezbut with lessons learned from error-kit
18:56hiredmanKirinDave: condition lets you catch and throw maps, basically
18:56KirinDavehiredman: But can you continue from the point of a raise?
18:56KirinDaveIn other words, can you have error handling strategies at the point of the rase?
18:57hiredmanKirinDave: you can throw a map that contains a function to continue at if you would like
18:57pppaul,(testing-vars-str)
18:57clojurebotjava.lang.Exception: Unable to resolve symbol: testing-vars-str in this context
18:57hiredmanit doesn't have built in functionality for it
18:58KirinDavehiredman: But that's the most awesome part of error-kit, and common-lisp style exceptions in general.
18:58hiredman*shrug*
18:58pppaulcommon lisp is going to hell
18:59KirinDavepppaul: So? That doesn't mean it isn't full of awesome stuff.
18:59pppaulyes
18:59pppaulthe hell of awesome
19:00KirinDavehiredman: I take it you've never used them.
19:00LOPPI <3 CL :P
19:00KirinDavehiredman: Even you can't be such a hater as to dismiss that power. It's pretty effin' incredible.
19:01hiredmanas I said, you if you want to throw a continuation you can
19:03technomancyKirinDave: yeah, c.c.condition is not as ambitious as error-kit. on the other hand, it's more accessible, and a lot more people use it.
19:04technomancyaccording to rich's conj talk, rebinding some kind of error-handler var is "good enough" to for most use cases of CL restarts.
19:04KirinDavetechnomancy: I'm glad to hear that.
19:04KirinDavetechnomancy: I was worried I agreed with Rich too much. :)
19:04technomancyhah
19:05hiredmanI don't recall rich saying that
19:05KirinDaveYou can make a strong argument that separating handlers and continues is demonstrably better than classical error handling.
19:05hiredmanI recall him saying that error handling was one of his envisioned use cases for dynamic vars
19:07KirinDaveBut I suppose having that power is unfamiliar and most people have their hands full not programming java-in-clojure.
19:09hiredmanyou can (binding [*handle-error* some-logging-function] (try .. (catch Exception e (*handle-error e))))
19:09hiredmanthen any place inside the try set! *handle-error*
19:09KirinDavehiredman: But that means you're putting the logging/handling stuff up there at the top.
19:09KirinDaveAnd yes, but why not formalize that to continues?
19:09hiredmanyou could
19:10KirinDavehiredman: So why do people seem to think that's not an awesome idea?
19:10hiredman*shrug*
19:59Raynessexpbot: kill
19:59sexpbotKILL IT WITH FIRE!
20:02pppaul:)
20:02rata_how do I get a chunked seq from a non-chunked seq?
20:06DeranderI have a hash map that goes {html-element html-element's-children, anotherone-..}
20:06Derandermy goal is to get a list of html-elements whose children pass a filter
20:07Deranderhow should I go about this?
20:07Deranderactually, I think I can do this better.
20:07tomojrata_: why do you want to do that?
20:07tomojDerander: are you parsing html on your own?
20:07clojurebotGabh mo leithscéal?
20:07rata_tomoj: to see if that increases performance
20:08Derandertomoj: well, I have a dOM
20:08DeranderDOM
20:08tomojI see
20:08tomojdo you already know about the xml-zip stuff?
20:09DeranderI do not understand zippers well enough to work with them
20:09tomojright
20:09tomojwell
20:09tomojas it happens
20:09tomojthere's also zip-filter
20:09Deranderyes
20:09tomojwhich saves you from low-level zip work
20:09DeranderI tried using zip-filter on an xml-zip of an html page
20:09tomojright, it's really quite nice
20:09DeranderI do not understand how the fuck zip-filter works, and there is no documentation anywhere
20:10tomojif you like I can try to help you understand? or you never want to see it again? :)
20:10Derandermy goal is to find the div with the largest number of immediate-children paragraphs
20:10DeranderI do not know how to translate that into zip filter speak
20:10tomojvery interesting problem
20:10tomojer, solution
20:10Deranderit's not bad at all w/ a dom
20:11tomojwhich solves a problem I was talking about today.. :)
20:11Deranderfind all the divs, sort by children "p"s
20:11tomojso what's the filter? div with child p's ?
20:11Deranderyes
20:12Deranderassuming regular html, divs are children of body, etc
20:14Deranderinternet flicker, last thing I would have seen was "tobiassp has left IRC"
20:14tomojside question: can we always expect to find p's only in divs?
20:14Deranderno
20:14Deranderunfortunately
20:14Derandernor does every div have a p
20:15tomojoh well
20:16tomojhuh, can you even easily get your dom into a format that will work with zip-filter xml stuff?
20:17Derandertomoj: yes
20:17Derandertomoj: I went down this path earlier; I have a code branch that parses html into an xml-zip
20:18tomojhm
20:18tomojtake the winning div
20:18tomojif it has div ancestors, what should you do?
20:19tomojtake the innermost div which still has the most p's?
20:19tomojoh, immediate-children
20:19tomojnevermind
20:20Derandertomoj: yeah
20:21rata_some clojure guru can help me with this? I'm getting a stack overflow https://gist.github.com/668294 (the lazy version, second file)
20:22rata_I don't even have a clue of what can be the cause of that overflow
20:22rata_it happens when I give get-complexes a map with more than 977 key-value pairs
20:32tomojDerander: well..
20:32tomojI couldn't remember how it worked off the top of my head
20:33tomojso I think I solved your problem
20:33tomojthere's gotta be a better way to do it, though
20:34Derandertomoj: you solved it?
20:34Derandertomoj: and yeah, I'm sure you can do it w/ zip filters
20:34Deranderor something
20:35Deranderwell, I do have one question.
20:35Deranderoh, never mind.
20:35tomojhttps://gist.github.com/8b2564ef082b942f3af8
20:35tomojone problem I always had with xml-> was combining them
20:36tomojin this case it works out, but if your first xml-> returns a seq of locs, you can't just funnel that in
20:36tomojwhich seems weird because each stage of xml-> normally can pass seqs
20:39Deranderyeah
20:39Deranderperhaps a map or something?
20:40Derandersorry, brain is being split in too many directions
20:43Deranderwell, I've solved the problem w/ the DOM method
20:44tomojDerander: you aren't doing automated browser stuff, are you?
20:45Derandertomoj: I don't think so
20:45DeranderI'm just parsing html pages for content
20:45tomojoh
20:45tomojwhat are you using for parsing?
20:46Derandera combination of HtmlCleaner, wc3.dom's stuff, and my own clojure code
20:46tomojI need to find a parser soon
20:47Deranderfor html?
20:47tomojdid you investigate enlive?
20:47tomojyeah
20:47DeranderI tried using enlive
20:47DeranderI couldn't figure out how to make it do things like "find me the parent of this element"
20:47DeranderI don't really need css selector searches
20:47tomojI still don't understand it
20:47Deranderthere is already something that does what I'm doing, basically
20:47Derandercalled webmine
20:48Derandercame out *this morning*
20:48Deranderbut I figure that I'll finish out this aspect of my project as a learning experience
20:48tomojwow, thanks
20:49tomojI think I'll use that to write a nutch plugin
20:49tomojif I can figure out how to
20:49tomojnutch is in a bad way :(
20:49rata_help
20:49Derandernot familiar with nutch
20:50Deranderis there a builtin function that is like max, but that takes a function to determine the weight?
20:50tomojrata_: can you paste the error?
20:50Deranderbasically (conj first reverse sort-by)
20:50tomojDerander: no
20:51tomojbut there is something in contrib I believe
20:51Derandereh, no worries
20:51rata_tomoj: https://gist.github.com/668294
20:51DeranderI can just do first reverse sort-by
20:51rata_the error is a stack overflow
20:52Derandertomoj: the reason I'm doing this is:
20:53DeranderI dump shit on my desktop.
20:53tomojrata_: yes, but I want to see the stack
20:53DeranderI want to write something that tries to categorize and understand meaning behind the shit I dump there
20:53tomojDerander: dude that's brilliant
20:53Deranderso right now I'm teaching it to autotag websites
20:53tomojI want to build an app like that too
20:53tomojhave you seen apache tika?
20:53Deranderno
20:53tomojit can parse PDF text out
20:53Deranderdammmn
20:53tomojwhich I need to categorize all these damn papers
20:53DeranderI'm going to put that on my website
20:53Derander:P
20:53Deranderdesktop*
20:53tomojit's pretty easy to use from clojure
20:54tomojit has html parser too I believe but I dunno what the hell they produce
20:54DeranderI had a little glue code that would dump word frequencies of weblocs into mongodb
20:54tomojnice
20:54DeranderI realized that it would be better if it actually extracted the "content"
20:54rata_tomoj: ok
20:54Deranderso I'm implementing readability's algorithm
20:54tomojI just figured out how to get nutch to store crawl results in cassandra
20:54Derandernice
20:54DeranderI've never worked with cassandra
20:54tomojme neither
20:54Deranderhaha
20:55Deranderwell, I am going to go home now.
20:55DeranderI'll see you later
20:55tomojgood luck
20:56rata_tomoj: https://gist.github.com/668294
20:57tomojok, hmm
20:57ohpauleezrata_: how's the battle going?
20:57tomojit looks like your code is doing (filter p (filter p (filter p (filter p...)
20:57tomojfrom the stack at least
20:57rata_bad... I have no clue what could be the problem
20:57tomojwhich is strange
20:57tomojyou have no 'filter' in the code
20:57rata_tomoj: that could be the remove
20:58tomojoh, yes
20:58rata_at line 11
20:58ohpauleezOf course, are you realizing the entire collection when you have to filter it? then making it lazy again?
20:58rata_with a doall there the problem disappears
20:58tomojright
20:58tomojI had a similar problem
20:59tomojat least in symptoms
20:59rata_it's strange
20:59tomojI had code that did (map + (map + (map + (map + ...
20:59tomojor something like that
20:59tomojare you building up a chain of remove operations and then running through the results of the chain only after building it very long?
21:00rata_yes, probably
21:00amalloyyes
21:00tomojbecause then clojure has to go through that entire chain to check whether the first element is in the result
21:00rata_though the lazy-seq there should stop them to being so nested
21:01tomojyou can probably also solve it by putting a call to vec somewhere
21:01tomojnot sure what the real solution is though
21:01tomojsorry, I don't understand the code :(
21:01amalloyrata_: the lazy-seq is exactly what's causing them to be nested
21:02rata_tomoj: it's like a connected-components for graphs
21:03rata_amalloy: then I don't understand lazy-seq at all
21:03tomojyou never change remaining
21:03tomojoh, yes you do
21:03tomojwith the remove
21:03tomojI see
21:04rata_it should really be (rest remaining) there, but remaining works too
21:04amalloyrata_: tomoj had the same problem, as he says, and someone posted an excellent explanation of the issue on g.group
21:04tomojhuh, I don't think I saw that
21:04amalloyi think so, anyway. maybe it was #clojure, but i thought g.group
21:04rata_I remember that problem and I was hoping the whole evening this not to be the same problem
21:05rata_:P
21:06amalloyhttp://groups.google.com/group/clojure/browse_thread/thread/6f5064532546a852
21:06amalloytomoj, rata_ ^^
21:09defnhey everybody
21:09defnRuby is annoying me.
21:10rata_amalloy: then is this a clojure bug?
21:10defn{:foo => "bar", :bar => "baz"} -- this syntax is so heavy! {:foo "bar" :bar "baz"}
21:10amalloyrata_: no, it's clojure being exactly as lazy as you want
21:10ohpauleezdefn: I feel that pain, every single day I have to work on php
21:10ohpauleezamongst other, terrible, terrible pains
21:11rata_mmmm... but much is said about lazyness protecting your code from stack overflows
21:11ohpauleezdefn: The advantage I have is I get to write server technology and system tools in Clojure and Python
21:16defnohpauleez: to ruby's credit the new 1.9.2 syntax is {foo: "bar", bar: "baz"}, but still
21:16defnthere's so much syntactic sugar, but then this obvious pain point is just sitting there
21:18hiredman~#2
21:18hiredmandamn
21:22hiredman~#2
21:22clojurebot2. Functions delay binding; data structures induce binding. Moral: Structure data late in the programming process.
21:22ohpauleezalright! I'm glad that's back
21:25hiredmanit should only be sending the first commit message for each watched repo the first time it runs :/
21:27ohpauleezclojurebot just knows that knowledge is power
21:39tomojit would be cool if vars had timestamps
21:49defntomoj: they can, if you want them to
22:00defntomoj: i take that back
22:04defntomoj: each commit for in transaction and committed values should have a commit timestamp
22:04defn(the point field in the TVal object)
22:05tomojTVal?
22:05defnsrc/jvm/clojure/lang/Ref.java
22:07defntomoj: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Ref.java#L47
22:08defntomoj: im just not sure if you can get at these values
22:08defntomoj: where do you intend to use timestamps?
22:09tomojI don't actually
22:09tomojI was thinking of tests
22:09tomojautomatically run only the tests that need to be run based on when each fn has last been changed
22:10defnthat's sort of a biased watcher
22:10defnwouldn't you agree?
22:10tomojdunno what you mean
22:10defnare you talking about contiunous testing?
22:10tomojyeah
22:10defnautotest, etc.
22:10tomojright
22:11defnwhy wouldn't be monitoring the file be the best course of action there?
22:11defns/be//
22:11sexpbot<defn> why wouldn't monitoring the file the st course of action there?
22:11tomojmaybe it would be
22:12defna language feature to facilitate continuous testing just seems wrong-headed to me
22:12defnthe filesystem changes are more obvious, but there's probably something to what you're syaing
22:12tomojwell, hmm
22:12tomojimagine that when you change a function, the tests are run for every function which calls that functnio
22:13tomojI guess if that were useful, you don't have good isolation in your tests
22:13defnhow much of lazytest have you read?
22:13tomojnone
22:13tomojnever used it
22:13defncheck out that, and midje
22:13tomojmidje the mocking framework?
22:13tomojI was actually originally thinking: mock with metadata
22:14defni'd say it's more than just mocking,no?
22:14tomojdunno
22:14tomojnever looked at it
22:14defnit's cool -- brian marick has good ideas and knows testing
22:15tomoj(deftest test-multiplication (is (* ^3 (+ 1 2) ^6 (+ 3 3))))
22:15tomojI don't know testing
22:15tomoj:(
22:15tomojwell that made no sense
22:15defnand lazytest -- stuart sierra
22:15defngood stuff.
22:15tomojshould've been (is (= (* ..) 18))
22:16tomojI was thinking it might be good to put expected values and actual use examples near eachother
22:16amalloyanyone know of a macro that's the opposite of :keys destructuring? i'd like to take N bound locals and cram them into a map, indexed by the keywordized versions of their names
22:16tomojthen you can switch off using the expected value or actually using the code to determine where the error really is?
22:16amalloyeasy to write myself, but if one already exists i'd rather us it
22:16tomojamalloy: I have just the thing
22:16tomojmaybe
22:17defnnot if i beat you to it
22:17amalloy#clojure: Competitive Helping capital of the world
22:18tomojamalloy: https://gist.github.com/2f060dde83ac1bfbe551
22:19tomojsomething like that?
22:19defngah!
22:19tomojnot sure if I understood what you meant
22:19tomojdefn: note the date
22:19defn:)
22:19amalloytomoj: yeah, i remember talking with you about this on #clojure back then
22:19defni have too many sandbox directories...
22:20defnit's in /one of these/ projects
22:20tomojamalloy: I guess it doesn't solve you problem then?
22:20amalloyi don't want to rebind or modify any locals, just build a map of locals i already have
22:20tomojI made a "scratch" lein project
22:20tomojamalloy: so, like, what?
22:20defnls -la ~/git | wc -l => 54
22:21tomoj(mapmap [foo bar baz])?
22:21amalloytomoj: right
22:21tomojexcept mapmap is a terrible name
22:21amalloysure
22:21amalloykeywordize is my code name :P
22:21hiredmanmuch better
22:22amalloy(defmacro keywordize [& vars] `(zipmap ~(map keyword vars) ~vars))
22:23amalloyi mean, it's really easy to write, but i don't want to roll my own if one exists, is all
22:24tomojhmm
22:24tomojthat doesn't work for me
22:24tomojhow would you call it?
22:25tomoj(defmacro mapmap [ss] (into {} (map (juxt keyword identity) ss)))
22:25tomojor [& ss]
22:25tomojis what I thought you meant
22:29amalloytomoj: sorry, semi-afk. that's probably what i meant
22:29hiredmanhttps://gist.github.com/668652
22:30amalloyhiredman: haha, that's cute. i guess if i want to capture everything, that works
22:31amalloyand tomoj, that one's exactly what i was looking for, though i'll play around a bit to understand why mine doesn't work
22:33hiredmanbecause your's expands into a function call
22:33hiredman~vars
22:33clojurebothttp://www.slideshare.net/mudphone/fun-with-vars
22:34amalloyoh, i see. so it'd have to be ~(vec vars) if i wanted to do it my way
22:40tomojhiredman: thanks!
22:40tomojI'd never seen a decent use of &env before
22:40Deranderis lein swank still hardcoded to 4005?
22:40tomojthought you had to dig down to java
22:40tomoj`lein swank PORT` or `lein swank PORT HOST`
22:40Deranderah, thanks.
22:40Derander,(doc into)
22:40clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
22:42hiredmantomoj: https://github.com/Seajure/serializable-fn/blob/master/src/serializable/fn.clj
23:07rata_so strange, rand-nth throws an IndexOutOfBoundsException https://gist.github.com/668678
23:26leifwrata_: on what code
23:27rata_(defmethod choice clojure.lang.IPersistentVector [v] (rand-nth v))
23:27leifwwell color me baffled
23:29leifwwhat do you pass in?
23:30leifwI mean, the only problem I can imagine is if you somehow passed in an infinite seq, which you can't do because it's a method of a vector...
23:30leifwso I dunno what I'm expecting you to say
23:30rata_wait me a sec... I'm at another bug right now... maybe solving this one solves that one
23:37rata_weird bugs
23:40rata_I'm going to work on these random bugs tomorrow
23:40rata_it's too late now
23:40rata_good night :)
23:40rata_see you