#clojure log - Nov 17 2008

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

3:14 Lau_of_DK: Morning gents

4:20 polli: anyone using webjure?

4:29 tWip: polli: me, but I am the author

4:29 polli: oh :)

4:30 tWip: I'm having some problems let me see if I can sort them out

4:31 tWip: polli: ok, you can report bugs in the project or ask me directly

4:31 I'm planning to do some work on it this week to catch up with clojure changes

4:31 but now I'm on my employers time, so I'll check back in the evening :)

4:36 polli: tWip: I'll send you a diff

5:09 Pupeno: Good morning.

6:03 Hello Lau_of_DK.

6:06 Lau_of_DK: Hello Mr. Pupeno :)

6:07 Pupeno: Lau_of_DK: how are you doing?

6:07 Lau_of_DK: Pupeno: Im doing good thanks, you ?

6:10 Pupeno: Lau_of_DK: I've got a cold, but I'm doing ok.

6:10 Lau_of_DK: Pupeno: Many peopl sick these days :(

6:12 Pupeno: Lau_of_DK: More Clojure time! :)

6:14 duck1123: are either of you doing Clojure for your work, or only on your own time?

6:14 Lau_of_DK: duck1123: a bit of both

6:15 Pupeno: duck1123: only my own time for now.

6:17 duck1123: and you?

6:17 duck1123: currently my own time, but I have some ruby code that I'm thinking of translating

6:19 but I've been doing a web site with Compojure on the weekends

6:19 Lau_of_DK: Can we see? :)

6:22 duck1123: http://kronk.homedns.org:8080/

6:22 I spent the weekend fighting the Jena api

6:23 at least, when my wife wasn't on the computer

6:24 Pupeno: duck1123: what is it?

6:25 duck1123: it's going to be a site for managing rdf assertations

6:25 I'm still not very far

6:31 * Pupeno still doesn't really know what rdf is.

6:38 Pupeno: Is there a better way to write (map (fn [x] (.blah x)) xs)? that is, without defining the anonymous function.

6:39 Lau_of_DK: You mean like (map #(+ 5 %) (range 10)) ?

6:40 mibu: duck1123: what does it mean managing rdf assertions?

6:41 Pupeno: Lau_of_DK: is #( the syntax for defining a function without spelling out fn?

6:41 Lau_of_DK: I meant something like (map .blah xs), where blah is a Java method, except that (map .blah xs) doesn't work.

6:41 mibu: pupeno: (map #((.blah %)) xs)

6:42 pupeno: the extra parens inside shouldn't be there.

6:42 Lau_of_DK: user> (map inc (range 10))

6:42 (1 2 3 4 5 6 7 8 9 10)


6:43 Pupeno: Lau_of_DK: but I want to use a java method, not a clojure function.

6:44 mibu: (map #(.toLowerCase %) '("Hello" "World"))

6:45 Pupeno: mibu: that still defines an anonymous function.

6:45 mibu: duck1123: are you using an RDF store?

6:45 Pupeno: What I really wanted to know if there's a way to treat java methods as functions, maybe there isn't.

6:50 mibu: do you guys use enclojure?

6:51 Pupeno: mibu: I've tried.

6:51 mibu: it messed up my netbeans.

6:51 pupeno: did you have any troubles with it?

6:51 hoeck: Pupeno: http://paste.lisp.org/display/67182

6:53 * Lau_of_DK is away

6:53 Pupeno: mibu: 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.

6:56 OK, 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)?

7:15 (reduce concat list-of-lists) seems to do the trick.

7:15 Chousuke: Pupeno: I don't think there's a way to map java methods without wrapping them

7:18 Pupeno: #(.foo %) is the preferred method nowadays I think, but there's also (memfn foo)

7:19 Pupeno: Chousuke: I see. Well, the existence of memfn kind of prooves your point there.

7:19 Chousuke: the 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) :/

7:20 but maybe that's going past the level of cleverness allowed for a compiler :)

7:23 hoeck: Pupeno: there is java Reflection, see http://paste.lisp.org/display/67182 for an example

7:24 Chousuke: memfn does that.

7:26 Pupeno: Ok... time to learn how to play with a DB from Clojure.

7:26 Lau_of_DK: Pupeno: post your findings :)

8:09 ranok: haha

8:09 Bill C's homepage is pretty awesome

8:10 Lau_of_DK: link0r?

8:10 ranok: billc: Mine is quite similar, though I wasted way too much time on mine http://jacobtorrey.com

8:10 Lau_of_DK: http://bc.tech.coop/

8:10 Lau_of_DK: thanks

8:16 Pupeno: is http://mvnrepository.com/ down?

8:17 duck1123: ded for me

8:17 loaded

8:18 took a little while, but seems fine in w3m at least

8:18 Pupeno: ok, thank.s

8:19 duck1123: has anybody been working on an ORM for Clojure?

8:19 gnuvince: No that I've heard of

8:19 polli: tWip: I've sent you a patch

8:20 Pupeno: duck1123: well, the O doesn't make much sense in Clojure world, doesn't it?

8:20 duck1123: a SRM would be nice though (Structure Relational Mapping).

8:20 duck1123: DSRM?

8:22 I'm getting sick of writing SQL queries.

8:23 Chouser: duck1123: would you be any happier if writing SQL queries was string mangling? Such as if it were a nice Clojure-y DSL?

8:24 Lau_of_DK: Had a good nights sleep Chouser? :)

8:24 duck1123: Chouser: that would make it a bit nicer

8:24 Chouser: Lau_of_DK: yes thanks!

8:24 duck1123: I don't know of such a beast yet, but I've been pondering it some. I think it's what I want.

8:25 Pupeno: I think something like cl-sql would be nice, like (select [table1 table2] :where (= blah bluh)) etc.

8:25 tWip: polli: Got it, thanks. I'll apply it when I get home.

8:26 duck1123: speaking of, is there a better way to concat strings then (apply str (concat s1 s2)) or using format?

8:28 Lau_of_DK: user> (str "string1" "string")

8:28 "string1string"

8:28 ?

8:29 duck1123: hmm, I thought I tried that... I'll have to see again

9:18 lisppaste8: blackdog pasted "require?" at http://paste.lisp.org/display/70567

9:18 blackdog_: how come the commented out require works and the other does not?

9:18 doesn't find clojure.contrib.sql in the (require) version

9:24 duck1123: try (:require (clojure.contrib [sql :as sql]))

9:24 at least, that's how I always do it

9:26 blackdog_: 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

9:28 (doc require) needs updating for new package structure

9:31 duck1123: I'm sorry, wrap that in a ns

9:31 blackdog_: yes, that works

9:32 but (require) doesn't, I'm in a script and a namespace is irrelevant

9:32 duck1123: oh... I think I misunderstood your question

