#clojure logs

2008-11-17

03:14Lau_of_DKMorning gents
04:20pollianyone using webjure?
04:29tWippolli: me, but I am the author
04:29pollioh :)
04:30pollitWip: I'm having some problems let me see if I can sort them out
04:31tWippolli: ok, you can report bugs in the project or ask me directly
04:31tWipI'm planning to do some work on it this week to catch up with clojure changes
04:31tWipbut now I'm on my employers time, so I'll check back in the evening :)
04:36pollitWip: I'll send you a diff
05:09PupenoGood morning.
06:03PupenoHello Lau_of_DK.
06:06Lau_of_DKHello Mr. Pupeno :)
06:07PupenoLau_of_DK: how are you doing?
06:07Lau_of_DKPupeno: Im doing good thanks, you ?
06:10PupenoLau_of_DK: I've got a cold, but I'm doing ok.
06:10Lau_of_DKPupeno: Many peopl sick these days :(
06:12PupenoLau_of_DK: More Clojure time! :)
06:14duck1123are either of you doing Clojure for your work, or only on your own time?
06:14Lau_of_DKduck1123: a bit of both
06:15Pupenoduck1123: only my own time for now.
06:17Pupenoduck1123: and you?
06:17duck1123currently my own time, but I have some ruby code that I'm thinking of translating
06:19duck1123but I've been doing a web site with Compojure on the weekends
06:19Lau_of_DKCan we see? :)
06:22duck1123http://kronk.homedns.org:8080/
06:22duck1123I spent the weekend fighting the Jena api
06:23duck1123at least, when my wife wasn't on the computer
06:24Pupenoduck1123: what is it?
06:25duck1123it's going to be a site for managing rdf assertations
06:25duck1123I'm still not very far
06:38PupenoIs there a better way to write (map (fn [x] (.blah x)) xs)? that is, without defining the anonymous function.
06:39Lau_of_DKYou mean like (map #(+ 5 %) (range 10)) ?
06:40mibuduck1123: what does it mean managing rdf assertions?
06:41PupenoLau_of_DK: is #( the syntax for defining a function without spelling out fn?
06:41PupenoLau_of_DK: I meant something like (map .blah xs), where blah is a Java method, except that (map .blah xs) doesn't work.
06:41mibupupeno: (map #((.blah %)) xs)
06:42mibupupeno: the extra parens inside shouldn't be there.
06:42Lau_of_DKuser> (map inc (range 10))
06:42Lau_of_DK(1 2 3 4 5 6 7 8 9 10)
06:42Lau_of_DK
06:43PupenoLau_of_DK: but I want to use a java method, not a clojure function.
06:44mibu(map #(.toLowerCase %) '("Hello" "World"))
06:45Pupenomibu: that still defines an anonymous function.
06:45mibuduck1123: are you using an RDF store?
06:45PupenoWhat I really wanted to know if there's a way to treat java methods as functions, maybe there isn't.
06:50mibudo you guys use enclojure?
06:51Pupenomibu: I've tried.
06:51mibuit messed up my netbeans.
06:51mibupupeno: did you have any troubles with it?
06:51hoeckPupeno: http://paste.lisp.org/display/67182
06:53Pupenomibu: I don't remember why I moved to NetBeans 6.5 and trunk for Enclojure and it just didn't work. Ended up using Emacs. Not sure if I could say it messed up my NetBeans, as it looked messed up from the start.
06:56PupenoOK, I bet there's a very simple way to do this, but I cant find it. How do I turn `((a b) (c d)) into '(a b c d)?
07:15Pupeno(reduce concat list-of-lists) seems to do the trick.
07:15ChousukePupeno: I don't think there's a way to map java methods without wrapping them
07:18ChousukePupeno: #(.foo %) is the preferred method nowadays I think, but there's also (memfn foo)
07:19PupenoChousuke: I see. Well, the existence of memfn kind of prooves your point there.
07:19Chousukethe clojure compiler could try to be smart and detect when you're trying to use a java method as a Fn though, so that you could just (map .foo java-objects) :/
07:20Chousukebut maybe that's going past the level of cleverness allowed for a compiler :)
07:23hoeckPupeno: there is java Reflection, see http://paste.lisp.org/display/67182 for an example
07:24Chousukememfn does that.
07:26PupenoOk... time to learn how to play with a DB from Clojure.
07:26Lau_of_DKPupeno: post your findings :)
08:09ranokhaha
08:09ranokBill C's homepage is pretty awesome
08:10Lau_of_DKlink0r?
08:10ranokbillc: Mine is quite similar, though I wasted way too much time on mine http://jacobtorrey.com
08:10ranokLau_of_DK: http://bc.tech.coop/
08:10Lau_of_DKthanks
08:16Pupenois http://mvnrepository.com/ down?
08:17duck1123ded for me
08:17duck1123loaded
08:18duck1123took a little while, but seems fine in w3m at least
08:18Pupenook, thank.s
08:19duck1123has anybody been working on an ORM for Clojure?
08:19gnuvinceNo that I've heard of
08:19pollitWip: I've sent you a patch
08:20Pupenoduck1123: well, the O doesn't make much sense in Clojure world, doesn't it?
08:20Pupenoduck1123: a SRM would be nice though (Structure Relational Mapping).
08:20duck1123DSRM?
08:22duck1123I'm getting sick of writing SQL queries.
08:23Chouserduck1123: would you be any happier if writing SQL queries was string mangling? Such as if it were a nice Clojure-y DSL?
08:24Lau_of_DKHad a good nights sleep Chouser? :)
08:24duck1123Chouser: that would make it a bit nicer
08:24ChouserLau_of_DK: yes thanks!
08:24Chouserduck1123: I don't know of such a beast yet, but I've been pondering it some. I think it's what I want.
08:25PupenoI think something like cl-sql would be nice, like (select [table1 table2] :where (= blah bluh)) etc.
08:25tWippolli: Got it, thanks. I'll apply it when I get home.
08:26duck1123speaking of, is there a better way to concat strings then (apply str (concat s1 s2)) or using format?
08:28Lau_of_DKuser> (str "string1" "string")
08:28Lau_of_DK"string1string"
08:28Lau_of_DK?
08:29duck1123hmm, I thought I tried that... I'll have to see again
09:18lisppaste8blackdog pasted "require?" at http://paste.lisp.org/display/70567
09:18blackdog_how come the commented out require works and the other does not?
09:18blackdog_doesn't find clojure.contrib.sql in the (require) version
09:24duck1123try (:require (clojure.contrib [sql :as sql]))
09:24duck1123at least, that's how I always do it
09:26blackdog_duck1123, nope that doesn't work, - thought :require was part of ns?? but O want to require without defininf a top level namespace as this is just a script
09:28blackdog_(doc require) needs updating for new package structure
09:31duck1123I'm sorry, wrap that in a ns
09:31blackdog_yes, that works
09:32blackdog_but (require) doesn't, I'm in a script and a namespace is irrelevant
09:32duck1123oh... I think I misunderstood your question
09:32Chouserwithout the ns macro, you need to quote the args: (require '[clojure...])
09:32blackdog_ah
09:33blackdog_ok that's better, thanks
09:43blarfwhat is the mod operator?
09:43duck1123rem
09:44duck1123for remainder
09:44blarfis let permitted anywhere?
09:45duck1123you can't let inside of a parameter list i think
09:45duck1123can't think of anywhere else
09:45Lau_of_DKIts a special form, and pretty well documented on clojure.org/special_forms#let
09:47blarfbut if i have my own func: (defn any [cond coll]
09:47blarf (> (count (filter cond coll))
09:47blarf 0))
09:47blarf(any #(= % true)
09:47blarf (let
09:48rhickeyblarf: please paste:
09:48rhickeylisppaste8: url
09:48lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
09:49ranokso
09:49ranokI've been developing my own language
09:50ranokthat is rather lispy
09:50ranokbut has a number of Erlang features
09:50ranokand some other stuff I find lacking
09:52leafwranok: post it, document it, illustrate with good examples. Otherwise why talk about ii.
09:52ranokit's still very early in it's development
09:52leafwthen tell us next year :)
09:53ranokit auto memoizes clean recursive lambda funcs
09:53ranoksomething I've found lacking in a number of other language
09:53ranoks
09:55ranokleafw: http://www.r4n0k.com/2008/10/28/new-programming-language-fang/
09:55ranoksince you asked
09:56Lau_of_DKranok: sounds interesting :) Maybe you should launch #fang for it, if it can raise a community?
09:57ranokLau_of_DK: thanks
10:03Lau_of_DKuser> (time (dorun (map #(if (prime? %) 0 -2) (range 1000000))))
10:03Lau_of_DK"Elapsed time: 2716.511874 msecs"
10:03Lau_of_DKnil
10:03Lau_of_DKuser> (time (dorun (pmap #(if (prime? %) 0 -2) (range 1000000))))
10:03Lau_of_DK"Elapsed time: 13219.155438 msecs"
10:03Lau_of_DK
10:03Lau_of_DKDoes anybody know why pmap gives the worst performance of the 2 ?
10:04ranokLau_of_DK: you on a multicore?
10:04Lau_of_DKYes sir
10:04ranok2 cores?
10:05Lau_of_DKYes sir
10:05wwmorganLau_of_DK: did you try it more than once? There may be some JVM optimizations going on
10:05Lau_of_DKTried it a few times yes, gives same results
10:07ranokperhaps there is some lock contention with the 2 cores
10:07Lau_of_DKI'd say thats impossible?
10:08Lau_of_DKBoth cores go up to about 60% laod each once I start computing
10:09rhickeyuser=> (doc pmap)
10:09rhickey-------------------------
10:09rhickeyclojure.core/pmap
10:09rhickey([f coll] [f coll & colls])
10:09rhickey Like map, except f is applied in parallel. Semi-lazy in that the
10:09rhickey parallel computation stays ahead of the consumption, but doesn't
10:09rhickey realize the entire result unless required. Only useful for
10:09rhickey computationally intensive functions where the time of f dominates
10:09rhickey the coordination overhead.
10:09ranoktry doing something that requires more time on element
10:10rhickeyLau_of_DK: you are not meeting that criteria
10:10blarfis there no zip-function?
10:10ranokbecause isprime? is tiny, so most of the time is spent scheduling the work
10:10Lau_of_DKoh, because time of f is not big enough ?
10:10Lau_of_DK@ rhickey ?
10:10rhickeyLau_of_DK: right
10:11Lau_of_DKrhickey: thanks :)
10:11ranokyeah, run something like factorial
10:11blarfis there no zip-function?
10:11hiredmanblarf: interleave?
10:11rhickeyblarf: doing what? map list?
10:19blarfzip [1 2 3] [4 5 6] -> [[1 4] [2 5] [3 6]]
10:19blarfi wrote one, just owndering if there is one
10:20gnuvinceblarf: (map vector [1 2 3] [4 5 6])
10:20rhickeyNo there isn't as (map vector [1 2 3] [4 5 6])
10:20rhickeyis so easy
10:21rhickeyas is map list, map hash-map etc
10:22blarfi see, more general than normal zip
10:24gnuvinceblarf: that's because map can take more than one collection, unlike in a language such as Haskell.
10:25gnuvincewhich is why they got zip up to zip8 or something
10:46blarfcant i define a function inside a function?
10:46blarfgnuvince: lol zip8
10:47rhickeyblarf: (let [foo (fn [bar] ...) ...
10:47blarfyes that is a bit weird with Haskell, why cant i have multiple argument list? because of the purity?
10:48gnuvinceblarf: because of the type system
10:48gnuvinceAnd I was wrong
10:48gnuvinceIt stops at zip7
10:48gnuvincehttp://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v:zip7
10:53ReplRatDoes anybody know how to make Emacs see an external Slime info tree? It already loads the elisp OK.
10:54blarfhow do i call Javas round method? i forgot the ynstax
10:54wwmorganblarf: (Math/round 2.5)
11:03blarfhow do i repeat an action ? like i want to test (Math/round (* (rand) 10)), can i do (run-times 100 f) ?
11:03blarfrepeat is not what i want
11:04wwmorganblarf: dotimes is what you want
11:04rhickeyblarf: there is dotimes and repeatedly
11:12tWipWhat class loader is the agent system using? I'm getting weird ClassCastExceptions for the same class when using agents from servlets.
11:12tWipor rather, how do I control it
11:14rhickeytWip: are you doing add-classpath?
11:14tWipno
11:16rhickeytWip: it's hard to answer generally, as servlet containers mess with classloaders
11:16tWipyes
11:16tWipbut is there a way I can control it?
11:17tWipI could easily set the classloader in some initialization code so that it is the same as the servlet classes.
11:17rhickeythere is a *use-context-classloader* which, when true, will cause the thread's context-loader to be used
11:17tWipok, so binding that should help... I'll try
11:26rhickeytWip: where is clojure.jar relative to the servlet?
11:26rhickeytWip: i.e. in the servlet or installed in the servlet appserver?
11:26tWipin WEB-INF/lib
11:26ChouserI haven't noticed anybody volunteer to do pretty-printing, but I've not done sufficient CL to know what's desired. It this a good model: http://dspace.mit.edu/handle/1721.1/6503
11:27blarfhow do take input?
11:27gnuvincefrom stdin you mean?
11:28Chouserblarf: you could use read-line
11:28Chouserblarf: or any Java class you choose
11:30blarfI?
11:30blarfyes when i do print in interpreter i want input
11:30blarfwait
11:30blarf(getLine)
11:30blarfor soemthing
11:30blarfin the repl
11:32rhickeyChouser: looks interesting, if somewhat complex. Maybe there's a simpler Scheme pprinter?
11:32blarfhow do i convert to int? (sorry for allt he questions)
11:33Chouserblarf: from what?
11:33Chouserblarf: from string: (Integer. "12") ==> 12
11:33tWipOk I don't get classloader errors anymore.
11:34tWipStill seems that Jetty doesn't like you messing with its request objects from other threads :P
11:37Chouserrhickey: it seems to me that pprinting code differently than non-code data will be more complex, but worth it. Do you agree?
11:42blarfis there a return ala Python? that just exits at a specific place ina function?
11:43ChousukeI don't know if there exist tricks to simulate return, but no.
11:43Chouserblarf: nope. If you feel like you want that, your function is probably straying toward imperative style.
11:46Chousukefunctional style can be difficult to reason about, sometimes.
11:46Chousukecertainly it is for me.
11:46Chouseryes, it takes practice.
11:46Chousukeusually it helps to scale down your function in that case.
11:46Chousukeif it's getting too complex, write a subset of it as a separate function
11:47Chousukethen use that to write the bigger function
11:47blarfyes, imw riting tictactoe, some stuff just is imperative though (yeah i guess someone willa rgue with that :) )
11:47Chouserno, Clojure's practical. If it has to be imperative, so be it. But you'll have to do it without a "return" :-)
11:48Chousukeyou'll have to think of your code as a series of transformations
11:48Chousukewhen you add a move to the board, the result is an entirely new board.
11:48Chousukeand you discard the old one
11:48Chousukeunless you need it.
11:49duck1123I always make the joke that Lisp syntax sucks, that's why Lisp programmers will do as much as possible by writing very little code.
11:49Chousukejust like when you add 1 and 1 in maths, the result is 2, which is not either of the ones.
11:50Chousukeoptimally there's only one 1 anyway
11:54sohailis there a planet clojure somewhere
11:55blarf(play-game brd)
11:55sohailI've been busy doing other stuff and the mailing list is getting too busy for me to follow
11:55Chousersohail: I don't think so.
11:55blarfjava.lang.NumberFormatException: For input string: " (play-game coll)))"
11:55sohailChouser, are there even enough blogs covering clojure? :-)
11:56danlarkinsohail: there will be eventually!
11:57Chouserbut yes, the google group seemed to explode this weekend.
12:00Chousukeblarf: if you want help with errors, you'll need to give more context. use paste.lisp.org for pastes :)
12:00sohailthe Clojure for LISP (caps!) programmers thread has some interesting posts
12:01Chousukethe OP is being a bit flamey though.
12:02cemericka bit? :-P
12:02Chouseryeah, my natural responses to most of his comments have been... unhelpful, shall we say.
12:03ChousukeI'm not sure if he understands that vectors and maps and sets are equivalent with lists as data structures.
12:04blarfcan if else branch like: if cond (1 expr) (several expr) ?
12:05blarf?paste
12:05Chousuke(if cond (expr) (do (several) (exprs))
12:05Chousukeoops
12:05Chousuke)
12:06hiredmandoes do return the value of the last expression?
12:06Chouserhiredman: yes
12:06ChousukeIIRC yes.
12:09sohailChousuke, if you use erc, I think it is built-in
12:10ChousukeI will not leave irssi :)
12:15askentaskenhmm
12:15askentaskendid the paste come?
12:15askentaskenhttp://paste.lisp.org/display/70574
12:17askentaskenoh wait it does woek now, i have no idea what the error was caused by before though
12:17askentaskenbut how can i better "move"
12:18Chouseraskentasken: what's updateAt?
12:18askentaskenmerging computer-move and player-move but i cant branch the if with lets and then "jump back"
12:18rhickeyChouser: how do you distinguish code from data?
12:19Chouserrhickey: two possibilities: yet another option (just like line length, etc.) or make a guess (PersitentList starting with symbol named def is probably code)
12:20Chousukeaskentasken: camelcase isn't very lispy. :) but hmm
12:20askentaskenChouser: oh my own list-function, perhaps there is a bultin already? it takes a list an index and a value and returns a new list with the val @ index
12:20askentaskencamel-case?
12:20askentaskenhelloThere?
12:21sohailChouser, why do you want to differentiate?
12:21Chousukeaskentasken: yeah
12:21askentaskeni wanted to differ betwene fucntion and variable, is underscore lispier?
12:21Chousukeaskentasken: don't differentiate.
12:22Chousukeaskentasken: they're just names
12:22Chousersohail: (defn foo [a b] **wrap-here** ...) vs. (a b c d e **wrap at end of line**)
12:22Chousukeaskentasken: a function can be used as data too
12:22Chousukelike you do with map there :P
12:22wwmorganaskentasken: move looks like a good place to use a multimethod
12:22drewrChouser: I thought of you when reading http://steve-yegge.blogspot.com/2008/11/ejacs-javascript-interpreter-for-emacs.html
12:23Chouseraskentasken: use a vector instead of a list, and then use assoc instead of updateAt: (assoc [7 8 9] 1 99)
12:23Chouserdrewr: really? Why's that?
12:24Chousukewhat is that updateAt function anyway?
12:24drewrChouser: Implementing JS in lisp I guess.
12:25rhickeyChouser: Clojure->ClojureScript->ejacs->elisp->extending emacs with Clojure!!
12:25drewrNot exactly what you've been doing, but related.
12:25drewrYes!
12:25hiredmanhah!
12:25Chouserah. lovely. :-)
12:25hiredmanmad as hatters
12:25sohailChouser, oh for printing. Is it really important?
12:26Chousersohail: I think for a pretty-printer, it'd be very nice. Think (pprint (macroexpand ...))
12:26hiredmanthat would be nice
12:27sohailI forget, what does slime do with clojure's macroexpand
12:28Chousukewas let a recur target?
12:29askentaskenChousuke: i updated with updateAt
12:30Chousukesohail: it doesn't pretty-print it, that's for sure
12:30askentaskenhttp://paste.lisp.org/display/70574#1
12:31sohailChousuke, ok
12:31Chouseraskentasken: use assoc!
12:34askentaskeni do!
12:34askentaskennow
12:39askentaskenwwmorgan: would a multimethod maie it shorter and make the common tasks in both to one?
12:41wwmorganaskentasken: depends on how you refactor it. What a multimethod would do is make it dead-easy to support different AIs or multiple human players
12:42wwmorganyou would want to do what you suggest anyway, whether you use multimethods or not
12:47askentaskenyes but i dont see how to do it really
12:47askentaskenno matter how i do it seems i need to separate branches
12:47askentaskensince one calls for input
12:48askentaskenyou are right about AIs, isee what you mean, then i could easily define new move for different strategies
12:49askentaskencan i do if-else-let-let?
12:49askentaskenone let if true or else the other let?
12:50kotarak(let [x (if condition a b)] ...) like that?
12:51askentaskenah
12:52Chousukehmm
12:56Pupenolisppaste8: url
12:56lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:57askentaskenhmm the if-else-let still is 10 lines
12:57lisppaste8Pupeno pasted "Failure creating table" at http://paste.lisp.org/display/70577
12:57askentaskenoh well, i will try to figure out multi-methods since that seems the best way if i want to do AI like min-max or soemhting
12:58PupenoAny ideas why that code fails with the error at the bottom?
12:58PupenoI'm trying to create a table with an auto-increment id using derby.
13:04askentaskenwhen using multi-methods, i can have some of them take no args and some taking several or 1 right?
13:04askentaskenlike human-player gives the inout so deosnt need the board(seees it) but computer might need it if it uses a strategy(and not random like now)
13:04Chousukeaskentasken: I made a version using multimethods as an example... I think has-winner? is buggy though :D
13:05Chousukehttp://paste.lisp.org/display/70574#2
13:05topois it possible to use clojure with emacs?
13:06ChousukeI don't know what the purpose of sum-indexes was so I just put in something :P
13:07deklundtopo: see http://clojure.org/getting_started#toc4
13:07askentaskenim tryong to grok the multis, but :
13:07askentasken(defmulti move :player)
13:07askentasken(defn human [] {:player :Human
13:07askentasken :fn (Integer. (read-line))})
13:07askentaskendoes it have to be a {} ?
13:08Chousukekeywords are functions of maps
13:08Chousukein there, :player is actually a function
13:08Chousukeand (:player {:player 'foo}) will return 'foo :)
13:08topook
13:08askentaskenah vr nice Chousuke
13:09Chousukemultimethods are a bit tricky I guess
13:09ChousukeI still don't grok them completely :P
13:10Chousukehowever, the code in my paste seems to work (at least the multimethods) so maybe it'll work as an example.
13:11Chousukeaskentasken: basically, the dispatch-function is a function that returns dispatch values (which can be anything)
13:11askentaskenwhat is buggy about hasWinner? though?
13:11Chousukewell it declares me the winner after the moves "2" and "3"
13:12Chousukebut that might just be my sum-indexes
13:12ChousukeI had no clue what it was supposed to do and didn't feel like thinking so I just put something :P
13:12askentaskennot me....
13:12Chousukewell, your sum-indexes might be doing something else.
13:13ChousukeI see you're using some maths trick to figure out the winner but I wasn't able to tell how it worked.
13:13askentasken(defn sum-indexes [coll indexes]
13:13Chousukeand your original paste was missing sum-indexes :)
13:13askentasken (sum (map #(nth coll %) indexes)))
13:13askentasken(defn sum [coll]
13:13askentasken (reduce + coll))
13:13Chousukehmmh :/
13:13askentaskenyou guessed pretty well
13:16Chousukeanyway, about multimethods: each (defmethod) call defines how to behave for given dispatch values as returned by the dispatch function
13:17Chousukeso (defmethod move :human [whatever here] ...) defines how move behaves when your dispatch function returns ":human"
13:18Chousukeyou can return vectors or whatever from a dispatch function too.
13:19Chousukethat's the entirety of my multimethod knowledge :p
13:19ericthorsenis there a shorter shortcut for default values for keys? (let [{:keys [a b c] :or {a 1 b 2 c 3}) ; I have to type the keys 2x again :(
13:22Chouserericthorsen: I think that's it. If you could have any sytax you want, what would it be?
13:23ericthorsenChouser: I guess something with defaults from a vector bound to the ordinals of the keys...
13:24ericthorsenChouser: Like (let [{:keys [a b c] :or [1 2 3])
13:24Chouserhm, that seems nice.
13:24ericthorsenChouser: I already selected the keys...just need default values for them
13:24Chouserright.
13:31Chouserhm, but you can specify :syms and :strs along with :keys if you want, or specify other map keys on their own. In any of these cases the ordering for an :or vector becomes ambiguous.
13:32Chouserso maybe (let [{:keys [a b c :or 1 2 3] :syms [d e f :or 4 5 6]} ...
13:33Chousukeaskentasken: noticed that there's a nicer definition for print-board too: (doseq [part (partition 3 board)] (println part))) :)
13:37Chousukeheh, found the bug too.
13:37ChousukeI had key and val swapped in assoc
13:37Chousukenow the game runs and works correctly :)
13:46Lau_of_DKGood evening gents
13:50askentaskenyour dose doesnt work
13:52Chousukewhich version of clojure are you using?
13:55askentaskeni can do recursion ina defmethod right?
13:55askentasken20080916 btw
13:58Chousukethat's pretty old
13:58Chousukeyou should be using SVN :)
13:58Chousukethere were some big changes recently.
13:59askentaskenok
14:03danlei`askentasken: you can, but there is no tail-call optimization, you can get that by `recur'
14:04Chouserrecur also works in a defmethod :-)
14:04danlei`yes, that's what i meant
14:05askentaskenyes i know
14:09Lau_of_DKkotarak: I just read your documentation for Euler 191 and 205 + the code. Thanks alot, that was very insightful. Nice consise solutions also
14:10askentaskenhmm actually it would be pretty easy to add AI anyway
14:10askentaskenwithout multimethods
14:10askentaskenmeh them multis break my code
14:10kotarakLau_of_DK: thanks. :)
14:10kotarakLau_of_DK: brute force - beh
14:10kotarakLau_of_DK: in that way it's much more fun
14:11Lau_of_DKThere was some smarts behind it
14:22Lau_of_DKChouser: Have you fixed The Source ?
14:25Lau_of_DK@ everybody: If an agent is send-off to (defn run-oce [a] (dosync (ref-set x y))) does the agent the self destruct after one call to this func?
14:25ChouserLau_of_DK: (source) may be doomed now that .clj files aren't included in clojure.jar
14:29Lau_of_DKChouser: Surely there must be a work0round ?
14:29hiredmanLau_of_DK: does a Thread exist after it has finished running?
14:30Lau_of_DKhiredman: thats the question
14:30hiredmanwell, Thread is an Object
14:31hiredmando Objects hang around when you are done with them?
14:31Chouseragents are not threads. an agent hangs around as long as it's being referenced by something.
14:31Lau_of_DKIf they do, I want to know how to kill them
14:31cooldude127if you lose a reference to an agent, does it go away?
14:31Chouserhiredman: I think Threads are a little different, since they have OS resources.
14:31cooldude127and stop doing its stuff?
14:31Chousercooldude127: yes.
14:31Chousercooldude127: no
14:32Lau_of_DKcooldude127: maybe
14:32cooldude127yes it goes away, but it keeps doing its stuff?
14:32ChouserI think a thread running an action for an agent will continue running and will in fact keep a reference to the agent.
14:32cooldude127so it's not really lost in the gc sense
14:33ChouserWhen the action is complete, if nothing else is referencing the agent, the agent will go away.
14:33cooldude127something still has the reference
14:33Lau_of_DKBut Chouser, why do we always have to (send-off *agent* self) if it lingers?
14:33tWipwhere would it linger? if not referenced
14:33askentaskeni got multis working and its slightly more code but might make it easier to change and work with later
14:33askentaskeni got multis working and its slightly more code but might make it easier to change and work with later
14:34jgracinI wonder who will be the first 100 user in history of Clojure.. :-)
14:34jgracin100th
14:34cooldude127how do you kill a continuously running agent? would this involve defining the action so there is a flag to stop?
14:34albinojgracin: is that based of mailing list or what?
14:34sohailChouser, is the test contrib being tested on a build server?
14:34Lau_of_DKcooldude127: thats how I do it
14:34jgracinon irc users right now.
14:34tWipI didn't think agents are running per se
14:35sohailand really, why doesn't rhickey add tests... This perplexes me
14:35tWipthreads run, agents just allow access to state
14:35Lau_of_DKagents are thread-wrappers afaik
14:35tWipno agents are run in a thread pool
14:35Chousercooldude127: I don't know how to stop a running agent, without the action itself checking a global ref or something. There may be a Java way.
14:35Chousersohail: not that I know of, but I'm not sure.
14:35cooldude127Chouser: that's what i thought
14:36cooldude127oh man ERC is making me giddy
14:36ChousertWip: true, but while an action is being done on an agent, one can think of the agent as "running", even though it's actually just a thread running a fn
14:37rhickeysohail: testing is overrated, at least the traditional unit tests, but I'm all for running tests others write
14:37tWipyes.. therefore I don't see the issue of "making an agent stop". do you mean possibly long running fns on the agent
14:37rhickeyhagman wins!
14:37jgracinand we have a winner!!
14:37tWip:D
14:37tomhickey=)
14:38cooldude127tWip: i mean an action that sends the same action again, making the same action run on the agent over and over
14:38sohailrhickey, I'm not sure that it is overrated. I have seen really ridiculous unit tests but testing (for example) that a bug doesn't regress is quite useful.
14:38Chousercongrats, hagman!
14:38sohailhagman is in the wrong channel
14:38jgracinsohail: :-)
14:39tWipcooldude127: why not just recur in a thread then?
14:39rhickeysohail: there is only so much time, I find it better spent thinking about what I am doing first rather than writing tests, but I can see the value in other approaches
14:40sohailrhickey, I'm not closed to your approach either (let others write the tests?) so I am interested in how it turns out
14:40cooldude127tWip: that's a good question. what's different about running an ordinary function in a thread as opposed to sending an action to an agent
14:41rhickeycooldude127: an agent runs on a thread from a thread pool
14:41cooldude127ok
14:41cooldude127it's also a little simpler to think about i would say
14:41hiredmandoes clojure have one thread pool and all agents are run on threads from that pool?
14:42Chousertwo thread pools -- one sized based on number of cores (for send)
14:42rhickeyhiredman: one for send, one for send-off, right now. I 'll probably add agent pools at some point
14:42Chouserone that grows (for send-off)
14:42drewcrhickey: i need a domain name for the clojure project hosting site .. any ideas?
14:42hiredmanI see
14:43tWipprojecture?
14:43gnuvince:)
14:43drewci like!
14:43cooldude127nice
14:43cooldude127that was quick
14:43gnuvinceThe pronounciation is fun
14:43sohailclojforge? clojr (web 2.0)
14:44cooldude127i thought about clojforge
14:44Chousercloforj
14:44drewcyeah, i thought about the forj puns too.
14:44drewctoo punny!
14:44Chouserprojecture's better though
14:44cooldude127i can't imagine tell someone about cloforj and having them not ask how to spell that
14:44Chouseror just "forj"
14:44Chouserforjure
14:45cooldude127my vote is for projecture
14:45cooldude127forjury
14:45cooldude127lol
14:45sohailclojectsrus
14:45sohailI don't even know what that means
14:45cooldude127lol
14:45cooldude127this is getting out of hand ;)
14:45rhickeyclojects.org
14:45sohailI got it!
14:45gnuvincesohail: dude, I just broke my jaw trying to pronounce that
14:45sohailproj4cloj
14:45kotarak+1 projecture. cloforj is too hard a break between clo and forj and Klo is something different in germnan.
14:45cooldude127clojects!
14:45cooldude127rhickey ftw
14:46sohailclojects is also nice
14:46canderaclojury
14:47canderaopenjure? :p
14:47Lau_of_DKrhickey: quick one about agents. if I started 100 agents using (map agent (replicate 5 0)) how do I kill them if I need to free all the resources?
14:47sohailprojecture sounds like a math library
14:47gnuvincedrewc: start a poll on the google group and let's see what happens
14:48ChouserLau_of_DK: creating an agent doesn't "start" anything
14:48drewcgnuvince: sounds like a plan.
14:48cooldude127Lau_of_DK: that doesn't start the agent, send or send-off does
14:48Lau_of_DKOk Mr. Nit Pick - If I define my agents like so, and then send-off those agents to a certain func, how do I kill them ?
14:48rhickeyLau_of_DK: you got good answers, agents are subjects to gc, threads running their actions return to the pool
14:48Lau_of_DKIn Clojure, edited in Emacs, evaluted to Slime
14:48ChouserLau_of_DK: unless the agent is queued or running, just losing the reference to it will allow GC to take it away.
14:49cooldude127write the function in a way that allows you to stop it on demand based on a ref or something
14:49cooldude127at least i think that would work
14:49Lau_of_DKLoosing the reference, means (def agents (map ...)), then I have to redef agents to 0 ?
14:50Chousercooldude127: yep: (loop [...] (when @keep-running (recur)))
14:50cooldude127yeah that's what i thought
14:51Chouserflying read. so pretty.
14:52cooldude127what happens if you do (send nil my-action)
14:52cooldude127error?
14:52tWipnull pointer exception?
14:52ChousertWip wins
14:52cooldude127k
14:54Lau_of_DKcooldude127: use ERC in emacs, you could test while chatting :)
14:55cooldude127that's true
14:55cooldude127i'm on ERC, it's lovely
14:55Lau_of_DKEmacs supports IRC, Email, Slime, you name it. For Vim users we have a special treat: Press dd to delete a whole line!
14:55tWipusing irssi now (for years) but I remember zenirc being a good and very unobtrusive client for emacs
14:56cooldude127yeah i just started using erc like half an hour ago
14:56tWipI don't think it's developed any more though, as the site has last news from january 2000
14:57cooldude127tWip: zenirc or erc?
14:57tWipzenirc
14:57Lau_of_DKk, it was just a quick mention to taunt the Vim users once again, lets get back to Clojure
14:57cooldude127lol
14:58cooldude127send to nil gets illegalargumentexceptions
14:58tWipnice. that means it's actually checked :)
14:58cooldude127wait i don't think that's all i messed up tho
14:59cooldude127alright it's actually a nullpointerexception
14:59cooldude127illegal arg is what happens when you use (x) instead of [x] in your arglist
14:59Chouserheh
14:59cooldude127we need some more descriptive errors
15:00Chousukedefinitely
15:01Lau_of_DKWhat could be more descriptive than "Agent has errors" ?
15:01Chousukeit's rather annoying to get an exception in some function and then it doesn't even tell me which one or where, because it happened to be an anonymous one defined in a let :(
15:01sohailcooldude127, there is a IRC client with emacs proper now
15:02sohail(not erc, iirc)
15:02cooldude127my complaint is that i could use something like syntax error for when i use (x) instead of [x]
15:02cooldude127sohail: since what version?
15:02cooldude127idk erc is making me happy right now
15:03sohailcooldude127, maybe since 22? I forget
15:03cooldude127lol
15:03cooldude127i'm on cvs actually so if it's there, i have itt
15:04cooldude127i believe there's rcirc or something
15:04chousukerchi
15:04chousukerchad to try :P
15:04cooldude127but apparently erc was more featureful
15:04cooldude127try what?
15:04chousukercThough I'm pretty sure I can't replace irssi with erc
15:04chousukercerc
15:05cooldude127oh
15:05cooldude127irssi confused the hell out of me when i tried it
15:05Lau_of_DKGuys
15:05Lau_of_DKGet back to Clojure :)
15:05cooldude127NEVER
15:06Chousukewhoops
15:07ChousukeI disabled erc-mode by accident
15:07cooldude127lol
15:07Chousukeand now I can't IRC
15:07cooldude127can't turn it back on?
15:07cooldude127M-x erc-mode ?
15:07ChousukeI have no idea how.
15:08Chousukethere is no such command
15:08cooldude127ahh how did it get disabled?
15:08gnuvinceC-x C-c irssi <Ret>
15:08ChousukeI didn't turn it off, I just enabled clojure-mode and erc stuff was replaced.
15:08cooldude127oh no
15:08cooldude127damn major modes
15:08cooldude127gnuvince: thanks for your suggestion ;)
15:08gnuvincecooldude127: any time :)
15:09gnuvinceIt worked well enough, but I prefer irssi
15:10ChousukeI'll stick with irssi :p
15:10cooldude127yeah well i'm switching from colloquy
15:10MarkVolkmannI'm trying to understand what assoc does, but I don't understand the doc for it. Can someone show me a simple example?
15:10rhickeyuser=> (assoc {:a 1} :b 2)
15:10rhickey{:b 2, :a
15:11rhickey{:b 2, :a 1}
15:11cooldude127assoc gives you a new map or vector with the given key and value in it
15:11cooldude127like in rhickeys example
15:11Chousukeit associates a value with an associative container. the doc says map but it works with vectors too :p
15:11Lau_of_DKCan I send-off agents with a timeout value ?
15:12cooldude127user> (assoc [1 2 3] 2 1)
15:12rhickeyLau_of_DK: no
15:12cooldude127[1 2 1]
15:12ChouserLau_of_DK: timeout of what? How long it can be stalled in the queue before giving up/
15:13Lau_of_DKChouser: Something like that. I want it to begin to pull data of the web, but if has not succeeded in 5 seconds, to close the call and note a failure
15:13rhickeyLau_of_DK: if you are using a blocking API, it probably has a timeout of its own
15:14Lau_of_DKAll Im using is agents, and then stream-reading a URL
15:17ChouserLau_of_DK: it's the stream-reading that's likely blocking if there's a problem, so that's what probably need to have a timeout.
15:17Lau_of_DKChouser: yea I imagine your right. It would just be so easy if Clojure itself could kill the thread half-way through if a limit was exceeded
15:19rhickeyLau_of_DK: killing threads is not going to happen - you have to start wanting something else :)
15:19ChouserThe blocking call probably has a way to report whether it succeeded vs. timed out, so then you can handle that condition appropriately.
15:20askentaskenis it one index 2 indeces or indexes?
15:20Chousukeindices
15:20drewcindices
15:20Chousukeindexes works too I suppose.
15:21krukowI was just looking through the Clojure Java sources to learn more. I have a couple of questions...
15:21drewci would also accept indexes
15:21drewc:)
15:21krukow: 1) I think there is a bug in ASeq.java the containsAll method -- it seems to implement containsSome?
15:22Lau_of_DKrhickey, Chouser: Thanks .)
15:23krukow2) I'm seeing a lot of classes that have up to 20 copies of the same method taking from one to 20 parameters; the last of which is a var-args-param. I guess it is an optimization?
15:24cooldude127krukow: that's most likely correct
15:24krukowindices, I think is the correct word ;-)
15:24cooldude127yes
15:24Chouserkrukow: re 2) yes, I think that allows direct one-step calls that can be inlined by the JVM well.
15:25cooldude12721 parameters can suck it up
15:25cooldude127lol
15:25Chouserwell, they still work, just not quite as fast.
15:25Chouserhave to create an array object and fill it out.
15:25cooldude127exactly
15:25cooldude127boo arrays
15:25hiredmanuse reduce instead of apply :P
15:25krukowyeah ;-) I think 10 should have been enough, though ;-)
15:26Chouseroh, sorry, I didn't know precisely what algorithm you meant by "suck it up" :-)
15:26cooldude127lol
15:26cooldude127i think the most i've ever used was like 5 maybe
15:27askentaskenhttp://paste.lisp.org/display/70588
15:28askentaskenisnt it pasting direclty to here anymore?
15:28sohaildrewc, for some reason I can't post to google groups through gmane so I vote for clojr :-)
15:28askentaskenanyway, theres my tictactoe, a little upgraded
15:28hiredmanthe bot seems to be in and out
15:28MarkVolkmannThanks for the assoc examples! I've got it now.
15:29rhickeyhiredman: apply is efficient too, it does not use an array - feeds the seq right to applyTo
15:29drewcsohail: i'm leaning toward clojr myself.
15:29Chouseraskentasken: lookin good. I think you could use (some ...) instead of (> (count (filter ...)) 0)
15:29sohaildrewc, it takes some getting used to
15:30Chouserisn't "clojr" pronounced the same as "clojure"?
15:30hiredmanrhickey: good to know
15:30cooldude127Chouser: yeah that is a concern
15:31MarkVolkmannIs there a deeper meaning to the name than the word "closure" with the "s" replaced by a "j" for Java?
15:31Chouseraskentasken: and "not-any?" for the (= 0 (count ...)
15:31abrooksChouser: No. You're supposed to silently clench your jaw when saying "clojr".
15:31Chouserabrooks: ah, got it. thanks.
15:31sohailChouser, you have to say clojr while hugging people
15:31askentaskensome retrns nil
15:31sohailMaybe clojure-projects.org would be the best thing
15:31askentaskendoes nil test as false?
15:31abrooksToo bad forj is already Google un-virginal. I liked forj.
15:32Chouseraskentasken: yes
15:32Chouseraskentasken: nil and false are the only things that act like false in a boolean context.
15:33Chouseraskentasken: sweet use of a keyword as your dispatch fn!
15:33rhickeykrukow: containsAll is fixed
15:34drewcChouser: pronunciation aside, i'm looking at clojr.net, which is different enough from clojure.org, and it's a cool url imo! :)
15:35rhickeydrewc: that wouldn't be my preference as it has the same pronunciation
15:35sohailclojects is hard to pronounce imo
15:36Pupenodrewc: hi there!
15:37drewcrhickey: ok, you have veto.
15:37askentaskenhttp://paste.lisp.org/display/70589
15:37askentaskenjava.lang.IllegalArgumentException: No method for dispatch value: null
15:37rhickeysohail: like projects, or clozhects
15:37AWizzArdrhickey: how close is the 1.0 realease away? Do you think it might happen this year?
15:37sohailrhickey, might be me, but it doesn't roll off the tongue too easily
15:38askentaskensometimes it works, sometimes it doesnt
15:38rhickeyAWizzArd: I hope so
15:38askentaskenare any and not-any added in newer versions?
15:38drewcprojecture.net is the other most popular choice. rhickey?
15:38ChouserAWizzArd: if he misses 2008, he's going to call in 2.0
15:38Chouserrhickey: right? :-)
15:38rhickeydrewc: projecture fine by me
15:38kotarakanything with clo in front should not have a hard break between the syllables. Klo in german has a different meaning... So pronounciation could lead to strange associations.
15:39AWizzArdWould be nice in 08 although I personally think it would still be okay for next year. Its API now seems to be stable for the coming time.
15:39Chouseraskentasken: "not-any?" has a question mark
15:39askentaskenChouser: askentasken: sweet use of a keyword as your dispatch fn! ironic there? whic exactly do you mean?
15:39rhickeyChouser: not calendar year, year from release
15:39Chouserrhickey: ah. so that gives you 'til Oct 2009?
15:39rhickeyChouser: yup
15:39Chouseraskentasken: honest, not ironic. I like it!
15:40PupenoI remember there was a method to mark public functions in a namespace or something like that. Kind-of like defining an API. Am I remembering wrong?
15:40drewcPupeno: hey, long time no see!
15:40ChouserPupeno: use defn- to define a private function
15:40kotarakPupeno: you can use defn- for private functions
15:40AWizzArd:-)
15:41PupenoChouser, kotarak: Oh! that was it. Thanks.
15:41MarkVolkmannWhere can I find documentation on clojure-contrib? My googling attempts have failed to find anything but the code. Maybe I just need to look at that.
15:42Pupenodrewc: how are you?
15:42ChouserMarkVolkmann: yeah, there's about it. Many of the .clj files have examples at the end.
15:43ChouserMarkVolkmann: you may be able to dig up some examples in the IRC log or google group.
15:43drewcPupeno: things are good. Work is steady and interesting, and life on the water is wonderful... how are things with you?
15:44Pupenodrewc: life on the water?
15:45Pupenodrewc: I'm fine, thanks.
15:45ChousukeAWizzArd: here's a version of your game that works on recent versions http://pastebin.com/f115b1f06 (contains spoilers!)
15:45Lau_of_DKIs there something similar to fork, when I just want to send-off a function to another thread, like when calling from UI ?
15:46drewcPupeno: i moved on board a sailboat early this year.
15:46ChouserLau_of_DK: what's wrong with "send-off"?
15:46AWizzArdChouser: my game?
15:46Chousukeer
15:47ChousukeI meant askentasken :)
15:47AWizzArdic
15:47Lau_of_DKChouser: nothing, except it requires an agent, which I was looking to avoid
15:47Pupenodrewc: you *moved*?
15:47drewrdrewc: Are you sailing right now?
15:49askentaskenChouser: but where? i odnt even know what u mean
15:50drewcPupeno: well, threw away most of my stuff and climbed on is more accurate, but yeah, i have no place on land.
15:50drewcdrewr: tied comfortably to the dock :)
15:51ChouserLau_of_DK: if you don't want an agent, you'll have to deal with Thread directly.
15:52Pupenodrewc: wow!
15:52Lau_of_DKChouser: is this way too dumb? (defmacro async
15:52Lau_of_DK [expr]
15:52Lau_of_DK `(send-off (agent 0) ~expr))
15:52Lau_of_DK
15:52ChouserLau_of_DK: (.run (Thread. #(prn "hi")))
15:52Pupenodrewc: do you have any pictures?
15:53ChouserLau_of_DK: (agent 0) is fine, or (agent nil). But expr has to be a fn of at least 1 arg.
15:53Lau_of_DKWhy ?
15:53Lau_of_DK:)
15:53drewcPupeno: you bet. I have 2 boats .. the smaller one i live on, they larger is up on the boat yard being repaired.
15:54Lau_of_DKChouser: Why as in: Why not 0 args?
15:54Chouseraskentasken: you asked if "not-any" is added in a newer Clojure. I'm saying it's in older versions of Clojure, but it's name is "not-any?"
15:54drewcPupeno: http://versions.tech.coop/kanu.jpg <-- smaller on (29th LOA)
15:54ChouserLau_of_DK: send and send-off always pass in the agent as the first arg
15:54askentaskenjava.lang.IllegalArgumentException: No method for dispatch value: null
15:55askentaskenso it is an error in the multimethods right?
15:55Lau_of_DKoh....
15:55cooldude127Lau_of_DK: that is, the state of the agent
15:55drewcPupeno: http://versions.tech.coop/cestlavie.jpg <--- and the ship herself (50ft LOA).
15:55Lau_of_DKChouser: now Im using this: (.run (Thread. #(start-stress-test)))
15:55Lau_of_DK (JOptionPane/showMessageDialog nil "Agents dispatched")), the JOptionP is never shown - how come?
15:56cooldude127not the agent itself
15:56wwmorganasktentaksken: you need to pass a map into the multimethod that has the appropriate key
15:56Pupenodrewc: that's amazing. Do you live by yourself there?
15:56askentaskenChouser : ok but you said nice use of, where i use what?
15:57Chousercooldude127: oh, right, sorry.
15:57drewcPupeno: no, my wife is with me, and her daughter stays sometimes... and 3 ferrets and a bird.
15:58Lau_of_DKDoes anybody know how I can kill Slime really quickly, without closing Emacs?
15:58PupenoAnd I complain because my place is so small...
15:58Pupenodrewc: how do you get on-line?
15:58Chouserdrewc, Pupeno: I don't mean to be rude, but could you guys take this elsewhere?
15:58drewcChouser: of course, sorry 'bout that!
15:59PupenoChouser: sorry!
15:59Chousernp. I wouldn't have said anything except the channel is so busy at the moment.
16:00Chouseraskentasken: I meant (defmulti move :player) <-- using :player as your dispatch function.
16:00Chousukeaskentasken: you're calling (move (:board player)) there!
16:00Chousukeaskentasken: it'll give you an error since you don't have a method for boards :P
16:01Chousukeaskentasken: also: instead of recursive calls, use (recur ...)
16:01Lau_of_DKGuys, if I want agent smith to go into the GC once his func completes, shouldnt this fit the bill? (map #(send-off % stress-task)
16:01Lau_of_DK (map agent
16:01Lau_of_DK (replicate (get$ :count-of-agents) 0))))
16:01duck1123I'm writing some C++ code for school. I modified a function and had to resist the urge to hit C-M-x
16:01Lau_of_DK(get$ :cou..) = 50
16:04ChouserLau_of_DK: send-off returns the agent, so your top-level map there will return a lazy-seq of agents.
16:04Lau_of_DKbut by that time, they will all be running right Mr. Houser ?
16:04Chouserif you put that seq in var, you'll not get any agents at all: (def agents (map...))
16:05Chouserbut if you wrap that map in a dorun, and you'll start all the agents but they should be GC'd as they complete.
16:06Lau_of_DKAlright, so what youre saying is. I gotta dorun ?
16:06ChouserI'm saying that's one solution, yes.
16:06hiredmanmap is lazy, so the the send-off doesn't happen until you walk the list somehow
16:06Lau_of_DKHouser, I thank thee
16:08Lau_of_DKoh man
16:08Lau_of_DKchock
16:08Lau_of_DKIt started, before I could look around it had many over 4000 hits on my webserver
16:09askentaskenoh using player, player isnt a builtin? anyway that was Chousuke who inspired me
16:09askentaskenjava.lang.IllegalArgumentException: No method for dispatch value: null
16:10Chousukeaskentasken: did you fix the (move (:board player)) bug? :P
16:10askentasken(move (player :board)))))
16:10askentasken?
16:10askentaskenbut i think isee it shouldnt work at all
16:10askentaskenit is the work soemtimes i dont get
16:11Chousukeyou want just (move player)
16:11Chousukenote, player != :player
16:11wwmorganaskentasken: a keyword acts as a function from associative things, but if you pass a non-associative thing to a keyword, it just returns nil instead of raising an error
16:12askentaskeni see now
16:14askentasken(assoc (player :board) mov 1)
16:14askentaskenplaer :board or :board player?
16:14Chousuke:board player
16:14Chousukeactually
16:14Chousukeeither works, since player is a map
16:14Chousukemaps are functions of their keys, and keywords are functions of maps :)
16:15Chousukevery powerful, but can be confusing
16:17Chousukeonce you get that sorted: in your play-game function it would be easier to just handle one turn at a time (instead of both the computer's and the player's)
16:28ChousukeThis tic-tac-toe thingy actually seems to be pretty good practice, since it has "state" (the board) and there's even use for multimethods.
16:28askentasken(defn human [coll] {:player <<--- if that what u mean tis ro the example at the clojure homepage
16:29askentaskenChousuke: yes i was thinking the same
16:29Chousukeno I mean in the play-game function
16:29askentaskeni will prob make a GUI and min-max-algorithm later
16:29Chousukewhere you do stuff like (let [newer_board (move (_second new_board))] ...)
16:29Chousukewhen you mean (move _second)
16:30Chousukeand everywhere else too you make the same mistake.
16:30Chousuke'move takes a player, not a board :)
16:31Chousukeand a player is a map that has two keys, :player and :board
16:31AWizzArdyes, although doseq lets the reader see that you are doing something imperative
16:31AWizzArdwrong channel
16:32wwmorganI think move should take a player key and a board
16:32Chousukewwmorgan: either works
16:32wwmorganfor a player to have a board doesn't really make sense
16:32Chousukea single-argument move is easier to extend
16:32Chousukewwmorgan: well, you could call it game-state then :)
16:33wwmorganyeah. it makes the multimethod easier to define too
16:33Chousukewith :player being the player whose turn it is
16:33askentaskenit would clear things up because im so confused over this now
16:33Chousukeaskentasken: what exactly is confusing you?
16:33Chousukeperhaps the use of :player as a function?
16:34ChouserAWizzArd: you're talking about Clojure in another channel/
16:34Chouser?
16:34AWizzArdChouser: in private
16:34Chousukeremember: multimethods decide which method to call based on the "return value" of the dispatch function (":player") on the arguments its called with (in this case player)
16:35Chousukeaskentasken: so, when you call (move player), behind the scenes clojure calls (:player player), which returns either :Human or :Computer
16:36Chousukeaskentasken: and then clojure knows which method to run.
16:36askentaskenhttp://paste.lisp.org/display/70595 </ c4rrent vers56n
16:36Lau_of_DKGuys - I get alot of these "Reflection warning: xyz cannot be resolved", can I code in a way that doesnt produce all this warnings?
16:37ChouserLau_of_DK: (set! *warn-on-reflection* false)
16:37Lau_of_DKChouser: so its not my home-grown coding style?
16:37albinoheh, that advice seems to be coming out daily, the reflection one I mean
16:37askentaskenWHY 5S 5T EVEN W6R25N AT A33
16:37duck1123denial is the best debugging policy
16:37askentaskenwhy is it even workin at all?
16:38Chousukeaskentasken: how far does it work?
16:39Chousukeoh wait! your play-game is correct now. I just got confused by your functions
16:39Chousukeand move methods are okay too.
16:40Chousukethose (pr _first) and (pr _second) don't make much sense though :)
16:44wwmorganaskentasken: your has-winner? is a cool trick, but it introduces coupling with the implementation of move. Instead, you could fill the board with :com and :player, and use every? to return a winner, or nil if there is none yet.
16:48wwmorganthen you can refactor move like this: http://paste.lisp.org/display/70574#4
16:50Lau_of_DKIf I call (def xyz zyx) in a defn, is it still globally declared?
16:50rhickeyLau_of_DK: yes, defs are global
16:50Lau_of_DKthanks
16:51Chousukeaskentasken: http://paste.lisp.org/display/70595#1
16:55askentaskenh cond yes
16:55Chousukethe :else there is not special syntax btw. it's just something that has a true value :)
16:56Chousukekind of like having no "else" at all and resorting to else if (true) { ... } :P
16:58Chousukeexcept that in most non-lisp languages, that would be a weird thing to do.
17:01hiredmanI think with clojure the main problem there is "true" is not a fn
17:02Chousukewell you could use true too :/
17:02hiredmanbut I think the reader would accept that, and you would knock it into shape with a macro
17:02Chousukewhat?
17:03hiredmanChousuke: if you wanted to use that syntax in clojure :P
17:04Chousukeah, righ.
17:04Chousukewell who would
17:04Chousukenot me.
17:05Chousuke better just move the parentheses around a bit
17:10Lau_of_DKWe have (reduce max seq) but do we have something like (reduce average seq) ?
17:11wwmorganLau_of_DK: arithmetic or geometric mean?
17:11hiredmanerm
17:11Lau_of_DKarith
17:11hiredmanjust reduce with + then / by (count seq)
17:11hiredmanoh
17:13wwmorganyou can't do that with just a reduce
17:13hiredmanyou could
17:13hiredmanbut I don't think you could cleanly
17:14hiredmanbut my math is not very good
17:14wwmorgan(reduce hypothetic-fn [100]) => 100 and (reduce (hypothetic-fn [100 100 100]) => 100
17:14wwmorganbut tack an extra element on to each list and the behavior changes
17:15Lau_of_DKso (/ (reduce + seq) (count seq)) is my best bet
17:16hiredmanunless there is some other method of calculating the arithmetic mean that doesn't need to know how many numbers there are
17:17Lau_of_DKhmm
17:20Lau_of_DKAnyway, I gotta hit the sack, thanks to everyone for answering so many questions tonight. I actually have a full blown http benchmarker running now :)
17:22askentaskenis reduce+ / count O(n) because of laziness?
17:23Chousukereduce is always O(n). count (at least after reduce) should be O(1)
17:23wwmorganlaziness is irrelevant there as neither reduce nor count is lazy
17:23askentaskenah count is O(n)
17:24askentaskenwhat i mean was, if count ws O(n) and reduce O(n) would laziness keep it O(n) instead of O(n) * 2?
17:24askentaskenok reduce is not lazy
17:25Chousukecount is O(1) for lists and vectors and maps. don't know how it behaves for arbitrary seqs
17:25hiredmanthe thing to remember is seqs != lists
17:25wwmorganyeah reduce looks like it could be lazy at first, but when you think about it it's only returning one value
17:34sohailhey drewc I like clojets (for source code coming out of the closets!) :-)
17:35drewcsohail: too late, i just registered projecture.net :)
17:35sohaildamn
17:35duck1123that was good too
17:36duck1123clojets is a good name, but it sounds like a name for something else
17:36wwmorganmy new hot tub has clojets in it
17:36duck1123perhaps wigits made in clojure
17:37pjb3So this doesn't work anymore: http://en.wikibooks.org/wiki/Clojure_Programming#Invoking_Clojure_from_Java
17:37sohailfourleafclojure has a ring to it too
17:37pjb3Anyone know how to do that now?
17:40duck1123I've been trying to think what a good name for a build system in Clojure would be. I like Jake, but it's too bad that Cl is also common lisp
17:40hiredmandejure
17:41hiredman"well you have to use it, it's the dejure build system"
17:41danlei` =)
17:41hiredmaner
17:41hiredmanI guess it would be, "build system dejure"
17:41duck1123hiredman: that's good
17:43hiredmanI am not sure, I hear it's kind of, you know, *french*
17:43danlei`dejure?
17:43danlei`that would be latin
17:43kotarakde jour
17:44danlei`jus = law
17:44wwmorgansoup du jour
17:45wwmorganthe soup of the law
17:53Chouserpjb3: use just "ns" instead of "clojure/ns"
17:54pjb3the java part doesn't work
17:54ChouserHm, I just built and ran it.
17:54ChouserWhat error are you getting?
17:56pjb3nevermind, it was some problem with my IDE, works now
17:56Chousergreat.
17:56pjb3thanks
17:58pjb3hmm....cool: System.out.println(RT.var("clojure.core", "+").invoke(1, 2));
17:59cooldude127pjb3: is that doing "(println (+ 1 2))" from the java side?
18:00pjb3cooldude127: yeah, pretty much
18:00hiredmanhas any one made a nice jar that you click on and up pops a repl window?
18:00pjb3you get the "+" function and then invoke it
18:00cooldude127yup
18:01pjb3hiredman: I'm actually trying to see if I can get a REPL in an Applet, thinking it probably won't work due to classloader/security BS
18:01hiredmanI have one in some java terminal thing, but it doesn't do copy and paste
18:02Chouserpjb3: I've seen a repl in an applet (I think) -- the applet has to be signed, and the user has to click through a permission dialog.
18:02Chouserpjb3: a non-repl clojure applet should be doable now with AOT, but I don't know that anybody's tried.
18:02pjb3Chouser: well if you if have a link, you could save me the trouble
18:03pjb3I'm thinking we should have a REPL on clojure.org
18:03pjb3so people could just try it out right there
18:03rhickeyChouser: actually not, as a repl needs to do code gen, and thus needs a classloader
18:03Chouserpjb3: I don't, and i've got to run. Google is your friend!
18:03pjb3rhickey: what do you think of that?
18:04rhickeyclojure.org is just a spot on wikispaces, I have no hosting for Clojure
18:04pjb3ah, well, we could find some place to stick the .class/.jar file
18:05rhickeypjb3: that's easy, if it's an applet
18:05pjb3yeah, so I'm just trying to figure out how to make an applet that has a REPL
18:05pjb3If I do, we'll find some place to host it
18:06ole2Hello, I've never been here bevor, just clicking at clojure.org at irc.
18:06ole2And it opened that window, wow
18:06rhickeyole2: welcome
18:06ole2:)
18:06drewcpjb3: I can offer you cheap hosting for clojure projects.. and actually a REPL i can host at projecture.net for free i'm sure. :)
18:07pjb3drewc: cool, I'll let you know if I get it working
18:10ole2O.K. i've installed java, jre, jdk, whatever, and got finally some kind of repl. But is there an ide? Name-completion?
18:11duck1123personally, I would like to see a ajax interface to a remote repl
18:11drewcole2: i recommend using SLIME personally.
18:11wwmorganole2: enclojure for netbeans is pretty good
18:11hiredmanI think the three main editors people use are emacs, vim, netbeans
18:11pjb3ole2: http://enclojure.org/Completion.html
18:12hiredmanI use vim myself with some thing that lets me send chunks of clojure to a repl
18:12hiredmanslime.vim? I dunno
18:13duck1123Gorilla?
18:13ole2thank you, i tried to install netbeans, but it takes several minute to startup, and the enclojure plugin did not work.
18:13hiredmanduck1123: nah, I haven't used gorilla or chimp yet
18:13ole2I'm not a java guy, and i can not figure this out.
18:14wwmorganole2: what behavior did you get out of the enclojure plugin?
18:14duck1123I tried enclojure, was pretty nice, but I'm too much of an emacs guy now to use anything else
18:14drewcI use SLIME because it's what i know, and it's made for Lisp.
18:14pjb3I tried enclojure a while ago, couldn't get it to work
18:15pjb3Guess I'll try again now
18:15ole2Well, I installed netbeans, all-package, jdk, takes several minutes to startup, and sayes some javamodules are missing.
18:15ole2Maybe i should ask at a java channel
18:15ole2But thanks for the help
18:16ole2O.K. You are all emacs guy's. So my next questions.
18:16hiredman<-- VIM
18:16ole2:)
18:17hiredmanbut yeah, everyone else
18:17duck1123I just wish emacs had a way to detect fn names
18:17ole2I have a working emacs/slime/sbcl/clisp blah installation. How do i get clojure to work with that
18:17rhickeyole2: there's also #enclojure for enclojure-specific qs
18:17ole2O.K. Thank you.
18:18duck1123ole2: did you try the code on the wiki?
18:18duck1123there are instructions on how to set up multiple lisp implementations
18:24ole2duck1123: thank you for the pointer. I did not look carefully. I think i could figure it out now. (And live on with this s*** editor :)
18:24cooldude127ole2: you dissin emacs?
18:24duck1123clojure + swank is difficult to get right some times
18:24duck1123you have to load things in the right order
18:24cooldude127idk i thought it was pretty easy to set up but i already had slime working
18:25cooldude127i was just adding clojure love
18:25cooldude127oh wait so was ole2
18:25duck1123I kept getting hit with the progn problem
18:26cooldude127what problem is that?
18:31cooldude127hagman appears to be having some issues
18:32duck1123you get the error that progn isn't a valid function
18:32duck1123it happens when you don't load things in the right order
18:32ole2Thanks for your patients, I load slime but got the java expection "Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/Repl"
18:32cooldude127it appears that you don't have it setup to load the clojure jar right
18:32ole2I have no idea what that means
18:33cooldude127cuz it can't find clojure's stuff
18:34duck1123(setq swank-clojure-jar-path (concat clojure-path "clojure.jar"))
18:35cooldude127what's clojure-path? does it have the final / at the end
18:36lisppaste8duck1123 pasted "my .emacs pick and choose to your hearts content" at http://paste.lisp.org/display/70611
18:37duck1123admittedly not the best setup, but it works for me
18:37cooldude127i'll paste my clojure stuff as well
18:38ole2I tried to rearange all the stuff you say, but it still yields the same error
18:38lisppaste8cooldude127 pasted "my clojure.el file" at http://paste.lisp.org/display/70612
18:39cooldude127i use a script with it
18:39cooldude127i should probably do the fun task of updating clojure and swank-clojure
18:41duck1123I haven't gotten around to it because Compojure hasn't been updated yet, and that's the only thing I use atm
18:41cooldude127how is compojure?
18:41cooldude127i haven't checked it out yet
18:42duck1123pretty good. takes some getting used to, and there are things I wish were different, but it works
18:42cooldude127cool
18:43cooldude127luckily i haven't really written too much significant code with clojure yet, so any big changes will just get used in new code and old code will be forgotten
18:44duck1123so has anyone written a BNF for Clojure yet?
18:44duck1123I'm wondering if I need to learn it to scratch my itch
18:44cooldude127holy shit swank clojure changed since i last updated
18:45duck1123when did you last download?
18:45cooldude127that's a damn good question
18:46cooldude127not really sure
18:46ole2i did not get it, what am i doing wrong http://paste.lisp.org/display/70613.
18:46ole2It's my .emacs
18:46cooldude127somebody help me: swank-clojure uses autoloads, so what do i do to load the new changes without quitting emacs and killing irc
18:47danlarkinduck1123: well kotarak's got a parser combinator library... it's a bit outdated at this point, though. He promises me he'll have some time to update it soon though :)
18:48duck1123cooldude127: M-: (require 'swank-clojure) ?
18:48danleicooldude127: M-x load-file
18:49duck1123danlarkin: do you know where it's at?
18:50danlarkinduck1123: http://kotka.de/projects/clojure/parser.html
18:51cooldude127ole2: your jar-path needs to have the actual jar, not just the dir
18:51cooldude127danlei: that's what worked, require didn't actually reload it i think
18:54ole2cooldude127: Hey, it worked. Thank you. (it throw's exeptions but i can fugure them out myself). Thank you for take a look at it.
18:54cooldude127no problem. i didn't notice at first but it just caught my eye
18:56cooldude127clojure and swank-clojure update successful
18:56cooldude127slime is still old, from late october
18:56cooldude127not that old i guess
19:00ole2Thank you all for the help! I will try to help someone myself as you did. Nice social networking thing you have here. Glueck auf! Take care!
19:02danlarkinduck1123: if you improve upon his Parser library let me know, I want to use it for my json decoder
19:36cooldude127don't you just love it when emacs crashes and you have NO IDEA cuz os x didn't give you a clue?
19:38gnuvince_;)
19:38wwmorganotoh, enclojure crashes with loud and cryptic error messages
19:39wwmorganan error in my user.clj manifested itself as a couldn't connect to socket exception
19:45cooldude127gnuvince_: i'm in no way against vim, it just doesn't fit for me
19:45cooldude127i actually want to like it
19:45cooldude127but i can't make it stick
19:45gnuvince_cooldude127: fair enough. Different people, different minds, different tastes, different editors :)
19:47cooldude127gnuvince_: i think the biggest thing is i use the colemak keyboard layout, and that really messes up vim's navigation and stuff
19:47sohailcooldude127, emacs never crashed for me except when I used erc
19:47cooldude127i think matlab was the problem here
19:47cooldude127matlab crashed too, and os x just didn't tell me that emacs went with it
19:51ChousukeI'm actually starting to like emacs
19:51Chousukemight be because I found vimpulse. which allows vim-style editing :P
19:51cooldude127lol
19:51cooldude127funny that the vim-style editing is what prevented me from doing vim
19:51walterswwmorgan: probably starts clojure as a separate process expecting to connect to it over a socket, but the external process fails on errors in user.clj
19:52waltersof course local apps talking to each other over TCP sockets is terribly broken, unfortunately Java doesn't expose local domain sockets
19:52wwmorganwalters: that's exactly it
19:52ChousukeWell I really don't like the 283490893 key combinations emacs has. I can remember at most a few of them
19:52gnuvince_I needed to stop using Emacs after two years because the pain it caused me were just getting unbearable.
19:53duck1123there's alway's M-x
19:53cooldude127gnuvince_: even remapping caps lock to control? does that help?
19:53cooldude127Chousuke: i don't know most of them
19:53cooldude127just the ones i constantly use
19:53Chousukeduck1123: I like how in vim you can "combine" commands
19:54duck1123We're learning vi in my linux fundamentals class
19:54duck1123I hate it
19:54gnuvince_cooldude127: didn't help.
19:54gnuvince_cooldude127: so I went back to vim
19:54gnuvince_(which I had left for Emacs)
19:55cooldude127oh
19:55Chousukeduck1123: like, d for delete, % to skip to the matching paren, d% for delete until matching pare
19:55Chousukestuff like that
19:55cooldude127yeah i did like that
19:55cooldude127it wasn't enough for me
19:55gnuvince_it all depends on how you work (though I guess the editor you have affects how you think you want to work)
19:56duck1123that was kinda cool. most of the caommands in emacs have C-u arguments that do something similar. I never use them
19:56gnuvince_I use the type of commands Chousuke mentioned a hundred times a day.
19:56ChousukeIf I can get most of that while still using emacs, well, yay. (I think emacs as an editor is superior, controlling it is just a pain)
19:56cooldude127yeah
19:57danleiemacs is the better os =)
19:57cooldude127plus i can't wrap my head around vimscript
19:57cooldude127emacs-lisp is flawed, but makes more sense to me
19:57duck1123there's viper
19:57cooldude127what's viper?
19:57danleivi emulation-mode
19:57Chousukeduck1123: yeah, that's what I'm using :)
19:57duck1123gives all the vi bindings in emacs
19:58Chousukemy emacs setup is really something
19:58gnuvince_Yeah, vimscript sucks ass.
19:58cooldude127i've done a lot of work on making my emacs setup easily tweakable
19:58Chousukeit's one part vi, one part emacs, and one part mac-app
19:58gnuvince_Lot of people wish Bram would just leave it only for configuration and switch to something more "proper" like Python for actual plugins.
19:59cooldude127everything i add goes in a new file to be loaded from .emacs
19:59duck1123my init.el file has gotten way too large
19:59Chousukeit's not awesome at being any of the three, but it just happens to be good enough at all of them to make me feel comfortable :P
19:59danleiduck1123: i once lost mine
20:00lisppaste8cooldude127 pasted "my .emacs" at http://paste.lisp.org/display/70620
20:00cooldude127mines on github actually
20:00duck1123I'm sitting at 730 lines
20:00duck1123not counting customized vars or keybindings
20:01cooldude127i keep all my dotfiles in a git repo
20:01duck1123I've been planning on putting mine on github, but I accidentally checked in my twitter password and I haven't gotten around to editing my history to remove it
20:01cooldude127lol
20:01Chousukeduck1123: Keep at it, soon you'll have a working text editor implementation!
20:02cooldude127i was really happy when i reduced my set of files to load to a list of symbols instead of a bunch of load calls
20:04cooldude127brb, trying out my updated emacs-cvs
20:06cooldude127ok well the new emacs did not work
20:06cooldude127and i don't feel like figuring out why
20:06duck1123cooldude127: do you actually use CVS or the git mirror?
20:07cooldude127cvs
20:07cooldude127it couldn't load cuz of some DOC file it couldn't find
20:08duck1123but it built before?
20:08cooldude127yeah
20:09cooldude127i'm running an older cvs one right now to chat
20:10duck1123I'm doing a `mr update` to see what's changed since this morning
20:11cooldude127Cannot open doc string file "/Users/mattmoriarity/usr/src/emacs/nextstep/Emacs.app/Contents/Resources/etc/DOC-23.0.60.2"
20:11cooldude127is the error
20:26duck1123took forever, but built with no errors. sorry
20:27cooldude127mine didn't take much time
20:27cooldude127maybe i should clean first
20:30cooldude127ok the build was still fast
20:30cooldude127duck1123: what platform are you on?
20:32cooldude127SWEET!
20:32cooldude127yeah cleaning helped
20:32cooldude127brb
20:34larrytheliquidis there a version of rest that returns an empty list instead of nil when empty?
20:35jtoylarrytheliquid: i dont think so
20:35Drakesondoes (a b c d e f g) -> ((a b c) (d e f) (g)) have a name?
20:35cooldude127and we're back with an up-to-date emacs :)
20:35jtoylarrytheliquid: but im sure you can do a macro or whatever
20:35larrytheliquidjtoy: ya np
20:35danlarkinDrakeson: partition
20:36cooldude127Drakeson: that's partition i think
20:36cooldude127damnit danlarkin
20:36Drakesonthanks :)
20:36danlarkinin like flint
21:26rzezeskijust out of curiosity...how long has everyone here been using Clojure, and what do you consider your "strongest" language
21:28Chouser9 months. Clojure. :-)
21:28pjb3rzezeski: I've been using clojure off and on for almost a year
21:28pjb3Ruby is probably my strongest language, Java probably a close secodn
21:29rzezeskichouser: You really consider Clojure your strongest language? What would you consider your strongest before Clojure?
21:29cooldude127i'm with pjb as far as ruby and java
21:29cooldude127i'm pretty good with java, but i can't stand using it
21:30rzezeskipjb3, how much experience w/ Ruby?
21:30cooldude127ruby is an excellent mix between a language i'm good at and a language i actually like to use
21:30pjb3cooldude127: yeah, me too
21:30pjb3rzezeski: Couple of years now
21:31cooldude127yeah same here
21:31cooldude127i can base it off the rails version of the time
21:31cooldude127cuz that's what got me started
21:31cooldude1270.8.0
21:32Chouserrzezeski: At various times, C, perl, and ruby have been my strongest. I've also done a lot of JavaScript, C++, and python. But as I spend time with one language, the others fade.
21:33rzezeskiCool, yea I've played with Ruby here an there over the last year and a half, but Java is what I know best mainly because of work. My favorite is Haskell, which Ruby actually led me back to. Now, recently, FP has led me to Clojure and I gotta say I really like it so far.
21:34pjb3rzezeski: yeah, Clojure is awesome
21:34rzezeskiYea my coworker and I are both fans of FP. He's more of a LISP guy and he told me about Clojure. I watched the videos on blip and now I'm hooked
21:35rzezeskiRich really knows how to give a good presentation
21:35cooldude127i liked both lisp and haskell, and clojure seems like a good mix
21:35cooldude127rzezeski: you bet he does
21:35gnuvince_Clojure has less bling than Haskell, but it's extremely enjoyable.
21:35cooldude127i love haskell until i get into more complicated programs and i'm just lost
21:36cooldude127there's a fine line in haskell between unbelievably clean and disgusting
21:36gnuvince_I agree
21:37cooldude127my lisp problem is a lack of libraries
21:37cooldude127which clojure solves
21:37Chouserthat's interesting. I've not given haskell the time it deserves.
21:37rzezeskiI'm very much a Haskell novice, but I know enough to read through most stuff and have an idea. I think the pure side of Haskell is awesome, but the IO is where it gets ugly to me. I like Clojure because I can apply the FP ideas I've learned from Haskell but still have easy IO
21:37cooldude127exactly
21:38gnuvince_rzezeski: and all the Java libs :)
21:38rzezeskithat too!
21:38gnuvince_I'm no fan of Java, but I definitely enjoy using a one year old language that has more libs than Perl :)
21:38cooldude127yeah java is a library whore
21:38cooldude127it has everything
21:38cooldude127ruby's about the same way, but not quite as much
21:39rzezeskiWhat's even cooler is I actually have a chance at using Haskell at my job since it is hosted on the JVM. Right now we are using Groovy/Grails but I'm hoping to sneak in some Clojure in the future
21:39rzezeskiClojure*
21:39pjb3I actually miss some of the Ruby libraries in Java
21:39gnuvince_rzezeski: ditto
21:39cooldude127i love ruby libraries, cuz in general they tend to be really pleasant
21:40pjb3Is there a good HTML parser for Java like Hpricot or Nokogiri?
21:40cooldude127Hpricot is a GREAT example of what i'm talking about
21:40albinotime for people to start porting
21:40pjb3Especially one that has a CSS engine
21:40gnuvince_rzezeski: I work mostly with Python and PHP at my current place of employment, but I'm pretty sure a future job will have Java in it, so it's nice to know I have something better than Java The Language at my disposal :)
21:40cooldude127i had to work with java last year, and i really wish i had clojure back then as mature as it is now
21:40pjb3cooldude127: Yeah, I would love a library for clojure where I can load an HTML doc and then query for parts of it using CSS selectors
21:41cooldude127it would have helped so much
21:41cooldude127pjb3: you and me both
21:41gnuvince_pjb3: I am using HTML Parser in my Clojure mini-tutorial. I don't think it has a CSS support and it definitely is less expressive than BeautifulSoup or Hpricot, but it does the job very well.
21:41gnuvince_pjb3: http://htmlparser.sf.net
21:41gnuvince_pjb3: (org.htmlparser.Parser. "http://www.xkcd.com&quot;)
21:41cooldude127if i had the spare time i would consider porting hpricot
21:41cooldude127_why would be cool :)
21:42gnuvince_:)
21:42gnuvince_I was searching for a project in my free time
21:42gnuvince_That could be an interesting one.
21:42cooldude127oh yay
21:43pjb3gnuvince_: once you've got a parser, how do you get parts of the document?
21:43pjb3extractAllNodesThatMatch(NodeFilter filter)
21:43gnuvince_pjb3: there are some filter classes and a visitor method
21:43gnuvince_Yes
21:43pjb3this is the kind of crap that I hate about Java libaries
21:43cooldude127ahh i knowww
21:43gnuvince_You and me both :)
21:44gnuvince_pjb3: *but*, it does provide Clojure with a solution, even if it's not the cleanest one
21:44cooldude127true
21:44cooldude127we get gui's and stuff like that basically free
21:44ChouserI like TagSoup + zip-filter
21:44pjb3Yeah, we can wrap that crap
21:45pjb3Looks like it has CssSelectorNodeFilter that does CSS2
21:45cooldude127woooo
21:45pjb3so you could use that in clojure to get something like jQuery
21:45cooldude127oh snap !
21:46pjb3($ "div.fancy" show)
21:46Chouserbut css to too limited for my taste
21:46gnuvince_I prefer things like BeautifulSoup
21:46gnuvince_Allow for more powerful searching
21:46pjb3$ would be an fn that takes a selector and N number of functions to apply to the matched elements
21:47cooldude127wtf emacs?
21:47gnuvince_soup.findAll('img', src=re.compile(r'png$'))
21:47cooldude127just up and crashed
21:47Chousergnuvince_: more powerful than css, or than zip-filter?
21:48rzezeskiIs the TagSoup for Java derived from Neil Mitchell's TagSoup Haskell library?
21:48gnuvince_rzezeski: no, they're completely different
21:48rzezeskioh gotcha
21:49pjb3gnuvince_: with CSS3 "img[src$=.png]"
21:49gnuvince_Chouser: afaik, you can't search by regexes with CSS selectors.
21:49gnuvince_pjb3: did they add regexes to CSS3?
21:49Chousergnuvince_: ah, right. yeah, css is too limited.
21:49gnuvince_or is it just "ends-with"
21:49pjb3no, just starts with, ends with, contains
21:50gnuvince_ok
21:50pjb3which is not bad
21:50gnuvince_Sure
21:50pjb3and if you have a function language, it's easy enough to get more than you need and filter on the result set using the language
21:50gnuvince_But if I went ahead and did a library like that for Clojure, I'd make sure you're not limited to using substrings.
21:53pjb3(filter #(re-matches #"whatever" %) ($ "img[src$='.png']"))
21:54gnuvince_(find-all "img" {:src #"png$"})
21:57pjb3so how does this AOT thing work?
21:57pjb3do I still use gen-and-save-class if I want to extend a Java class?
21:58Chouserpjb3: for a few more days, yes.
22:04pjb3Chouser: So you can't use AOT to extend a Java class yet?
22:04Chouserpjb3: right. you can create a class with a main function, but that's it so far.
22:05pjb3Ok, so I was going to try to write an Applet with Clojure, but I guess that will have to wait
22:06pjb3but I could just write a Java class to implement the applet that just loads up a Clojure script, right?
22:06ChouserI believe rhickey's working on it actively -- making gen-class-like options available for the ns macro.
22:07rhickeyChouser: coming along - it's been a bear
22:08Chouserrhickey: so is it more or less fun to have an impatient audience (compare to two years of silent solo work)
22:10rhickeyI'm thrilled with the ever growing audience, and having you guys to run interference :)
22:10Chouserheh
22:15hiredmanman, I love "," as whitespace
22:18hiredmanlisppaste8: url?
22:18lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
22:50sohailChouser, more tagged type? :-)
22:55Chousernope, pprint tonight
23:26cooldude127man this place is dead
23:27Chouserwe're working. shhhh...
23:27Chouser;-)
23:29cooldude127hehe