9:32 Chouser: without the ns macro, you need to quote the args: (require '[clojure...])

9:32 blackdog_: ah

9:33 ok that's better, thanks

9:43 blarf: what is the mod operator?

9:43 duck1123: rem

9:44 for remainder

9:44 blarf: is let permitted anywhere?

9:45 duck1123: you can't let inside of a parameter list i think

9:45 can't think of anywhere else

9:45 Lau_of_DK: Its a special form, and pretty well documented on clojure.org/special_forms#let

9:47 blarf: but if i have my own func: (defn any [cond coll]

9:47 (> (count (filter cond coll))

9:47 0))

9:47 (any #(= % true)

9:47 (let

9:48 rhickey: blarf: please paste:

9:48 lisppaste8: url

9:48 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

9:49 ranok: so

9:49 I've been developing my own language

9:50 that is rather lispy

9:50 but has a number of Erlang features

9:50 and some other stuff I find lacking

9:52 leafw: ranok: post it, document it, illustrate with good examples. Otherwise why talk about ii.

9:52 ranok: it's still very early in it's development

9:52 leafw: then tell us next year :)

9:53 ranok: it auto memoizes clean recursive lambda funcs

9:53 something I've found lacking in a number of other language

9:53 s

9:55 leafw: http://www.r4n0k.com/2008/10/28/new-programming-language-fang/

9:55 since you asked

9:56 Lau_of_DK: ranok: sounds interesting :) Maybe you should launch #fang for it, if it can raise a community?

9:57 ranok: Lau_of_DK: thanks

10:03 Lau_of_DK: user> (time (dorun (map #(if (prime? %) 0 -2) (range 1000000))))

10:03 "Elapsed time: 2716.511874 msecs"

10:03 nil

10:03 user> (time (dorun (pmap #(if (prime? %) 0 -2) (range 1000000))))

10:03 "Elapsed time: 13219.155438 msecs"


10:03 Does anybody know why pmap gives the worst performance of the 2 ?

10:04 ranok: Lau_of_DK: you on a multicore?

10:04 Lau_of_DK: Yes sir

10:04 ranok: 2 cores?

10:05 Lau_of_DK: Yes sir

10:05 wwmorgan: Lau_of_DK: did you try it more than once? There may be some JVM optimizations going on

10:05 Lau_of_DK: Tried it a few times yes, gives same results

10:07 ranok: perhaps there is some lock contention with the 2 cores

10:07 Lau_of_DK: I'd say thats impossible?

10:08 Both cores go up to about 60% laod each once I start computing

10:09 rhickey: user=> (doc pmap)

10:09 -------------------------

10:09 clojure.core/pmap

10:09 ([f coll] [f coll & colls])

10:09 Like map, except f is applied in parallel. Semi-lazy in that the

10:09 parallel computation stays ahead of the consumption, but doesn't

10:09 realize the entire result unless required. Only useful for

10:09 computationally intensive functions where the time of f dominates

10:09 the coordination overhead.

10:09 ranok: try doing something that requires more time on element

10:10 rhickey: Lau_of_DK: you are not meeting that criteria

10:10 blarf: is there no zip-function?

10:10 ranok: because isprime? is tiny, so most of the time is spent scheduling the work

10:10 Lau_of_DK: oh, because time of f is not big enough ?

10:10 @ rhickey ?

10:10 rhickey: Lau_of_DK: right

10:11 Lau_of_DK: rhickey: thanks :)

10:11 ranok: yeah, run something like factorial

10:11 blarf: is there no zip-function?

10:11 hiredman: blarf: interleave?

10:11 rhickey: blarf: doing what? map list?

10:19 blarf: zip [1 2 3] [4 5 6] -> [[1 4] [2 5] [3 6]]

10:19 i wrote one, just owndering if there is one

10:20 gnuvince: blarf: (map vector [1 2 3] [4 5 6])

10:20 rhickey: No there isn't as (map vector [1 2 3] [4 5 6])

10:20 is so easy

10:21 as is map list, map hash-map etc

10:22 blarf: i see, more general than normal zip

10:24 gnuvince: blarf: that's because map can take more than one collection, unlike in a language such as Haskell.

10:25 which is why they got zip up to zip8 or something

10:46 blarf: cant i define a function inside a function?

10:46 gnuvince: lol zip8

10:47 rhickey: blarf: (let [foo (fn [bar] ...) ...

10:47 blarf: yes that is a bit weird with Haskell, why cant i have multiple argument list? because of the purity?

10:48 gnuvince: blarf: because of the type system

10:48 And I was wrong

10:48 It stops at zip7

10:48 http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v:zip7

10:53 ReplRat: Does anybody know how to make Emacs see an external Slime info tree? It already loads the elisp OK.

10:54 blarf: how do i call Javas round method? i forgot the ynstax

10:54 wwmorgan: blarf: (Math/round 2.5)

11:03 blarf: how do i repeat an action ? like i want to test (Math/round (* (rand) 10)), can i do (run-times 100 f) ?

11:03 repeat is not what i want

11:04 wwmorgan: blarf: dotimes is what you want

11:04 rhickey: blarf: there is dotimes and repeatedly

11:12 tWip: What class loader is the agent system using? I'm getting weird ClassCastExceptions for the same class when using agents from servlets.

11:12 or rather, how do I control it

11:14 rhickey: tWip: are you doing add-classpath?

11:14 tWip: no

11:16 rhickey: tWip: it's hard to answer generally, as servlet containers mess with classloaders

11:16 tWip: yes

11:16 but is there a way I can control it?

11:17 I could easily set the classloader in some initialization code so that it is the same as the servlet classes.

11:17 rhickey: there is a *use-context-classloader* which, when true, will cause the thread's context-loader to be used

11:17 tWip: ok, so binding that should help... I'll try

11:26 rhickey: tWip: where is clojure.jar relative to the servlet?

11:26 tWip: i.e. in the servlet or installed in the servlet appserver?

11:26 tWip: in WEB-INF/lib

11:26 Chouser: I 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:27 blarf: how do take input?

11:27 gnuvince: from stdin you mean?

11:28 Chouser: blarf: you could use read-line

11:28 blarf: or any Java class you choose

11:30 blarf: I?

11:30 yes when i do print in interpreter i want input

11:30 wait

11:30 (getLine)

11:30 or soemthing

11:30 in the repl

11:32 rhickey: Chouser: looks interesting, if somewhat complex. Maybe there's a simpler Scheme pprinter?

11:32 blarf: how do i convert to int? (sorry for allt he questions)

11:33 Chouser: blarf: from what?

11:33 blarf: from string: (Integer. "12") ==> 12

11:33 tWip: Ok I don't get classloader errors anymore.

11:34 Still seems that Jetty doesn't like you messing with its request objects from other threads :P

11:37 Chouser: rhickey: it seems to me that pprinting code differently than non-code data will be more complex, but worth it. Do you agree?

11:42 blarf: is there a return ala Python? that just exits at a specific place ina function?

11:43 Chousuke: I don't know if there exist tricks to simulate return, but no.

11:43 Chouser: blarf: nope. If you feel like you want that, your function is probably straying toward imperative style.

11:46 Chousuke: functional style can be difficult to reason about, sometimes.

11:46 certainly it is for me.

11:46 Chouser: yes, it takes practice.

11:46 Chousuke: usually it helps to scale down your function in that case.

11:46 if it's getting too complex, write a subset of it as a separate function

11:47 then use that to write the bigger function

11:47 blarf: yes, imw riting tictactoe, some stuff just is imperative though (yeah i guess someone willa rgue with that :) )

11:47 Chouser: no, Clojure's practical. If it has to be imperative, so be it. But you'll have to do it without a "return" :-)

11:48 Chousuke: you'll have to think of your code as a series of transformations

11:48 when you add a move to the board, the result is an entirely new board.

11:48 and you discard the old one

11:48 unless you need it.

11:49 duck1123: I 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:49 Chousuke: just like when you add 1 and 1 in maths, the result is 2, which is not either of the ones.

11:50 optimally there's only one 1 anyway

11:54 sohail: is there a planet clojure somewhere

11:55 blarf: (play-game brd)

11:55 sohail: I've been busy doing other stuff and the mailing list is getting too busy for me to follow

11:55 Chouser: sohail: I don't think so.

11:55 blarf: java.lang.NumberFormatException: For input string: " (play-game coll)))"

11:55 sohail: Chouser, are there even enough blogs covering clojure? :-)

11:56 danlarkin: sohail: there will be eventually!

11:57 Chouser: but yes, the google group seemed to explode this weekend.

12:00 Chousuke: blarf: if you want help with errors, you'll need to give more context. use paste.lisp.org for pastes :)

12:00 sohail: the Clojure for LISP (caps!) programmers thread has some interesting posts

12:01 Chousuke: the OP is being a bit flamey though.

12:02 cemerick: a bit? :-P

12:02 Chouser: yeah, my natural responses to most of his comments have been... unhelpful, shall we say.

12:03 Chousuke: I'm not sure if he understands that vectors and maps and sets are equivalent with lists as data structures.

12:04 blarf: can if else branch like: if cond (1 expr) (several expr) ?

12:05 ?paste

12:05 Chousuke: (if cond (expr) (do (several) (exprs))

12:05 oops

12:05 )

12:06 * Chousuke needs lisp syntax highlighting for irssi...

12:06 hiredman: does do return the value of the last expression?

12:06 Chouser: hiredman: yes

12:06 Chousuke: IIRC yes.

12:09 sohail: Chousuke, if you use erc, I think it is built-in

12:10 Chousuke: I will not leave irssi :)

12:15 askentasken: hmm

12:15 did the paste come?

12:15 http://paste.lisp.org/display/70574

12:17 oh wait it does woek now, i have no idea what the error was caused by before though

12:17 * Pupeno has to still try Emacs for anything else than editing.

12:17 askentasken: but how can i better "move"

12:18 Chouser: askentasken: what's updateAt?

12:18 askentasken: merging computer-move and player-move but i cant branch the if with lets and then "jump back"

12:18 rhickey: Chouser: how do you distinguish code from data?

12:19 Chouser: rhickey: two possibilities: yet another option (just like line length, etc.) or make a guess (PersitentList starting with symbol named def is probably code)

12:20 Chousuke: askentasken: camelcase isn't very lispy. :) but hmm

12:20 askentasken: Chouser: 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:20 camel-case?

12:20 helloThere?

12:21 sohail: Chouser, why do you want to differentiate?

12:21 Chousuke: askentasken: yeah

12:21 askentasken: i wanted to differ betwene fucntion and variable, is underscore lispier?

12:21 Chousuke: askentasken: don't differentiate.

12:22 askentasken: they're just names

12:22 Chouser: sohail: (defn foo [a b] **wrap-here** ...) vs. (a b c d e **wrap at end of line**)

12:22 Chousuke: askentasken: a function can be used as data too

12:22 like you do with map there :P

12:22 wwmorgan: askentasken: move looks like a good place to use a multimethod

12:22 drewr: Chouser: I thought of you when reading http://steve-yegge.blogspot.com/2008/11/ejacs-javascript-interpreter-for-emacs.html

12:23 Chouser: askentasken: use a vector instead of a list, and then use assoc instead of updateAt: (assoc [7 8 9] 1 99)

12:23 drewr: really? Why's that?

12:24 Chousuke: what is that updateAt function anyway?

12:24 drewr: Chouser: Implementing JS in lisp I guess.

12:25 rhickey: Chouser: Clojure->ClojureScript->ejacs->elisp->extending emacs with Clojure!!

12:25 drewr: Not exactly what you've been doing, but related.

12:25 Yes!

12:25 hiredman: hah!

12:25 Chouser: ah. lovely. :-)

12:25 hiredman: mad as hatters

12:25 sohail: Chouser, oh for printing. Is it really important?

12:26 Chouser: sohail: I think for a pretty-printer, it'd be very nice. Think (pprint (macroexpand ...))

12:26 hiredman: that would be nice

12:27 sohail: I forget, what does slime do with clojure's macroexpand

12:28 Chousuke: was let a recur target?

12:29 askentasken: Chousuke: i updated with updateAt

12:30 Chousuke: sohail: it doesn't pretty-print it, that's for sure

12:30 askentasken: http://paste.lisp.org/display/70574#1

12:31 sohail: Chousuke, ok

12:31 Chouser: askentasken: use assoc!

12:34 askentasken: i do!

12:34 now

12:39 wwmorgan: would a multimethod maie it shorter and make the common tasks in both to one?

12:41 wwmorgan: askentasken: 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:42 you would want to do what you suggest anyway, whether you use multimethods or not

12:47 askentasken: yes but i dont see how to do it really

12:47 no matter how i do it seems i need to separate branches

12:47 since one calls for input

12:48 you are right about AIs, isee what you mean, then i could easily define new move for different strategies

12:49 can i do if-else-let-let?

12:49 one let if true or else the other let?

12:50 kotarak: (let [x (if condition a b)] ...) like that?

12:51 askentasken: ah

12:52 Chousuke: hmm

12:56 Pupeno: lisppaste8: url

12:56 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

12:57 askentasken: hmm the if-else-let still is 10 lines

12:57 lisppaste8: Pupeno pasted "Failure creating table" at http://paste.lisp.org/display/70577

12:57 askentasken: oh 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:58 Pupeno: Any ideas why that code fails with the error at the bottom?

12:58 I'm trying to create a table with an auto-increment id using derby.

13:04 askentasken: when using multi-methods, i can have some of them take no args and some taking several or 1 right?

13:04 like 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:04 Chousuke: askentasken: I made a version using multimethods as an example... I think has-winner? is buggy though :D

13:05 http://paste.lisp.org/display/70574#2

13:05 topo: is it possible to use clojure with emacs?

13:06 Chousuke: I don't know what the purpose of sum-indexes was so I just put in something :P

13:07 deklund: topo: see http://clojure.org/getting_started#toc4

13:07 askentasken: im tryong to grok the multis, but :

13:07 (defmulti move :player)

13:07 (defn human [] {:player :Human

13:07 :fn (Integer. (read-line))})

13:07 does it have to be a {} ?

13:08 Chousuke: keywords are functions of maps

13:08 in there, :player is actually a function

13:08 and (:player {:player 'foo}) will return 'foo :)

13:08 topo: ok

13:08 askentasken: ah vr nice Chousuke

13:09 Chousuke: multimethods are a bit tricky I guess

13:09 I still don't grok them completely :P

13:10 however, the code in my paste seems to work (at least the multimethods) so maybe it'll work as an example.

13:11 askentasken: basically, the dispatch-function is a function that returns dispatch values (which can be anything)

13:11 askentasken: what is buggy about hasWinner? though?

13:11 Chousuke: well it declares me the winner after the moves "2" and "3"

13:12 but that might just be my sum-indexes

13:12 I had no clue what it was supposed to do and didn't feel like thinking so I just put something :P

13:12 askentasken: not me....

13:12 Chousuke: well, your sum-indexes might be doing something else.

13:13 I see you're using some maths trick to figure out the winner but I wasn't able to tell how it worked.

13:13 askentasken: (defn sum-indexes [coll indexes]

13:13 Chousuke: and your original paste was missing sum-indexes :)

13:13 askentasken: (sum (map #(nth coll %) indexes)))

13:13 (defn sum [coll]

13:13 (reduce + coll))

13:13 Chousuke: hmmh :/

13:13 askentasken: you guessed pretty well

13:16 Chousuke: anyway, about multimethods: each (defmethod) call defines how to behave for given dispatch values as returned by the dispatch function

13:17 so (defmethod move :human [whatever here] ...) defines how move behaves when your dispatch function returns ":human"

13:18 you can return vectors or whatever from a dispatch function too.

13:19 that's the entirety of my multimethod knowledge :p

13:19 ericthorsen: is 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:22 Chouser: ericthorsen: I think that's it. If you could have any sytax you want, what would it be?

13:23 ericthorsen: Chouser: I guess something with defaults from a vector bound to the ordinals of the keys...

13:24 Chouser: Like (let [{:keys [a b c] :or [1 2 3])

13:24 Chouser: hm, that seems nice.

13:24 ericthorsen: Chouser: I already selected the keys...just need default values for them

13:24 Chouser: right.

13:31 hm, 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:32 so maybe (let [{:keys [a b c :or 1 2 3] :syms [d e f :or 4 5 6]} ...

13:33 Chousuke: askentasken: noticed that there's a nicer definition for print-board too: (doseq [part (partition 3 board)] (println part))) :)

13:37 heh, found the bug too.

13:37 I had key and val swapped in assoc

13:37 now the game runs and works correctly :)

13:46 Lau_of_DK: Good evening gents

13:50 askentasken: your dose doesnt work

13:52 Chousuke: which version of clojure are you using?

13:55 askentasken: i can do recursion ina defmethod right?

13:55 20080916 btw

13:58 Chousuke: that's pretty old

13:58 you should be using SVN :)

13:58 there were some big changes recently.

13:59 askentasken: ok

14:03 danlei`: askentasken: you can, but there is no tail-call optimization, you can get that by `recur'

14:04 Chouser: recur also works in a defmethod :-)

14:04 danlei`: yes, that's what i meant

14:05 askentasken: yes i know

14:09 Lau_of_DK: kotarak: I just read your documentation for Euler 191 and 205 + the code. Thanks alot, that was very insightful. Nice consise solutions also

14:10 askentasken: hmm actually it would be pretty easy to add AI anyway

14:10 without multimethods

14:10 meh them multis break my code

14:10 kotarak: Lau_of_DK: thanks. :)

14:10 Lau_of_DK: brute force - beh

14:10 Lau_of_DK: in that way it's much more fun

14:11 Lau_of_DK: There was some smarts behind it

14:22 Chouser: Have you fixed The Source ?

14:25 @ 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:25 Chouser: Lau_of_DK: (source) may be doomed now that .clj files aren't included in clojure.jar

14:29 Lau_of_DK: Chouser: Surely there must be a work0round ?

14:29 hiredman: Lau_of_DK: does a Thread exist after it has finished running?

14:30 Lau_of_DK: hiredman: thats the question

14:30 hiredman: well, Thread is an Object

14:31 do Objects hang around when you are done with them?

14:31 Chouser: agents are not threads. an agent hangs around as long as it's being referenced by something.

14:31 Lau_of_DK: If they do, I want to know how to kill them

14:31 cooldude127: if you lose a reference to an agent, does it go away?

14:31 Chouser: hiredman: I think Threads are a little different, since they have OS resources.

14:31 cooldude127: and stop doing its stuff?

14:31 Chouser: cooldude127: yes.

14:31 cooldude127: no

14:32 Lau_of_DK: cooldude127: maybe

14:32 cooldude127: yes it goes away, but it keeps doing its stuff?

14:32 Chouser: I think a thread running an action for an agent will continue running and will in fact keep a reference to the agent.

14:32 cooldude127: so it's not really lost in the gc sense

14:33 Chouser: When the action is complete, if nothing else is referencing the agent, the agent will go away.

14:33 cooldude127: something still has the reference

14:33 Lau_of_DK: But Chouser, why do we always have to (send-off *agent* self) if it lingers?

14:33 tWip: where would it linger? if not referenced

14:33 askentasken: i got multis working and its slightly more code but might make it easier to change and work with later

14:33 i got multis working and its slightly more code but might make it easier to change and work with later

14:34 jgracin: I wonder who will be the first 100 user in history of Clojure.. :-)

14:34 100th

14:34 cooldude127: how do you kill a continuously running agent? would this involve defining the action so there is a flag to stop?

14:34 albino: jgracin: is that based of mailing list or what?

14:34 sohail: Chouser, is the test contrib being tested on a build server?

14:34 Lau_of_DK: cooldude127: thats how I do it

14:34 jgracin: on irc users right now.

14:34 tWip: I didn't think agents are running per se

14:35 sohail: and really, why doesn't rhickey add tests... This perplexes me

14:35 tWip: threads run, agents just allow access to state

14:35 Lau_of_DK: agents are thread-wrappers afaik

14:35 tWip: no agents are run in a thread pool

14:35 Chouser: cooldude127: 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:35 sohail: not that I know of, but I'm not sure.

14:35 cooldude127: Chouser: that's what i thought

14:36 oh man ERC is making me giddy

14:36 Chouser: tWip: 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:37 rhickey: sohail: testing is overrated, at least the traditional unit tests, but I'm all for running tests others write

14:37 tWip: yes.. therefore I don't see the issue of "making an agent stop". do you mean possibly long running fns on the agent

14:37 rhickey: hagman wins!

14:37 jgracin: and we have a winner!!

14:37 tWip: :D

14:37 tomhickey: =)

14:38 cooldude127: tWip: i mean an action that sends the same action again, making the same action run on the agent over and over

14:38 sohail: rhickey, 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:38 Chouser: congrats, hagman!

14:38 sohail: hagman is in the wrong channel

14:38 jgracin: sohail: :-)

14:39 tWip: cooldude127: why not just recur in a thread then?

14:39 rhickey: sohail: 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:40 sohail: rhickey, I'm not closed to your approach either (let others write the tests?) so I am interested in how it turns out

14:40 cooldude127: tWip: 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:41 * Chousuke is having too much fun with this tic-tac-toe thing :p

14:41 rhickey: cooldude127: an agent runs on a thread from a thread pool

14:41 cooldude127: ok

14:41 it's also a little simpler to think about i would say

14:41 hiredman: does clojure have one thread pool and all agents are run on threads from that pool?

14:42 Chouser: two thread pools -- one sized based on number of cores (for send)

14:42 rhickey: hiredman: one for send, one for send-off, right now. I 'll probably add agent pools at some point

14:42 Chouser: one that grows (for send-off)

14:42 drewc: rhickey: i need a domain name for the clojure project hosting site .. any ideas?

14:42 hiredman: I see

14:43 tWip: projecture?

14:43 gnuvince: :)

14:43 drewc: i like!

14:43 cooldude127: nice

14:43 that was quick

14:43 gnuvince: The pronounciation is fun

14:43 sohail: clojforge? clojr (web 2.0)

14:44 cooldude127: i thought about clojforge

14:44 Chouser: cloforj

14:44 drewc: yeah, i thought about the forj puns too.

14:44 too punny!

14:44 Chouser: projecture's better though

14:44 cooldude127: i can't imagine tell someone about cloforj and having them not ask how to spell that

14:44 Chouser: or just "forj"

14:44 forjure

14:44 * gnuvince is +1 for projecture

14:45 cooldude127: my vote is for projecture

14:45 forjury

14:45 lol

14:45 sohail: clojectsrus

14:45 I don't even know what that means

14:45 cooldude127: lol

14:45 this is getting out of hand ;)

14:45 rhickey: clojects.org

14:45 sohail: I got it!

14:45 gnuvince: sohail: dude, I just broke my jaw trying to pronounce that

14:45 sohail: proj4cloj

14:45 kotarak: +1 projecture. cloforj is too hard a break between clo and forj and Klo is something different in germnan.

14:45 cooldude127: clojects!

14:45 rhickey ftw

14:46 * sohail likes proj4cloj

14:46 sohail: clojects is also nice

14:46 * cooldude127 likes clojects and projecture

14:46 candera: clojury

14:47 openjure? :p

14:47 Lau_of_DK: rhickey: 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:47 sohail: projecture sounds like a math library

14:47 gnuvince: drewc: start a poll on the google group and let's see what happens

14:48 Chouser: Lau_of_DK: creating an agent doesn't "start" anything

14:48 drewc: gnuvince: sounds like a plan.

14:48 cooldude127: Lau_of_DK: that doesn't start the agent, send or send-off does

14:48 Lau_of_DK: Ok 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:48 rhickey: Lau_of_DK: you got good answers, agents are subjects to gc, threads running their actions return to the pool

14:48 Lau_of_DK: In Clojure, edited in Emacs, evaluted to Slime

14:48 Chouser: Lau_of_DK: unless the agent is queued or running, just losing the reference to it will allow GC to take it away.

14:49 cooldude127: write the function in a way that allows you to stop it on demand based on a ref or something

14:49 at least i think that would work

14:49 Lau_of_DK: Loosing the reference, means (def agents (map ...)), then I have to redef agents to 0 ?

14:50 Chouser: cooldude127: yep: (loop [...] (when @keep-running (recur)))

14:50 cooldude127: yeah that's what i thought

14:51 Chouser: flying read. so pretty.

14:52 cooldude127: what happens if you do (send nil my-action)

14:52 error?

14:52 tWip: null pointer exception?

14:52 Chouser: tWip wins

14:52 cooldude127: k

14:54 Lau_of_DK: cooldude127: use ERC in emacs, you could test while chatting :)

14:55 cooldude127: that's true

14:55 i'm on ERC, it's lovely

14:55 Lau_of_DK: Emacs supports IRC, Email, Slime, you name it. For Vim users we have a special treat: Press dd to delete a whole line!

14:55 tWip: using irssi now (for years) but I remember zenirc being a good and very unobtrusive client for emacs

14:56 cooldude127: yeah i just started using erc like half an hour ago

14:56 tWip: I don't think it's developed any more though, as the site has last news from january 2000

14:57 cooldude127: tWip: zenirc or erc?

14:57 tWip: zenirc

14:57 Lau_of_DK: k, it was just a quick mention to taunt the Vim users once again, lets get back to Clojure

14:57 cooldude127: lol

14:58 send to nil gets illegalargumentexceptions

14:58 tWip: nice. that means it's actually checked :)

14:58 cooldude127: wait i don't think that's all i messed up tho

14:59 alright it's actually a nullpointerexception

14:59 illegal arg is what happens when you use (x) instead of [x] in your arglist

14:59 Chouser: heh

14:59 cooldude127: we need some more descriptive errors

15:00 Chousuke: definitely

15:01 Lau_of_DK: What could be more descriptive than "Agent has errors" ?

15:01 Chousuke: it'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:01 sohail: cooldude127, there is a IRC client with emacs proper now

15:02 (not erc, iirc)

15:02 cooldude127: my complaint is that i could use something like syntax error for when i use (x) instead of [x]

15:02 sohail: since what version?

15:02 idk erc is making me happy right now

15:03 sohail: cooldude127, maybe since 22? I forget

15:03 * sohail is using xchat right now anyway

15:03 cooldude127: lol

15:03 i'm on cvs actually so if it's there, i have itt

15:04 i believe there's rcirc or something

15:04 chousukerc: hi

15:04 had to try :P

15:04 cooldude127: but apparently erc was more featureful

15:04 try what?

15:04 chousukerc: Though I'm pretty sure I can't replace irssi with erc

15:04 erc

15:05 cooldude127: oh

15:05 irssi confused the hell out of me when i tried it

15:05 Lau_of_DK: Guys

15:05 Get back to Clojure :)

15:05 cooldude127: NEVER

15:06 Chousuke: whoops

15:07 I disabled erc-mode by accident

15:07 cooldude127: lol

15:07 Chousuke: and now I can't IRC

15:07 cooldude127: can't turn it back on?

15:07 M-x erc-mode ?

15:07 Chousuke: I have no idea how.

15:08 there is no such command

15:08 cooldude127: ahh how did it get disabled?

15:08 gnuvince: C-x C-c irssi <Ret>

15:08 Chousuke: I didn't turn it off, I just enabled clojure-mode and erc stuff was replaced.

15:08 cooldude127: oh no

15:08 damn major modes

15:08 gnuvince: thanks for your suggestion ;)

15:08 gnuvince: cooldude127: any time :)

15:09 * gnuvince used to IRC with M-x rcirc

15:09 gnuvince: It worked well enough, but I prefer irssi

15:10 Chousuke: I'll stick with irssi :p

15:10 cooldude127: yeah well i'm switching from colloquy

15:10 MarkVolkmann: I'm trying to understand what assoc does, but I don't understand the doc for it. Can someone show me a simple example?

15:10 rhickey: user=> (assoc {:a 1} :b 2)

15:10 {:b 2, :a

15:11 {:b 2, :a 1}

15:11 cooldude127: assoc gives you a new map or vector with the given key and value in it

15:11 like in rhickeys example

15:11 Chousuke: it associates a value with an associative container. the doc says map but it works with vectors too :p

15:11 Lau_of_DK: Can I send-off agents with a timeout value ?

15:12 cooldude127: user> (assoc [1 2 3] 2 1)

15:12 rhickey: Lau_of_DK: no

15:12 cooldude127: [1 2 1]

15:12 Chouser: Lau_of_DK: timeout of what? How long it can be stalled in the queue before giving up/

15:13 Lau_of_DK: Chouser: 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:13 rhickey: Lau_of_DK: if you are using a blocking API, it probably has a timeout of its own

15:14 Lau_of_DK: All Im using is agents, and then stream-reading a URL

15:17 Chouser: Lau_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:17 Lau_of_DK: Chouser: 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:19 rhickey: Lau_of_DK: killing threads is not going to happen - you have to start wanting something else :)

15:19 Chouser: The blocking call probably has a way to report whether it succeeded vs. timed out, so then you can handle that condition appropriately.

15:20 askentasken: is it one index 2 indeces or indexes?

15:20 Chousuke: indices

15:20 drewc: indices

15:20 Chousuke: indexes works too I suppose.

15:21 krukow: I was just looking through the Clojure Java sources to learn more. I have a couple of questions...

15:21 drewc: i would also accept indexes

15:21 :)

15:21 krukow: : 1) I think there is a bug in ASeq.java the containsAll method -- it seems to implement containsSome?

15:22 Lau_of_DK: rhickey, Chouser: Thanks .)

15:23 krukow: 2) 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:24 cooldude127: krukow: that's most likely correct

15:24 krukow: indices, I think is the correct word ;-)

15:24 cooldude127: yes

15:24 Chouser: krukow: re 2) yes, I think that allows direct one-step calls that can be inlined by the JVM well.

15:25 cooldude127: 21 parameters can suck it up

15:25 lol

15:25 Chouser: well, they still work, just not quite as fast.

15:25 have to create an array object and fill it out.

15:25 cooldude127: exactly

15:25 boo arrays

15:25 hiredman: use reduce instead of apply :P

15:25 krukow: yeah ;-) I think 10 should have been enough, though ;-)

15:26 Chouser: oh, sorry, I didn't know precisely what algorithm you meant by "suck it up" :-)

15:26 cooldude127: lol

15:26 i think the most i've ever used was like 5 maybe

15:27 askentasken: http://paste.lisp.org/display/70588

15:28 isnt it pasting direclty to here anymore?

15:28 sohail: drewc, for some reason I can't post to google groups through gmane so I vote for clojr :-)

15:28 askentasken: anyway, theres my tictactoe, a little upgraded

15:28 hiredman: the bot seems to be in and out

15:28 MarkVolkmann: Thanks for the assoc examples! I've got it now.

15:29 * drewr officially can't keep up with the list or with this channel anymore

15:29 rhickey: hiredman: apply is efficient too, it does not use an array - feeds the seq right to applyTo

15:29 drewc: sohail: i'm leaning toward clojr myself.

15:29 Chouser: askentasken: lookin good. I think you could use (some ...) instead of (> (count (filter ...)) 0)

15:29 sohail: drewc, it takes some getting used to

15:30 Chouser: isn't "clojr" pronounced the same as "clojure"?

15:30 hiredman: rhickey: good to know

15:30 cooldude127: Chouser: yeah that is a concern

15:31 MarkVolkmann: Is there a deeper meaning to the name than the word "closure" with the "s" replaced by a "j" for Java?

15:31 Chouser: askentasken: and "not-any?" for the (= 0 (count ...)

15:31 abrooks: Chouser: No. You're supposed to silently clench your jaw when saying "clojr".

15:31 Chouser: abrooks: ah, got it. thanks.

15:31 sohail: Chouser, you have to say clojr while hugging people

15:31 askentasken: some retrns nil

15:31 sohail: Maybe clojure-projects.org would be the best thing

15:31 askentasken: does nil test as false?

15:31 abrooks: Too bad forj is already Google un-virginal. I liked forj.

15:32 Chouser: askentasken: yes

15:32 askentasken: nil and false are the only things that act like false in a boolean context.

15:33 askentasken: sweet use of a keyword as your dispatch fn!

15:33 rhickey: krukow: containsAll is fixed

15:34 drewc: Chouser: pronunciation aside, i'm looking at clojr.net, which is different enough from clojure.org, and it's a cool url imo! :)

15:35 * sohail likes http://clojr.(net|org) as a url

15:35 rhickey: drewc: that wouldn't be my preference as it has the same pronunciation

15:35 sohail: clojects is hard to pronounce imo

15:36 Pupeno: drewc: hi there!

15:37 drewc: rhickey: ok, you have veto.

15:37 askentasken: http://paste.lisp.org/display/70589

15:37 java.lang.IllegalArgumentException: No method for dispatch value: null

15:37 rhickey: sohail: like projects, or clozhects

15:37 AWizzArd: rhickey: how close is the 1.0 realease away? Do you think it might happen this year?

15:37 sohail: rhickey, might be me, but it doesn't roll off the tongue too easily

15:38 askentasken: sometimes it works, sometimes it doesnt

15:38 rhickey: AWizzArd: I hope so

15:38 askentasken: are any and not-any added in newer versions?

15:38 drewc: projecture.net is the other most popular choice. rhickey?

15:38 Chouser: AWizzArd: if he misses 2008, he's going to call in 2.0

15:38 rhickey: right? :-)

15:38 rhickey: drewc: projecture fine by me

15:38 kotarak: anything 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:39 AWizzArd: Would 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:39 Chouser: askentasken: "not-any?" has a question mark

15:39 askentasken: Chouser: askentasken: sweet use of a keyword as your dispatch fn! ironic there? whic exactly do you mean?

15:39 rhickey: Chouser: not calendar year, year from release

15:39 Chouser: rhickey: ah. so that gives you 'til Oct 2009?

15:39 rhickey: Chouser: yup

15:39 Chouser: askentasken: honest, not ironic. I like it!

15:40 Pupeno: I 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:40 drewc: Pupeno: hey, long time no see!

15:40 Chouser: Pupeno: use defn- to define a private function

15:40 kotarak: Pupeno: you can use defn- for private functions

15:40 AWizzArd: :-)

15:41 Pupeno: Chouser, kotarak: Oh! that was it. Thanks.

15:41 MarkVolkmann: Where 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:42 Pupeno: drewc: how are you?

15:42 Chouser: MarkVolkmann: yeah, there's about it. Many of the .clj files have examples at the end.

15:43 MarkVolkmann: you may be able to dig up some examples in the IRC log or google group.

15:43 drewc: Pupeno: things are good. Work is steady and interesting, and life on the water is wonderful... how are things with you?

15:44 Pupeno: drewc: life on the water?

15:45 drewc: I'm fine, thanks.

15:45 Chousuke: AWizzArd: here's a version of your game that works on recent versions http://pastebin.com/f115b1f06 (contains spoilers!)

15:45 Lau_of_DK: Is there something similar to fork, when I just want to send-off a function to another thread, like when calling from UI ?

15:46 drewc: Pupeno: i moved on board a sailboat early this year.

15:46 Chouser: Lau_of_DK: what's wrong with "send-off"?

15:46 AWizzArd: Chouser: my game?

15:46 Chousuke: er

15:47 I meant askentasken :)

15:47 AWizzArd: ic

15:47 Lau_of_DK: Chouser: nothing, except it requires an agent, which I was looking to avoid

15:47 Pupeno: drewc: you *moved*?

15:47 drewr: drewc: Are you sailing right now?

15:49 askentasken: Chouser: but where? i odnt even know what u mean

15:50 drewc: Pupeno: well, threw away most of my stuff and climbed on is more accurate, but yeah, i have no place on land.

15:50 drewr: tied comfortably to the dock :)

15:51 Chouser: Lau_of_DK: if you don't want an agent, you'll have to deal with Thread directly.

15:52 Pupeno: drewc: wow!

15:52 Lau_of_DK: Chouser: is this way too dumb? (defmacro async

15:52 [expr]

15:52 `(send-off (agent 0) ~expr))


15:52 Chouser: Lau_of_DK: (.run (Thread. #(prn "hi")))

15:52 Pupeno: drewc: do you have any pictures?

15:53 Chouser: Lau_of_DK: (agent 0) is fine, or (agent nil). But expr has to be a fn of at least 1 arg.

15:53 Lau_of_DK: Why ?

15:53 :)

15:53 drewc: Pupeno: you bet. I have 2 boats .. the smaller one i live on, they larger is up on the boat yard being repaired.

15:54 Lau_of_DK: Chouser: Why as in: Why not 0 args?

15:54 Chouser: askentasken: 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:54 drewc: Pupeno: http://versions.tech.coop/kanu.jpg <-- smaller on (29th LOA)

15:54 Chouser: Lau_of_DK: send and send-off always pass in the agent as the first arg

15:54 askentasken: java.lang.IllegalArgumentException: No method for dispatch value: null

15:55 so it is an error in the multimethods right?

15:55 Lau_of_DK: oh....

15:55 cooldude127: Lau_of_DK: that is, the state of the agent

15:55 drewc: Pupeno: http://versions.tech.coop/cestlavie.jpg <--- and the ship herself (50ft LOA).

15:55 Lau_of_DK: Chouser: now Im using this: (.run (Thread. #(start-stress-test)))

15:55 (JOptionPane/showMessageDialog nil "Agents dispatched")), the JOptionP is never shown - how come?

15:56 cooldude127: not the agent itself

15:56 wwmorgan: asktentaksken: you need to pass a map into the multimethod that has the appropriate key

15:56 Pupeno: drewc: that's amazing. Do you live by yourself there?

15:56 askentasken: Chouser : ok but you said nice use of, where i use what?

15:57 Chouser: cooldude127: oh, right, sorry.

15:57 drewc: Pupeno: no, my wife is with me, and her daughter stays sometimes... and 3 ferrets and a bird.

15:58 Lau_of_DK: Does anybody know how I can kill Slime really quickly, without closing Emacs?

15:58 Pupeno: And I complain because my place is so small...

15:58 drewc: how do you get on-line?

15:58 Chouser: drewc, Pupeno: I don't mean to be rude, but could you guys take this elsewhere?

15:58 drewc: Chouser: of course, sorry 'bout that!

15:59 Pupeno: Chouser: sorry!

15:59 Chouser: np. I wouldn't have said anything except the channel is so busy at the moment.

16:00 askentasken: I meant (defmulti move :player) <-- using :player as your dispatch function.

16:00 Chousuke: askentasken: you're calling (move (:board player)) there!

16:00 askentasken: it'll give you an error since you don't have a method for boards :P

16:01 askentasken: also: instead of recursive calls, use (recur ...)

16:01 Lau_of_DK: Guys, 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:01 (map agent

16:01 (replicate (get$ :count-of-agents) 0))))

16:01 duck1123: I'm writing some C++ code for school. I modified a function and had to resist the urge to hit C-M-x

16:01 Lau_of_DK: (get$ :cou..) = 50

16:04 Chouser: Lau_of_DK: send-off returns the agent, so your top-level map there will return a lazy-seq of agents.

16:04 Lau_of_DK: but by that time, they will all be running right Mr. Houser ?

16:04 Chouser: if you put that seq in var, you'll not get any agents at all: (def agents (map...))

16:05 but 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:06 Lau_of_DK: Alright, so what youre saying is. I gotta dorun ?

16:06 Chouser: I'm saying that's one solution, yes.

16:06 hiredman: map is lazy, so the the send-off doesn't happen until you walk the list somehow

16:06 Lau_of_DK: Houser, I thank thee

16:08 oh man

16:08 chock

16:08 It started, before I could look around it had many over 4000 hits on my webserver

16:09 askentasken: oh using player, player isnt a builtin? anyway that was Chousuke who inspired me

16:09 java.lang.IllegalArgumentException: No method for dispatch value: null

16:10 Chousuke: askentasken: did you fix the (move (:board player)) bug? :P

16:10 askentasken: (move (player :board)))))

16:10 ?

16:10 but i think isee it shouldnt work at all

16:10 it is the work soemtimes i dont get

16:11 Chousuke: you want just (move player)

16:11 note, player != :player

16:11 wwmorgan: askentasken: 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:12 askentasken: i see now

16:14 (assoc (player :board) mov 1)

16:14 plaer :board or :board player?

16:14 Chousuke: :board player

16:14 actually

16:14 either works, since player is a map

16:14 maps are functions of their keys, and keywords are functions of maps :)

16:15 very powerful, but can be confusing

16:17 once 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:28 This 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:28 askentasken: (defn human [coll] {:player <<--- if that what u mean tis ro the example at the clojure homepage

16:29 Chousuke: yes i was thinking the same

16:29 Chousuke: no I mean in the play-game function

16:29 askentasken: i will prob make a GUI and min-max-algorithm later

16:29 Chousuke: where you do stuff like (let [newer_board (move (_second new_board))] ...)

16:29 when you mean (move _second)

16:30 and everywhere else too you make the same mistake.

16:30 'move takes a player, not a board :)

16:31 and a player is a map that has two keys, :player and :board

16:31 AWizzArd: yes, although doseq lets the reader see that you are doing something imperative

16:31 wrong channel

16:32 wwmorgan: I think move should take a player key and a board

16:32 Chousuke: wwmorgan: either works

16:32 wwmorgan: for a player to have a board doesn't really make sense

16:32 Chousuke: a single-argument move is easier to extend

16:32 wwmorgan: well, you could call it game-state then :)

16:33 wwmorgan: yeah. it makes the multimethod easier to define too

16:33 Chousuke: with :player being the player whose turn it is

16:33 askentasken: it would clear things up because im so confused over this now

16:33 Chousuke: askentasken: what exactly is confusing you?

16:33 perhaps the use of :player as a function?

16:34 Chouser: AWizzArd: you're talking about Clojure in another channel/

16:34 ?

16:34 AWizzArd: Chouser: in private

16:34 Chousuke: remember: 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:35 askentasken: so, when you call (move player), behind the scenes clojure calls (:player player), which returns either :Human or :Computer

16:36 askentasken: and then clojure knows which method to run.

16:36 askentasken: http://paste.lisp.org/display/70595 </ c4rrent vers56n

16:36 Lau_of_DK: Guys - I get alot of these "Reflection warning: xyz cannot be resolved", can I code in a way that doesnt produce all this warnings?

16:37 Chouser: Lau_of_DK: (set! *warn-on-reflection* false)

16:37 Lau_of_DK: Chouser: so its not my home-grown coding style?

16:37 albino: heh, that advice seems to be coming out daily, the reflection one I mean

16:37 askentasken: WHY 5S 5T EVEN W6R25N AT A33

16:37 duck1123: denial is the best debugging policy

16:37 askentasken: why is it even workin at all?

16:38 Chousuke: askentasken: how far does it work?

16:39 oh wait! your play-game is correct now. I just got confused by your functions

16:39 and move methods are okay too.

16:40 those (pr _first) and (pr _second) don't make much sense though :)

16:44 wwmorgan: askentasken: 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:48 then you can refactor move like this: http://paste.lisp.org/display/70574#4

16:50 Lau_of_DK: If I call (def xyz zyx) in a defn, is it still globally declared?

16:50 rhickey: Lau_of_DK: yes, defs are global

16:50 Lau_of_DK: thanks

16:51 Chousuke: askentasken: http://paste.lisp.org/display/70595#1

16:55 askentasken: h cond yes

16:55 Chousuke: the :else there is not special syntax btw. it's just something that has a true value :)

16:56 kind of like having no "else" at all and resorting to else if (true) { ... } :P

16:58 except that in most non-lisp languages, that would be a weird thing to do.

17:01 hiredman: I think with clojure the main problem there is "true" is not a fn

17:02 Chousuke: well you could use true too :/

17:02 hiredman: but I think the reader would accept that, and you would knock it into shape with a macro

17:02 Chousuke: what?

17:03 hiredman: Chousuke: if you wanted to use that syntax in clojure :P

17:04 Chousuke: ah, righ.

17:04 well who would

17:04 not me.

17:05 better just move the parentheses around a bit

17:10 Lau_of_DK: We have (reduce max seq) but do we have something like (reduce average seq) ?

17:11 wwmorgan: Lau_of_DK: arithmetic or geometric mean?

17:11 hiredman: erm

17:11 Lau_of_DK: arith

17:11 hiredman: just reduce with + then / by (count seq)

17:11 oh

17:13 wwmorgan: you can't do that with just a reduce

17:13 hiredman: you could

17:13 but I don't think you could cleanly

17:14 but my math is not very good

17:14 wwmorgan: (reduce hypothetic-fn [100]) => 100 and (reduce (hypothetic-fn [100 100 100]) => 100

17:14 but tack an extra element on to each list and the behavior changes

17:15 Lau_of_DK: so (/ (reduce + seq) (count seq)) is my best bet

17:16 hiredman: unless there is some other method of calculating the arithmetic mean that doesn't need to know how many numbers there are

17:17 Lau_of_DK: hmm

17:20 Anyway, 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:22 askentasken: is reduce+ / count O(n) because of laziness?

17:23 Chousuke: reduce is always O(n). count (at least after reduce) should be O(1)

17:23 wwmorgan: laziness is irrelevant there as neither reduce nor count is lazy

17:23 askentasken: ah count is O(n)

17:24 what i mean was, if count ws O(n) and reduce O(n) would laziness keep it O(n) instead of O(n) * 2?

17:24 ok reduce is not lazy

17:25 Chousuke: count is O(1) for lists and vectors and maps. don't know how it behaves for arbitrary seqs

17:25 hiredman: the thing to remember is seqs != lists

17:25 wwmorgan: yeah reduce looks like it could be lazy at first, but when you think about it it's only returning one value

17:34 sohail: hey drewc I like clojets (for source code coming out of the closets!) :-)

17:35 drewc: sohail: too late, i just registered projecture.net :)

17:35 sohail: damn

17:35 duck1123: that was good too

17:36 clojets is a good name, but it sounds like a name for something else

17:36 wwmorgan: my new hot tub has clojets in it

17:36 duck1123: perhaps wigits made in clojure

17:37 pjb3: So this doesn't work anymore: http://en.wikibooks.org/wiki/Clojure_Programming#Invoking_Clojure_from_Java

17:37 sohail: fourleafclojure has a ring to it too

17:37 pjb3: Anyone know how to do that now?

17:40 duck1123: I'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:40 hiredman: dejure

17:41 "well you have to use it, it's the dejure build system"

17:41 danlei`: =)

17:41 hiredman: er

17:41 I guess it would be, "build system dejure"

17:41 duck1123: hiredman: that's good

17:43 hiredman: I am not sure, I hear it's kind of, you know, *french*

17:43 danlei`: dejure?

17:43 that would be latin

17:43 kotarak: de jour

17:44 danlei`: jus = law

17:44 wwmorgan: soup du jour

17:45 the soup of the law

17:45 * hiredman resists the urge to say "oh, it's foreign"

17:53 Chouser: pjb3: use just "ns" instead of "clojure/ns"

17:54 pjb3: the java part doesn't work

17:54 Chouser: Hm, I just built and ran it.

17:54 What error are you getting?

17:56 pjb3: nevermind, it was some problem with my IDE, works now

17:56 Chouser: great.

17:56 pjb3: thanks

17:58 hmm....cool: System.out.println(RT.var("clojure.core", "+").invoke(1, 2));

17:59 cooldude127: pjb3: is that doing "(println (+ 1 2))" from the java side?

18:00 pjb3: cooldude127: yeah, pretty much

18:00 hiredman: has any one made a nice jar that you click on and up pops a repl window?

18:00 pjb3: you get the "+" function and then invoke it

18:00 cooldude127: yup

18:01 pjb3: hiredman: 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:01 hiredman: I have one in some java terminal thing, but it doesn't do copy and paste

18:02 Chouser: pjb3: 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:02 pjb3: a non-repl clojure applet should be doable now with AOT, but I don't know that anybody's tried.

18:02 pjb3: Chouser: well if you if have a link, you could save me the trouble

18:03 I'm thinking we should have a REPL on clojure.org

18:03 so people could just try it out right there

18:03 rhickey: Chouser: actually not, as a repl needs to do code gen, and thus needs a classloader

18:03 Chouser: pjb3: I don't, and i've got to run. Google is your friend!

18:03 pjb3: rhickey: what do you think of that?

18:04 rhickey: clojure.org is just a spot on wikispaces, I have no hosting for Clojure

18:04 pjb3: ah, well, we could find some place to stick the .class/.jar file

18:05 rhickey: pjb3: that's easy, if it's an applet

18:05 pjb3: yeah, so I'm just trying to figure out how to make an applet that has a REPL

18:05 If I do, we'll find some place to host it

18:06 ole2: Hello, I've never been here bevor, just clicking at clojure.org at irc.

18:06 And it opened that window, wow

18:06 rhickey: ole2: welcome

18:06 ole2: :)

18:06 drewc: pjb3: 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:07 pjb3: drewc: cool, I'll let you know if I get it working

18:10 ole2: O.K. i've installed java, jre, jdk, whatever, and got finally some kind of repl. But is there an ide? Name-completion?

18:11 duck1123: personally, I would like to see a ajax interface to a remote repl

18:11 drewc: ole2: i recommend using SLIME personally.

18:11 wwmorgan: ole2: enclojure for netbeans is pretty good

18:11 hiredman: I think the three main editors people use are emacs, vim, netbeans

18:11 pjb3: ole2: http://enclojure.org/Completion.html

18:12 hiredman: I use vim myself with some thing that lets me send chunks of clojure to a repl

18:12 slime.vim? I dunno

18:13 duck1123: Gorilla?

18:13 ole2: thank you, i tried to install netbeans, but it takes several minute to startup, and the enclojure plugin did not work.

18:13 hiredman: duck1123: nah, I haven't used gorilla or chimp yet

18:13 ole2: I'm not a java guy, and i can not figure this out.

18:14 wwmorgan: ole2: what behavior did you get out of the enclojure plugin?

18:14 duck1123: I tried enclojure, was pretty nice, but I'm too much of an emacs guy now to use anything else

18:14 drewc: I use SLIME because it's what i know, and it's made for Lisp.

18:14 pjb3: I tried enclojure a while ago, couldn't get it to work

18:15 Guess I'll try again now

18:15 ole2: Well, I installed netbeans, all-package, jdk, takes several minutes to startup, and sayes some javamodules are missing.

18:15 Maybe i should ask at a java channel

18:15 But thanks for the help

18:16 O.K. You are all emacs guy's. So my next questions.

18:16 hiredman: <-- VIM

18:16 ole2: :)

18:17 hiredman: but yeah, everyone else

18:17 duck1123: I just wish emacs had a way to detect fn names

18:17 ole2: I have a working emacs/slime/sbcl/clisp blah installation. How do i get clojure to work with that

18:17 rhickey: ole2: there's also #enclojure for enclojure-specific qs

18:17 ole2: O.K. Thank you.

18:18 duck1123: ole2: did you try the code on the wiki?

18:18 there are instructions on how to set up multiple lisp implementations

18:24 ole2: duck1123: 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:24 cooldude127: ole2: you dissin emacs?

18:24 duck1123: clojure + swank is difficult to get right some times

18:24 you have to load things in the right order

18:24 cooldude127: idk i thought it was pretty easy to set up but i already had slime working

18:25 i was just adding clojure love

18:25 oh wait so was ole2

18:25 duck1123: I kept getting hit with the progn problem

18:26 cooldude127: what problem is that?

18:31 hagman appears to be having some issues

18:32 duck1123: you get the error that progn isn't a valid function

18:32 it happens when you don't load things in the right order

18:32 ole2: Thanks for your patients, I load slime but got the java expection "Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/Repl"

18:32 cooldude127: it appears that you don't have it setup to load the clojure jar right

18:32 ole2: I have no idea what that means

18:33 cooldude127: cuz it can't find clojure's stuff

18:34 duck1123: (setq swank-clojure-jar-path (concat clojure-path "clojure.jar"))

18:35 cooldude127: what's clojure-path? does it have the final / at the end

18:36 lisppaste8: duck1123 pasted "my .emacs pick and choose to your hearts content" at http://paste.lisp.org/display/70611

18:37 duck1123: admittedly not the best setup, but it works for me

18:37 cooldude127: i'll paste my clojure stuff as well

18:38 ole2: I tried to rearange all the stuff you say, but it still yields the same error

18:38 lisppaste8: cooldude127 pasted "my clojure.el file" at http://paste.lisp.org/display/70612

18:39 cooldude127: i use a script with it

18:39 i should probably do the fun task of updating clojure and swank-clojure

18:41 duck1123: I haven't gotten around to it because Compojure hasn't been updated yet, and that's the only thing I use atm

18:41 cooldude127: how is compojure?

18:41 i haven't checked it out yet

18:42 duck1123: pretty good. takes some getting used to, and there are things I wish were different, but it works

18:42 cooldude127: cool

18:43 luckily 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:43 * cooldude127 runs ant

18:44 duck1123: so has anyone written a BNF for Clojure yet?

18:44 I'm wondering if I need to learn it to scratch my itch

18:44 cooldude127: holy shit swank clojure changed since i last updated

18:45 duck1123: when did you last download?

18:45 cooldude127: that's a damn good question

18:46 not really sure

18:46 ole2: i did not get it, what am i doing wrong http://paste.lisp.org/display/70613.

18:46 It's my .emacs

18:46 cooldude127: somebody help me: swank-clojure uses autoloads, so what do i do to load the new changes without quitting emacs and killing irc

18:47 danlarkin: duck1123: 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:48 duck1123: cooldude127: M-: (require 'swank-clojure) ?

18:48 danlei: cooldude127: M-x load-file

18:49 duck1123: danlarkin: do you know where it's at?

18:50 danlarkin: duck1123: http://kotka.de/projects/clojure/parser.html

18:51 cooldude127: ole2: your jar-path needs to have the actual jar, not just the dir

18:51 danlei: that's what worked, require didn't actually reload it i think

18:54 ole2: cooldude127: 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:54 cooldude127: no problem. i didn't notice at first but it just caught my eye

18:56 clojure and swank-clojure update successful

18:56 slime is still old, from late october

18:56 not that old i guess

19:00 ole2: Thank 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:02 danlarkin: duck1123: if you improve upon his Parser library let me know, I want to use it for my json decoder

19:36 cooldude127: don't you just love it when emacs crashes and you have NO IDEA cuz os x didn't give you a clue?

19:38 * gnuvince_ whispers "vim" in cooldude127's ear

19:38 gnuvince_: ;)

19:38 wwmorgan: otoh, enclojure crashes with loud and cryptic error messages

19:39 an error in my user.clj manifested itself as a couldn't connect to socket exception

19:45 cooldude127: gnuvince_: i'm in no way against vim, it just doesn't fit for me

19:45 i actually want to like it

19:45 but i can't make it stick

19:45 gnuvince_: cooldude127: fair enough. Different people, different minds, different tastes, different editors :)

19:47 cooldude127: gnuvince_: i think the biggest thing is i use the colemak keyboard layout, and that really messes up vim's navigation and stuff

19:47 sohail: cooldude127, emacs never crashed for me except when I used erc

19:47 cooldude127: i think matlab was the problem here

19:47 matlab crashed too, and os x just didn't tell me that emacs went with it

19:51 Chousuke: I'm actually starting to like emacs

19:51 might be because I found vimpulse. which allows vim-style editing :P

19:51 cooldude127: lol

19:51 funny that the vim-style editing is what prevented me from doing vim

19:51 walters: wwmorgan: 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:52 of course local apps talking to each other over TCP sockets is terribly broken, unfortunately Java doesn't expose local domain sockets

19:52 wwmorgan: walters: that's exactly it

19:52 Chousuke: Well I really don't like the 283490893 key combinations emacs has. I can remember at most a few of them

19:52 gnuvince_: I needed to stop using Emacs after two years because the pain it caused me were just getting unbearable.

19:53 duck1123: there's alway's M-x

19:53 cooldude127: gnuvince_: even remapping caps lock to control? does that help?

19:53 Chousuke: i don't know most of them

19:53 just the ones i constantly use

19:53 Chousuke: duck1123: I like how in vim you can "combine" commands

19:54 duck1123: We're learning vi in my linux fundamentals class

19:54 I hate it

19:54 gnuvince_: cooldude127: didn't help.

19:54 cooldude127: so I went back to vim

19:54 (which I had left for Emacs)

19:55 cooldude127: oh

19:55 Chousuke: duck1123: like, d for delete, % to skip to the matching paren, d% for delete until matching pare

19:55 stuff like that

19:55 cooldude127: yeah i did like that

19:55 it wasn't enough for me

19:55 gnuvince_: it all depends on how you work (though I guess the editor you have affects how you think you want to work)

19:56 duck1123: that was kinda cool. most of the caommands in emacs have C-u arguments that do something similar. I never use them

19:56 gnuvince_: I use the type of commands Chousuke mentioned a hundred times a day.

19:56 Chousuke: If 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:56 cooldude127: yeah

19:57 danlei: emacs is the better os =)

19:57 cooldude127: plus i can't wrap my head around vimscript

19:57 emacs-lisp is flawed, but makes more sense to me

19:57 duck1123: there's viper

19:57 cooldude127: what's viper?

19:57 danlei: vi emulation-mode

19:57 Chousuke: duck1123: yeah, that's what I'm using :)

19:57 duck1123: gives all the vi bindings in emacs

19:58 Chousuke: my emacs setup is really something

19:58 gnuvince_: Yeah, vimscript sucks ass.

19:58 cooldude127: i've done a lot of work on making my emacs setup easily tweakable

19:58 Chousuke: it's one part vi, one part emacs, and one part mac-app

19:58 gnuvince_: Lot of people wish Bram would just leave it only for configuration and switch to something more "proper" like Python for actual plugins.

19:59 cooldude127: everything i add goes in a new file to be loaded from .emacs

19:59 duck1123: my init.el file has gotten way too large

19:59 Chousuke: it'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:59 danlei: duck1123: i once lost mine

20:00 lisppaste8: cooldude127 pasted "my .emacs" at http://paste.lisp.org/display/70620

20:00 cooldude127: mines on github actually

20:00 duck1123: I'm sitting at 730 lines

20:00 not counting customized vars or keybindings

20:01 cooldude127: i keep all my dotfiles in a git repo

20:01 duck1123: I'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:01 cooldude127: lol

20:01 Chousuke: duck1123: Keep at it, soon you'll have a working text editor implementation!

20:02 cooldude127: i 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:04 brb, trying out my updated emacs-cvs

20:06 ok well the new emacs did not work

20:06 and i don't feel like figuring out why

20:06 duck1123: cooldude127: do you actually use CVS or the git mirror?

20:07 cooldude127: cvs

20:07 it couldn't load cuz of some DOC file it couldn't find

20:08 duck1123: but it built before?

20:08 cooldude127: yeah

20:09 i'm running an older cvs one right now to chat

20:10 duck1123: I'm doing a `mr update` to see what's changed since this morning

20:11 cooldude127: Cannot open doc string file "/Users/mattmoriarity/usr/src/emacs/nextstep/Emacs.app/Contents/Resources/etc/DOC-"

20:11 is the error

20:26 duck1123: took forever, but built with no errors. sorry

20:27 cooldude127: mine didn't take much time

20:27 maybe i should clean first

20:30 ok the build was still fast

20:30 duck1123: what platform are you on?

20:32 SWEET!

20:32 yeah cleaning helped

20:32 brb

20:34 larrytheliquid: is there a version of rest that returns an empty list instead of nil when empty?

20:35 jtoy: larrytheliquid: i dont think so

20:35 Drakeson: does (a b c d e f g) -> ((a b c) (d e f) (g)) have a name?

20:35 cooldude127: and we're back with an up-to-date emacs :)

20:35 jtoy: larrytheliquid: but im sure you can do a macro or whatever

20:35 larrytheliquid: jtoy: ya np

20:35 danlarkin: Drakeson: partition

20:36 cooldude127: Drakeson: that's partition i think

20:36 damnit danlarkin

20:36 Drakeson: thanks :)

20:36 danlarkin: in like flint

21:26 rzezeski: just out of curiosity...how long has everyone here been using Clojure, and what do you consider your "strongest" language

21:28 Chouser: 9 months. Clojure. :-)

21:28 pjb3: rzezeski: I've been using clojure off and on for almost a year

21:28 Ruby is probably my strongest language, Java probably a close secodn

21:29 rzezeski: chouser: You really consider Clojure your strongest language? What would you consider your strongest before Clojure?

21:29 cooldude127: i'm with pjb as far as ruby and java

21:29 i'm pretty good with java, but i can't stand using it

21:30 rzezeski: pjb3, how much experience w/ Ruby?

21:30 cooldude127: ruby is an excellent mix between a language i'm good at and a language i actually like to use

21:30 pjb3: cooldude127: yeah, me too

21:30 rzezeski: Couple of years now

21:31 cooldude127: yeah same here

21:31 i can base it off the rails version of the time

21:31 cuz that's what got me started

21:31 0.8.0

21:32 Chouser: rzezeski: 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:33 rzezeski: Cool, 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:34 pjb3: rzezeski: yeah, Clojure is awesome

21:34 rzezeski: Yea 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:35 Rich really knows how to give a good presentation

21:35 cooldude127: i liked both lisp and haskell, and clojure seems like a good mix

21:35 rzezeski: you bet he does

21:35 gnuvince_: Clojure has less bling than Haskell, but it's extremely enjoyable.

21:35 cooldude127: i love haskell until i get into more complicated programs and i'm just lost

21:36 there's a fine line in haskell between unbelievably clean and disgusting

21:36 gnuvince_: I agree

21:37 cooldude127: my lisp problem is a lack of libraries

21:37 which clojure solves

21:37 Chouser: that's interesting. I've not given haskell the time it deserves.

21:37 rzezeski: I'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:37 cooldude127: exactly

21:38 gnuvince_: rzezeski: and all the Java libs :)

21:38 rzezeski: that too!

21:38 gnuvince_: I'm no fan of Java, but I definitely enjoy using a one year old language that has more libs than Perl :)

21:38 cooldude127: yeah java is a library whore

21:38 it has everything

21:38 ruby's about the same way, but not quite as much

21:39 rzezeski: What'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:39 Clojure*

21:39 pjb3: I actually miss some of the Ruby libraries in Java

21:39 gnuvince_: rzezeski: ditto

21:39 cooldude127: i love ruby libraries, cuz in general they tend to be really pleasant

21:40 pjb3: Is there a good HTML parser for Java like Hpricot or Nokogiri?

21:40 cooldude127: Hpricot is a GREAT example of what i'm talking about

21:40 albino: time for people to start porting

21:40 pjb3: Especially one that has a CSS engine

21:40 gnuvince_: 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:40 cooldude127: i had to work with java last year, and i really wish i had clojure back then as mature as it is now

21:40 pjb3: cooldude127: 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:41 cooldude127: it would have helped so much

21:41 pjb3: you and me both

21:41 gnuvince_: 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:41 pjb3: http://htmlparser.sf.net

21:41 pjb3: (org.htmlparser.Parser. "http://www.xkcd.com")

21:41 cooldude127: if i had the spare time i would consider porting hpricot

21:41 _why would be cool :)

21:42 gnuvince_: :)

21:42 I was searching for a project in my free time

21:42 That could be an interesting one.

21:42 cooldude127: oh yay

21:43 pjb3: gnuvince_: once you've got a parser, how do you get parts of the document?

21:43 extractAllNodesThatMatch(NodeFilter filter)

21:43 gnuvince_: pjb3: there are some filter classes and a visitor method

21:43 Yes

21:43 pjb3: this is the kind of crap that I hate about Java libaries

21:43 cooldude127: ahh i knowww

21:43 gnuvince_: You and me both :)

21:44 pjb3: *but*, it does provide Clojure with a solution, even if it's not the cleanest one

21:44 cooldude127: true

21:44 we get gui's and stuff like that basically free

21:44 Chouser: I like TagSoup + zip-filter

21:44 pjb3: Yeah, we can wrap that crap

21:45 Looks like it has CssSelectorNodeFilter that does CSS2

21:45 cooldude127: woooo

21:45 pjb3: so you could use that in clojure to get something like jQuery

21:45 cooldude127: oh snap !

21:46 pjb3: ($ "div.fancy" show)

21:46 Chouser: but css to too limited for my taste

21:46 gnuvince_: I prefer things like BeautifulSoup

21:46 Allow for more powerful searching

21:46 pjb3: $ would be an fn that takes a selector and N number of functions to apply to the matched elements

21:47 cooldude127: wtf emacs?

21:47 gnuvince_: soup.findAll('img', src=re.compile(r'png$'))

21:47 cooldude127: just up and crashed

21:47 Chouser: gnuvince_: more powerful than css, or than zip-filter?

21:48 rzezeski: Is the TagSoup for Java derived from Neil Mitchell's TagSoup Haskell library?

21:48 gnuvince_: rzezeski: no, they're completely different

21:48 rzezeski: oh gotcha

21:49 pjb3: gnuvince_: with CSS3 "img[src$=.png]"

21:49 gnuvince_: Chouser: afaik, you can't search by regexes with CSS selectors.

21:49 pjb3: did they add regexes to CSS3?

21:49 Chouser: gnuvince_: ah, right. yeah, css is too limited.

21:49 gnuvince_: or is it just "ends-with"

21:49 pjb3: no, just starts with, ends with, contains

21:50 gnuvince_: ok

21:50 pjb3: which is not bad

21:50 gnuvince_: Sure

21:50 pjb3: and 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:50 gnuvince_: 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:53 pjb3: (filter #(re-matches #"whatever" %) ($ "img[src$='.png']"))

21:54 gnuvince_: (find-all "img" {:src #"png$"})

21:57 pjb3: so how does this AOT thing work?

21:57 do I still use gen-and-save-class if I want to extend a Java class?

21:58 Chouser: pjb3: for a few more days, yes.

22:04 pjb3: Chouser: So you can't use AOT to extend a Java class yet?

22:04 Chouser: pjb3: right. you can create a class with a main function, but that's it so far.

22:05 pjb3: Ok, so I was going to try to write an Applet with Clojure, but I guess that will have to wait

22:06 but I could just write a Java class to implement the applet that just loads up a Clojure script, right?

22:06 Chouser: I believe rhickey's working on it actively -- making gen-class-like options available for the ns macro.

22:07 rhickey: Chouser: coming along - it's been a bear

22:08 Chouser: rhickey: so is it more or less fun to have an impatient audience (compare to two years of silent solo work)

22:10 rhickey: I'm thrilled with the ever growing audience, and having you guys to run interference :)

22:10 Chouser: heh

22:15 hiredman: man, I love "," as whitespace

22:18 lisppaste8: url?

22:18 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

22:50 sohail: Chouser, more tagged type? :-)

22:55 Chouser: nope, pprint tonight

23:26 cooldude127: man this place is dead

23:27 Chouser: we're working. shhhh...

23:27 ;-)

23:29 cooldude127: hehe

Logging service provided by n01se.net