#clojure log - Aug 16 2009

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

0:07 lowlycoder: what's the comment char in clojure?

0:07 Anniepoo: ; end of line

0:07 andyfingerhut: semicolon

0:08 Anniepoo: you can ifdef out a form by preceeding it with #_

0:26 lowlycoder: so structs are just maps?

0:26 rlb: lowlycoder: yes, though optimized for the named elements.

0:26 andyfingerhut: with some space efficiency enhancements, yes

0:29 lowlycoder: interesting, thanks

0:29 andyfingerhut: kinda cool that you can still add other keys to them if you really want to

0:31 lowlycoder: clojure does not allow defining of reader macros

0:32 how do I violate this condigion?

0:32 *condition*

0:32 technomancy: next time someone complains about Clojure stacktraces point them to JRuby... it gets the line number significantly wrong frequently

0:32 lowlycoder: patch LispReader.java and recompile

0:33 Anniepoo: lowlycoder - it means you can't decide that you don't like #^{} for metadata and want that to be something else

0:39 lowlycoder: technomancy: nice; thanks

0:47 so I know that Java code is not tail recursive; but is even clojure code not compiled to be tail recursive? (it seems very easy to implement via trampolines)

0:48 Anniepoo: it is for the simple case

0:48 tomoj: it's only tail recursive if you make it tail recursive

0:49 well.. any tail recursive function is tail recursive

0:49 but clojure will not automatically optimize

0:49 you have to be explicit if you want optimization

0:55 lowlycoder: so I can't write functions like:

0:55 (defn (foo a b) (if (equal? a 0) b) (foo (- a 1) (+ b 1))) and expect (foo 1000000000 100000000) to only consume a reasonable constant amount of memory?

0:55 does "optimize it myself" mean convert it to a do loop?

0:56 replaca: lowlycoder: just replace the second foo with recur and you'll be good

0:58 tomoj: that is not clojure code anyway..

0:58 lowlycoder: hey; i'm converting over slowly

0:59 tomoj: from what?

0:59 doesn't look like any lisp I've used either :)

0:59 replaca: ,(let [f (fn [a b] (if (= a 0) b (recur (dec a) (inc b)))) ] (f 10000000 10000000))

0:59 tomoj: the bot isn't here :(

0:59 replaca: :(

0:59 well, running it is an exercise for the reader

1:00 tomoj: works fine

1:00 lowlycoder: why is implementing trampolines so hard?

1:00 replaca: i knew that :-)

1:00 tomoj: we have trampolines

1:00 clojure.core/trampoline

1:01 they aren't necessary for simple tail recursion like the above

1:01 lowlycoder: well, the above is a leaky abstraction

1:01 it makes me have to think to use recur

1:01 tomoj: yup, sorry

1:01 it's the JVM's fault

1:01 replaca: lowlycoder: yeah, it's supposed to be. Rich doesn't want to hack in a solution when it should be solved at the JVM level

1:02 tomoj: maybe the JVM will have TCO someday

1:02 replaca: that's his assumption, I think. It is under discussion, but not at the top of the list

1:03 lowlycoder: great; so we don't have a solution until the JVm changes, even thouch in theory we could?

1:03 replaca: that's probably true

1:03 unless Rich changes his mind

1:03 tomoj: weird

1:04 I've heard multiple times that it's flat out impossible

1:04 replaca: in real life, I haven't noticed it to be much of a pain point

1:04 tomoj: without the qualification "unless we do ___, which we don't want to"

1:04 replaca: well, for the recur case, Rich could do the optimization himself in the compiler

1:04 but the trampoline case is a bunch harder

1:05 Rich has tried to compile to very clean code in general in order to best leverage the JVM's strengths

2:08 Anniepoo: architectural question

2:09 I'm going to implement a database of resources

2:09 essentially takes a string and returns a ID for a resource that's expensive to make

2:11 so I'll keep a memory resident copy of a file (durability isn't important here)

2:11 and modify and write

2:12 is it better to make the file format be a def and just load it?

2:40 arbscht: so close yet so far. got clojure-clr to sort-of-kind-of build on mono, but not yet load :(

2:45 tatofoo: how can I call Graphics2D.drawPolyline(int[], int[], int) from within clojure? I've tried (doto g (.drawPolyline [0 10 10] [0 10 40] 3)) but it tells me PersistentVector cannot be cast to [I

2:48 arbscht: ,(int-array [0 10 10])

2:49 tatofoo: arbscht: :O thanks, sorry for my ignorance but what's the , for?

2:50 arbscht: that usually triggers clojurebot to evaluate the expression

2:50 lowlycoder: what's clojure's obsession with [] ? why does let even use [] to separate the vars from the body?

2:50 tatofoo: hehe, ah ok, than you I'll try that

2:50 arbscht: however clojurebot is missing in action today :/

2:52 lowlycoder: it's a feature of clojure's homoiconicity

2:53 lowlycoder: what does it mena?

2:53 the word's too big for me

2:54 Anniepoo: clojure code and clojure data are one and the same

2:54 arbscht: clojure's code is represented by clojure data structures

2:54 more info at http://en.wikipedia.org/wiki/Homoiconicity

2:55 lowlycoder: this doesn't seem to explain why let is based on vectors rather than lists

2:55 performane reasons?

2:55 so for anyting whose length we know at compile time, use vectors instead of lists?

2:56 Anniepoo: lowly, vectors aren't assumed to be functions

2:56 arbscht: oh, partly for aesthetic reasons (too many parens), but also to differentiate from operator calls

2:57 Anniepoo: you'll come to appreciate having both structures

2:57 lowlycoder: it's also weird that (let [[x y] [1 2 3]] ... ) just drops the 3

2:58 it seems like it should throw an error of some kind

3:01 tomoj: I find it very useful that it doesn't throw an error

3:03 lowlycoder: Clojure=> (import '(package Class+))

3:03 #<CompilerException java.lang.ClassNotFoundException: package.Class+ (REPL:1)>

3:03 why doesn't this work?

3:04 (import '(java.io InputStream File))

3:04 why doesn't that use [] instead of () ?

3:04 especailly since it'l reduce the need for '

3:05 arbscht: (import [java.io InputStream File]) works

3:07 lowlycoder: (round 1.2) --> goes to 1, not 2 as mentioned in the book

3:08 arbscht: stu halloway's book?

3:08 lowlycoder: ya

3:08 tomoj: lowlycoder: you're not supposed to type the code in the grey boxes

3:08 I suppose you've realized this

3:08 * arbscht is not familiar with its contents

3:08 tomoj: it's just a typo

3:12 tatofoo: :O I was wondering about that '( in the import aswell, didn't know you could use [] :D

3:16 lowlycoder: so do is just == begin?

3:17 arbscht: what's begin?

3:17 tomoj: you mean begin from ruby?

3:17 lowlycoder: begin from scheme

3:18 tomoj: oh.. dunno

3:18 progn from CL

3:22 lowlycoder: hmm, so recur does tail recursion on a singl efunction

3:22 can i have a set of functions that recur on each other?

3:22 i.e. the last expr in f is (g ...), and the last expr in g is (f ...)

3:27 tomoj: lowlycoder: that's in the book

3:27 lowlycoder: haven't gotten to there yet

3:27 can you tell me?

3:27 tomoj: 5.4

3:27 there are a few different ways to solve that problem

3:28 you're probably looking for trampoline

3:30 but laziness or solving the problem another way can be prettier

3:43 lowlycoder: how does def and defn differ?

3:43 I'm confused on when to use the two

3:46 arbscht: defn is defined in terms of def. use defn when you intend to define a function

3:46 lowlycoder: why not juse use def all the time?

3:50 arbscht: I guess you could if you wanted to

3:50 mudphone: convenience

3:50 arbscht: defn has the advantage of being nicer to read, with an easy way to add docstrings

3:55 lowlycoder: (defn indexed [coll] (map vector (iterate inc 0) coll))

3:55 (defn index-filter [pred coll] (when pred (for [[idx elt] (indexed coll) :when (pred elt)] idx)))

3:55 (index-filter #{\a \b} "abcdbb")

3:55 no way, is the ${} ... using advantage of the fact that sets are functions of it's members?

4:21 tomoj: yep

4:21 cool, huh? :)

4:21 lowlycoder: a little too magical for my liking

4:22 i think it's kind of stupid to not have a standard library function of "convert set into a function"; instead of binding this directly to the syntax, which I can't modify without breakig clojure

4:22 tomoj: there is no "convert a set into a function" in the syntax

4:22 sets ARE functions

4:24 #{} is just reader syntax for sets

4:27 if you want to be more verbose for some strange reason you can use (set '(\a \b))

4:28 ..and if you don't like sets as functions you can go ahead and use (contains? (set '(\a \b)) \a)

4:29 personally I think (#{\a \b} \a) is a lot cooler :D

4:29 lowlycoder: i don't like verbosity

4:29 i just don't like things that are hardcoded for me

4:29 tomoj: you don't have to use the set reader macro if you don't want to

4:30 lowlycoder: i think reader macros are cool; and the syntax introdued is pretty elegant

4:30 i'm just annoyed that I can't modify it to my future needs :-D

4:30 tomoj: user reader macros cause problems that rich decided were not worth the trouble

4:33 lowlycoder: does clojure require the use of capital letters at all?

4:33 or are all names separated by - by default?

4:34 tomoj: names are separated by whatever you separate them with.. I don't understand the question

4:34 arbscht: names in the clojure api do not. names imported from java might

4:34 lowlycoder: langauges like c/java tend to use things like CamelCase

4:34 I was just curious what clojure tends to use

4:34 tomoj: convention is lisp-case

6:34 ZabaQ: I know Common Lisp fairly well, but I have no clue about Java. How much pain am I letting myself in for?

6:36 Chousuke: Hmm.

6:36 arbscht: none, I should hope. I came to Clojure from CL and that was painless.

6:36 Chousuke: ZabaQ: You'll have to learn to read javadocs at least :)

6:36 because while you won't have to write java, it's still very useful to know the java libraries.

6:38 though clojure.contrib does contain wrappers for a lot of the basic functionality that clojure.core leaves to java

6:42 ZabaQ: Chousuke: Hmm. I haven't looked at clojure-contrb yet. Perhaps I should.

6:42 Chousuke: Yeah. Pretty much everyone uses it anyway.

6:43 and yet there is no proper release of it :P

6:43 so you'll need to git it :)

6:47 ZabaQ: I'm going to need ant

6:49 Chousuke: unfortunately :P

6:50 ZabaQ: I hate ant with a passion. Mostly because I've been forced to use it on a huge C++ project, when it wasn't really in it's element.

6:50 I assume it's much happier in Java-land.

6:51 Chousuke: well, it's still a programming language with XML syntax

6:51 and not in a good way like xslt

6:52 arbscht: better ant than visual studio solution files...

6:52 Chousuke: but fortunately, most of my use of ant just involves calling the targets :P

6:52 arbscht: not that you have to do much more than "ant jar" or the like

6:52 right

6:58 ZabaQ: ant complained about not being able to find tools.jar. Is that bad?

6:59 Chousuke: hm

6:59 you're probably missing some dependency?

7:07 ZabaQ: I wan't using the right JRE. There's an anicent one lurking on this machine

7:16 clojure.contrib.monads!?

7:17 hmm. there is a lot of stuff in there.

7:17 Chousuke: yeah :)

7:18 ZabaQ: BUILD SUCCESSFUl. Wahey. I think I need to read docs for a bit..

7:18 Chousuke: which version of clojure are you using?

7:18 ZabaQ: git

7:18 head

7:18 Chousuke: 'k. then contrib will work fine too

7:19 contrib master only works with clojure master; there's a 1.0-compatible branch too though.

7:19 ZabaQ: right

7:20 Chousuke: also see http://java.ociweb.com/mark/clojure/

7:24 ZabaQ: javadocs are best read in an ordinary browser, I take it?

7:24 Chousuke: that's what I do.

7:24 and Clojure docs from slime :P

7:25 (well, function docs anyway)

7:26 ZabaQ: ah, I've only set up clojre to run with run-lisp. Not trying to make it work with slime as this is a windows box and my slime setup is bits of duct tape and string.

7:26 (metaphorically).

7:26 Chousuke: heh.

7:27 ZabaQ: I think slime has a mode that gives you slimey functionality in an *inferior-lisp* buffer: I'll try that.

8:05 It's a Lisp-1. Oh dear.

8:07 Chousuke: I haven't yet figured out how that's supposed to be a problem :)

8:07 * eevar_ thinks it's an advantage

8:11 Chousuke: I always hear stuff about how lisp-1's have hygiene problems and whatnot but I honestly don't know what they're talking about.

8:11 eevar_: and having to use "funcall" blows chunks imo

8:16 osaunders: I wanted to have a value called range but couldn't.

8:16 Then again maybe that would have been a bad name.

8:17 ... in a Lisp-2

8:17 Chousuke: well, you can have the range value but it'll shadow the function def :P

8:18 that's one think I'll give to lisp-2 :)

8:18 osaunders: ,(let [range (range 10)] (print range))

8:18 Chousuke: but not worth funcall IMO :P

8:18 osaunders: Dude, where's clojurebot?

8:18 Chousuke: no idea :/

8:19 hiredman is gone too so hmm.

8:22 osaunders: Is hiredman related to clojurebot?

8:22 Chousuke: he made it. :P

8:22 osaunders: Ah.

8:23 Father then. :-)

8:24 Chousuke: Clojurebot actually started as a gist.

8:24 but then I wanted to hack on it a bit and cloned the gist and put it in a proper github repo :P

8:24 that's why the early history doesn't have very interesting commit messages.

8:26 (and why github says hiredman's repo is a fork of mine)

8:26 osaunders: You credit stealer you.

8:27 Chousuke: I haven't touched it in half a year, though

8:30 the beginning: http://github.com/hiredman/clojurebot/blob/2381e7989977b8999aa0f863ef0a50415bb6e5fc/clojurebot.clj

8:34 ZabaQ: Lisp-1 isn't a big deal, you have to be more careful about names, mainly.

8:34 Chousuke: in Clojure at worst you end up shadowing them locally

8:35 unless you do trickery in a macro to force a capturing expansion.

8:39 Syntax-quote is the best feature of clojure's macro system. it's pretty much impossible to accidentally shadow names in the expansion environment, but it's easy enough if you want it.

8:40 though doing it makes your macro look ugly, which is probably just a good thing

8:44 osaunders: Brainfart is Windows 7 out?

8:44 Chousuke: no.

8:44 arbscht: progress... clojure-clr now loads on mono, but dies anyway :)

8:44 osaunders: OK. Thanks for clearing that up.

8:45 Chousuke: but apparently there's an RTM build already

8:45 osaunders: Read The Manual build?

8:45 Chousuke: Release to manufacturing or something? the gold master :P

8:46 ZabaQ: It might actually tempt me to upgrade from Win2k

8:46 Chousuke: Win2k :|

8:47 osaunders: Wow I clicked on 90% of all the links on Hacker News today.

8:47 Normally it's about 40%

8:55 ZabaQ: I don't suppose there's anything like (describe ) in CL?

8:56 danlei: (doc ...)

8:57 actually more like documentation, but closest

8:58 arbscht: (meta ...) covers some of the difference too

9:01 cemerick: well, (meta #'...), anyway :-)

9:04 danlei: (meta #'symbol) pretty much feels like (symbol-plist 'symbol), but modern CLs usually don't put such information in plists anymore.

9:09 cemerick: good thing clojure isn't a modern CL ;-)

9:15 * Neronus wonders if clojure could work as a scripting language

10:55 syamajala: i'm trying to figure out swank

10:55 user=> java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)

11:00 danlei: (add-classpath "file:///path/to/swank-clojure/")

11:00 (require 'swank.swank)

11:01 (swank.swank/start-server "/path/to/tmpfile/")

11:01 (swank.swank/start-server "/path/to/tmpfile.tmp")

11:03 (add-classpath is considered bad style, but it's ok for figuring things out)

11:19 syamajala: danlei: that seems to work, or at least i can do slime-connect from emacs that way

11:19 danlei: ok

11:19 syamajala: ideally i would like to just be able to do M-x slime-clojure and be presented with a repl

11:20 and i have stuff setup that way right now in my .emacs its just that clojure can't find the swank stuff

11:20 danlei: you could also add the classpath on the command line, e.g: java -server -cp "/path/to/clojure.jar;/path/to/swank-clojure/" clojure.lang.repl

11:20 syamajala: and i know no nothing of java and all this classpath stuff. i'm coming from lisp...

11:21 danlei: in emacs, you can set swank-clojure-extra-classpaths

11:22 - here's what I have for cygwin

11:22 (when (eq system-type 'cygwin)

11:22 (setq swank-clojure-jar-path

11:22 "e:/cygwin/home/danlei/build/clojure/trunk/clojure.jar"

11:22 swank-clojure-extra-classpaths

11:22 '("e:/cygwin/home/danlei/coding/lisp/clojure/")))


11:22 to give you an idea

11:22 syamajala: i just used your java -server -cp line

11:23 in a script

11:23 danlei: (actually, what I once HAD in my .eamacs :)

11:23 ok

11:23 syamajala: that seems to work

11:23 danlei: glad to hear it works

11:28 syamajala: ok now my setup is exactly the way i want it

11:52 markaddleman: hey folks... has anyone gotten clojure to work under osgi? i'd like to write an osgi activator that loads *.clj resources from a bundle

12:09 Chouser: there have been some attempts, and rich has done some work to make Clojure more amenable to osgi, but I'm not sure of the status of any of that.

12:11 markaddleman: thanks.

12:15 osaunders: You know what would help a lot.

12:15 A related functions list for each function.

12:16 Chouser: yeah.

12:16 I made a weak attempt at that on the clojure.org site

12:16 osaunders: Also each function could probably do with it's own page.

12:16 Chouser: listing groups of functions for each data structure.

12:16 osaunders: Where can I find that?

12:17 Chouser: http://clojure.org/data_structures#toc16 for example

12:18 osaunders: Hm, it's a good start.

12:18 Chouser: but yes, a page per function, with several examples, related function links, discussion of performance for various data structures, etc. would be nice.

12:18 though creating it is only a fraction of the work -- then it has to be maintained. :-/

12:18 osaunders: Exactly. I couldn't put it better myself.

12:19 Well, it's a wiki. With enough people these things are easily maintained.

12:19 Small corrections here and there by several people.

12:19 syamajala: is there a hyperspec-lookup type thing?

12:19 osaunders: (doc symbol)

12:19 Is that what you mean?

12:20 syamajala: yeah i guess thats good enough for now

12:20 osaunders: I mostly don't believe in good enough.

12:22 Is there a nice way to convert ([x y] [x y]) into [x y x y]?

12:23 Chouser: Do you think I should post on the list with idea to improve the documentation?

12:23 *ideas

12:27 Oh concat!

12:28 dreish: osaunders: What good would wishing out loud do? If you want it, why not actually do something about it?

12:29 osaunders: There are many reasons not to act.

13:48 gcv: is there any way to make a thread "inherit" a dynamic binding from wherever it's created?

13:48 e.g., I'd like (binding [*x* 3] (.start (Thread. (fn [] (println *x*))))) to print 3

13:49 (assuming something like (def *x* 5) on the outside)

13:49 Chousuke: do (let [*x* *x*] (Thread. #(println *x*)))

13:50 that captures the dynamic binding as a local one so the thread can access it.

13:53 gcv: Chousuke: that's pretty good, but doesn't work if the thread gets created outside the lexical scope of the let form

13:54 it doesn't allow access to *x* outside the lexical scope in general, which is what I'm trying to accomplish

13:54 Chousuke: but that way lies concurrency trouble.

13:55 gcv: sure, but *x* might be an immutable value, in which case it would be fine

13:55 there's concurrency trouble anyway with (def *x* ...), except there's just the one value of it available, the global one. I'm trying to have the same situation, but with a local value of *x* for a particular path of execution.

13:56 Chousuke: values bound with binding can be changed thread-locally.

13:57 I suppose you might be able to do (let [foo *x*] (Thread. (fn [] (binding [*x* foo] (somestuff)))))

13:57 gcv: not if I don't have control over the thread invocation

13:58 Chousuke: then there's no way. :P

13:58 you need a ref. :/

13:59 gcv: if I want my code to start two embedded different Jetty instances, each running self-contained with different values of *x*, where *x* is a "global" variable for each one

13:59 hmmm, how would a ref help?

13:59 Chousuke: hm, I guess it wouldn't in that case.

14:01 I can't think of a way to do what you want.

14:02 is it possible for you to run an "init" function in the new thread, when it's created?

14:03 if you can, you could perhaps use push-thread-bindings to set up the bindings for the thread.

14:03 or hm, that's not in master yet I guess ;/

14:04 (Var/pushThreadBindings is though)

14:04 gcv: push-thread-bindings? that sounds promising

14:04 where should I look for that code?

14:04 Chousuke: it's what binding does undercover

14:04 it just also does a popThreadBindings :)

14:05 take a look at the binding macro. it should be easy enough to understand.

14:05 gcv: yup, got it. thanks

14:06 so basically, if I can figure out how to hook into the creation of every new thread and execute pushThreadBindings with the parent thread's bindings, I should be good to go

14:06 sounds like cake :)

14:08 Chousuke: there's also getThreadBindings

14:08 for getting the parent thread bindings :P

14:11 gcv: Chousuke: nice. thank you

14:23 d2dchat: does anyone know why: (take 10 (iterate rand-int 100)) seems to return lots of 0's and why the #'s seem to get lower going right?

14:26 gcv: d2dchat: wow. wild. maybe something there screws up pseudorandom numbers?

14:27 dreish: (iterate rand-int 100) passes the prev rand-int return val as the argument to the next call to rand-int.

14:27 d2dchat: ahhh

14:27 that make sense

14:27 haha

14:27 dreish: There might be a better way to put it, but:

14:28 ,(take 10 (repeatedly #(rand-int 100)))

14:28 Oh, cjbot is offline.

14:28 d2dchat: ahh works :)

14:31 tomoj: that's a cool problem though

14:31 how many numbers on average do you get before you wind up at zero

14:34 dreish: Around 5.18 or 5.19.

14:35 tomoj: yeah, but.. I wonder how you'd actually figure it out

14:35 heading to #math

15:04 aha

15:04 the answer is 14466636279520351160221518043104131447711/2788815009188499086581352357412492142272

15:05 dreish: Why?

15:05 tomoj: someone in #math gave an elegant argument for why the answer is 1+1/2+1/3+...1/n

15:06 ie the harmonic numbers

15:06 dreish: Interesting.

15:11 konr: have you guys used qt with clojure?

15:15 d2dchat: Is there a way to rescue exceptions in clojure?

15:16 konr: that sounds interesting :)

15:17 konr: I have not but, I think there is a Java binding to Qt

15:17 I would start there

15:25 tomoj: d2dchat: you mean java exceptions?

15:25 d2dchat: Yes

15:25 tomoj: d2dchat: http://clojure.org/special_forms#try

15:25 d2dchat: My program is evaluating division by zero occasionally and I just want it to ignore it silently and move on

15:26 tomoj: ah! Thanks!

15:34 osaunders: d2dchat: Testing the divisor with zero? beforehand may be cleaner and more performant.

15:35 d2dchat: osaunders: Would be, but this framework is too generic.. :(

15:35 Chousuke: osaunders: unless you're doing millions of divisions and only a few of them will be zero

15:35 osaunders: d2dchat: OK.

15:35 Chousuke: in those cases, catching the exception may actually be faster

15:36 osaunders: Chousuke: True.

15:36 d2dchat: Well, all kinds of exceptions *could* happen

15:36 if one happens, I just want it to do nothing

15:37 and move on

15:37 Genetic Programming :)

15:37 osaunders: The concern with that is there may be exceptions that you don't want to ignore that you'll catch.

15:37 d2dchat: Yea, I will have to build that in somehow.. good point :)

15:41 tomoj: are you evolving sexps?

15:43 d2dchat: tomoj: yes

15:43 tomoj: awesome

15:44 osaunders: What's that?

15:44 d2dchat: I'm new to clojure

15:44 and it took me a week to do

15:44 (on and off after work)

15:44 tomoj: clojure seems intuitively harder for that than other things, but I've never tried anything like it

15:44 d2dchat: Which is pretty incredible

15:45 tomoj: I mean it seems that a randomly built clojure sexp is less likely to do anything meaningful than a randomly built program in some other language

15:45 d2dchat: Ya, I had to play with it a bit

15:45 Why's that?

15:45 tomoj: but like I said I've never done any genetic programming

15:45 well, lazy seqs and first class functions and all

15:46 d2dchat: right

15:46 tomoj: seems like it would be difficult to have something write e.g. combinations of map/filter/reduce using anonymous functions that even compiled successfully

15:46 or did anything meaningful if they did compile

15:46 d2dchat: I'm going to do some tests on lists

15:46 I just finished arithmetic so

15:47 * osaunders just realised you said genetic not generic

15:47 d2dchat: Which worked out pretty well :)

15:47 tomoj: cool

15:47 I'm interested in writing a neuroevolution library in clojure

15:48 d2dchat: I found the answer to life, the universe and everything using my framework just now

15:48 :)

15:48 tomoj: haha

15:48 osaunders: 42?

15:49 d2dchat: (* (- 2 4 2) (/ 7 2 2) (- 7 9 4))

15:49 (/ (* 6 9 3) (/ 2 7 8) (* 6 3 6))

15:50 oh clojurebot

15:50 where art thou?

15:50 osaunders: We're not sure.

15:51 He belongs to hiredman though and he's not around either.

15:59 bryanjswift: anyone familiar with setting up vimclojure. I'm pretty sure the bit I'm missing is getting my .clj files on the classpath of the nailgun server I'm starting but I'm a little spaced as to how to do that nicely.

16:45 mebaran151: what's the difference between doto and ->?

16:46 oh I see, doto returns the original object

16:49 Chouser: mebaran151: and feeds the original object into each step. -> feeds each expression into the next.

16:49 mebaran151: ah

16:49 I just discovered ->, it's a very neat way to design stuff I'd normally do pesudo-imperatively with a number of let bindings

16:50 LauJensen: Anyone here skilled with nginx that I can hijack for a private 2 min chat ?

16:51 mebaran151: I've kind of set up nginx before

16:51 are you trying to set up a reverse proxy

17:00 ZabaQ: I'm thinking of trying to get penumbra working on 'doze, but there are some bits in it's lib directory that I can't find the win32 equivalent of.

17:01 what the hell are newt and nativewindow?

17:08 JAS415: quick question:

17:08 > (.split "snipper403.html" ".")

17:08 >#<String[] [Ljava.lang.String;@383118>

17:08 i try to split on a period

17:08 split doesn't work

17:09 ZabaQ: hmm. newt is a text UI library..

17:09 JAS415: >(second (.split "snippet403.html" "3"))

17:09 > (second (.split "snippet403.html" "3"))

17:09 >".html"

17:09 anything else works

17:11 ooh do i have to escape the .?

17:11 drewr: ,(.split "foo.html" "\.")

17:12 JAS415: ah okay, thanks :-)

17:12 drewr: whoops, try (seq (.split "foo.html" "\\."))

17:12 clojurebot must have taken Sunday off

17:15 syamajala: why does using ns break tab completion in clojure mode in emacs?

17:17 JAS415: ahh

17:17 very nice

17:24 syamajala: slime with clojure is frustrating

17:24 maybe i should try eclipse

17:25 JAS415: what's frustrating about it?

17:25 rather

17:25 what are you finding to be frustrating

17:25 syamajala: it just doesn't seem to be as polished as slime with a common lisp

17:26 drewr: sure, slime/swank was written for CL

17:26 JAS415: i can see that

17:27 drewr: I'm amazed at how well clojure/swank works honestly

17:42 syamajala: i think i would rather deal with slime and clojure than use eclipse

17:58 tomoj: ns doesn't break tab completion for me

18:54 lowlycoder: i asked this a few days back, but lost the answer -- what's the best opengl library for clojure?

18:55 Chousuke: And I think I suggested penumbra. :P

18:56 lowlycoder: my irc logs agree

18:56 you in fact stated it at 14:54 last time

18:56 oops, I think I just gave away my time zone

18:56 Chousuke: somewhere across the atlantic? :P

18:57 lowlycoder: depends on which side of the atlantic you're on

18:58 Chousuke: east side.

18:58 :P

18:58 lowlycoder: i don't understand geography

19:01 JAS415: ok so

19:01 i'm trying to save an image to file

19:02 i'm using something like this

19:02 (javax.imageio.ImageIO/write img ext file)

19:02 passing this : (#<ToolkitImage sun.awt.image.ToolkitImage@1bb02e> jpg #<File /home/jon/hacking/clj/current-work/cache/images/markcc_normal.jpg>)

19:02 lowlycoder: i have no idea how to solve your problem, but I'm gong to take this opportunity to look at this and see how responsive the cloure irc community is

19:02 JAS415: and returining

19:02 Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: No matching method found: write

19:03 this

19:03 followed by a stacktrace

19:04 Chousuke: your arguments probably have the wrong type.

19:04 JAS415: im guessing it is something to do with using a toolkit image and imageio together

19:04 hmm

19:04 clojure is great, java is annoying

19:05 Chousuke: It'd help a lot if Clojure told you what parameter types the method call was attempted with

19:05 JAS415: yeah that would be nice

19:05 lowlycoder: err, penumbra ... does it have any docs?

19:05 like how the heck do I run the examples

19:06 Chousuke: check the wiki?

19:06 lowlycoder: there's a wiki?

19:06 i only found mailing list posts

19:06 Chousuke: every github page has a wiki

19:07 but other than that, it doesn't seem there's much documentation besides the readme

19:07 lowlycoder: the readme doesn't say much

19:07 want to help me get this to work? :-)

19:08 Chousuke: you'll probably just need to add everything in the /lib dir to your classpath

19:09 in addition to the penumbra lib of course

19:10 lowlycoder: eh, screw this; i'll just use jogl

19:10 and yet write my own bindings in addition to cloggle, penumbra

19:10 Chousuke: I think in java 6, -cp lib/*:penumbra-dir-here/:clojure.jar ought to work

19:10 lowlycoder: or you could mail the author :P

19:10 lowlycoder: mail ... is that like asynchronous irc?

19:11 * arbscht suspects lib/ might need to be in LD_LIBRARY_PATH too

19:12 lowlycoder: okay, I can't get jvax.media.opengl

19:12 i suspect this is eomthign wrong with my java installation

19:12 how do I get it?

19:13 Chousuke: it's probably the set of jars in the lib/ dir of penumbra :P

19:14 lowlycoder: how can I check if my java is loading /usr/share/java/jogl-1.1.1+dak1.jar

19:14 /usr/share/java/gluegen-rt-1.1.1+dak1.jar

19:14 and /usr/share/java/jogl.jar

19:14 /usr/share/java/gluegen-rt.jar

19:14 JAS415: yup converting to a buffered image worked

19:14 lowlycoder: ? I have jogl installed already

19:15 JAS415: haha

19:15 lowlycoder: ?

19:15 JAS415: they should rename it 'BufferedImageIO'

19:15 ImageIO is misleading

19:15 Chousuke: lowlycoder: you'll have to specify the classpath manually anyway :/

19:15 lowlycoder: it's how java works ;/

19:16 there's a way to tell jvm to load all jars from a single dir though.

19:16 lowlycoder: it doesn't autoload all from /usr/share/java ?

19:16 Chousuke: no, it doesn't

19:17 lowlycoder: great, it works now

19:17 thanks :-)

19:20 tomoj: the apparent lack of console ui libraries for java depresses me

19:20 I suppose it comes with platform independence

19:21 lowlycoder: speaking of which

19:21 is there a good terminal enulator in java?

19:21 Chousuke: :/

19:21 I'm not aware of one. why?

19:24 tomoj: I'm thinking I need to use the JNI with ncurses or something

19:30 osaunders_: Does first post need to be moderated on http://groups.google.com/group/clojure ?

19:43 Chousuke: osaunders_: IIRC yes.

19:43 osaunders_: Chousuke: OK. Waiting game for me then I guess.

19:54 lowlycoder: how do I import in all the functions here: http://download.java.net/media/jogl/jogl-2.x-docs/javax/media/opengl/fixedfunc/GLLightingFunc.html#glShadeModel(int)

19:55 (import '(javax.media.opengl.fixedfunc)

19:55 is not cutting it

19:55 (i do have an ending ), it's just not shown sinre more are included

19:57 Chousuke: lowlycoder: you don't import functions; you import classes.

19:58 lowlycoder: All Known Implementing Classes: DebugGL2, DebugGL2ES1, DebugGLES1, FixedFuncHook, FixedFuncImpl, TraceGL2, TraceGL2ES1, TraceGLES1

19:58 so i have to import one of those?

19:58 Chousuke: most likely.

19:58 or you can import just the interface too if you only need access to the statics.

19:59 lowlycoder: no, I need to use glShaderModel

20:00 http://clojure.googlegroups.com/web/opengl-gears.clj?gda=gTJ_y0EAAABDIkriCAGxFgqh3JA2kVqHjmUnUmFxkzZFmBPeskNnImG1qiJ7UbTIup-M2XPURDQ2vNdh001Siw0x8QiEtM34WlKsreMtIDAb3JYcIi6O-A&gsc=FWPSYAsAAADf7lsqqJAqFfo_UvfMxMwC <-- can you help me get this to work?

20:01 Chousuke: I think I'll have to get some sleep now :/

20:01 lowlycoder: fair enough, thanks for all your help :-)

20:01 Chousuke: but looks like that's very old clojure code.

20:01 the dotos are missing dots for java methods.

20:02 the old syntax for doto was (doto javaobj methodcall (methodcall2 args)), but that was changed to (doto obj .methodcall (.methodcall2 args) clojure-fn)

20:03 lowlycoder: great, it moved me on to a different error

20:03 yay; thanks

20:03 how has doseq changed?

20:03 (doseq i (range (+ 1 teeth))

20:03 (let [angle (/ (* i 2.0 (. Math PI)) teeth)]

20:03 gives: #<CompilerException java.lang.IllegalArgumentException: doseq requires a vector for its binding (opengl-gears.clj:34)>

20:03 Chousuke: it now takes [i seq]

20:03 like let

20:04 lowlycoder: woot

20:04 if you can stay awake for another 10 mins

20:04 I think I can get this to work

20:04 line 46 now

20:05 Chousuke: it looks like there's not much besides the dotos and doseqs

20:05 lowlycoder: woot

20:05 this runs

20:05 Chousuke: and lots of dots :(

20:05 lowlycoder: and ... gets me a blank screen :-(

20:05 but no exceptions

20:06 * Chousuke does not like using the . form directly.

20:06 lowlycoder: hmm, i will conttinue debuggint this

20:06 thakns for all your help :-)

20:06 Chousuke: no problem. Now I will try to sleep :P

20:06 later.

20:06 lowlycoder: cheers

20:12 crap, the javax.media.opengl.GLAutoDrawable stuff looks kinda out of date

20:27 konr: Guys, I'm following a Clojure tutorial, yet I am having an error with an example. Any idea on what could have caused the error? A missing library? Take a look: http://scorciapino.com/pub/fotos/xmonad3.png

20:42 tomoj: konr: did you eval the ns form?

20:52 konr: tomoj: yes

20:52 tomoj: hmm, wait..

21:00 tomoj: the doto needs to be evaled in the com.ociweb.demo namespace

21:00 I can't tell what editor that is

21:00 konr: haha, vi

21:00 tomoj: in emacs I'd just C-c C-k to compile the whole file

21:00 konr: apparently, the problem is with the DISPLAY variable

21:01 I've set it now to 0:0, but I'm getting the "cannot connect to display" error...

21:01 tomoj: why would DISPLAY cause an "unable to resolve classname" error?

21:01 that's odd

21:02 konr: actually that particular error was because I hadn't evaluated the ns

21:04 Hmm, I've set DISPLAY to :0 and no longer I'm getting an error, but the doto form returns nil

21:05 tomoj: that's odd

21:05 konr: (and doesn't show up the "Hello World" window)

21:05 tomoj: that means (JFrame. "Hello") is null

21:05 is that even possible?

21:05 konr: let me comment everything else...

21:06 tomoj: doto is supposed to return the thing the stuff is done to

21:07 konr: hmm, it's not returning anything

21:07 tomoj: do you have a repl?

21:07 konr: yes

21:07 tomoj: (JFrame. "Hello") just returns nil?

21:10 konr: nope, an object, apparently: #<JFrame javax.swing.JFrame[frame2,0,0,0x0,invalid,hidden,layout=java.awt.BorderLayout,title=Hello,resizable,normal,defaultCloseOperation=HIDE_ON_CLOSE,rootPane=javax.swing.JRootPane[,0,0,0x0,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]>

21:10 tomoj: ok, so something is wrong with the doto

21:10 it should return whatever (JFrame. "Hello") returns

21:11 konr: hmmm, apparently it is the "(.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)" line

21:11 tomoj: that's probably a bad idea anyway, I'd think

21:12 if you're running this in a long-running clojure session in the background

21:13 it works in my slime repl though

21:14 but then if I close the window, slime dies

21:14 konr: hmmm

21:23 is anybody using vimclojure?

21:23 peregrine81: konr: I was wondering the same thing

21:25 konr: peregrine81: haha, how do you deal with namespaces? it seems that after I eval a (ns) form with \et, *ns* doesn't change

21:26 peregrine81: konr: I've never actually used it I was looking more for reviews/opinions

21:26 konr: peregrine81: hmmm, it is pretty good. Much better than the similar plugins for common lisp

21:29 tomoj: konr: maybe try doing (in-ns 'whatever.whatever) first

21:29 in the repl or with \et I guess, not sure how vimclojure works

21:30 and by first I mean second

21:32 Knekk: quickest way to check if elem is a member in list?

21:33 dreish: (some #{elem} list)

21:34 Knekk: thanks

21:35 tomoj: do lists return true for contains? ever?

21:35 konr: tomoj: interesting... it worked. Apparently, every repl window starts in the user namespace, and everytime I evaluate a form, it will also be in user namespace.

21:36 dreish: tomoj: If you mean (.contains '(1 2 3) 2), yes, that works too.

21:36 tomoj: no, I meant contains?

21:36 (contains? '(1 2 3) 1) is false

21:36 paulp: hello clojure people. I am scala person investigating clojure. I'm in the market for nutty ideas that leverage both languages. Sky's the limit. Thanks for any conversation starters.

21:37 dreish: tomoj: No, it will fall through the if/else if/else if/... in Rt.contains() and return false.

21:37 RT.contains(), that is.

21:38 tomoj: ah

21:38 seems kinda strange t ome

21:38 (contains? #{1 2 3} 1) is true

21:39 dreish: Yes, I might have had it throw an exception if given a non-indexable object.

21:39 tomoj: or at least explain in the docs what "non-indexable" means :)

21:40 oh, it sortof hints at the fact that it doesn't work for lists

21:40 since it says constant/log time

21:45 konr: shouldn't the clojure server have a single *ns* variable?

21:46 dreish: paulp: The only connection I've heard of is that someone once said they'd like to see the Clojure persistent data structures in Scala.

21:46 paulp: yeah, that's kind of cheating though, just bytecode reuse.

21:47 I was hoping to tackle some kind of scala problem I can't handle with scala proper, metaprogramming maybe.

21:47 dreish: Is it just me, or is github.com heavily broken a lot lately?

21:47 paulp: dreish: it is not just you.

21:47 dreish: That's a relief. I've been getting server errors for at least a week trying to look at the Clojure network graph.

21:47 Thought maybe I was clicking it the wrong way.

21:48 paulp: I'm sitting here unable to get the clojure source, making me sad

21:48 and I pay github, too.

21:48 dreish: Okay, it's all over the twitterwebs.

21:49 paulp: the irony of github bringing a single point of failure to git never ceases to amuse

21:51 dreish: Looks like it went down about 4-5 hours ago.

21:52 paulp: wtf github gentlemen!

22:21 peregrine81: So is pragmatic programmer: Clojure a good place to start for a first time lisper?

22:37 Chouser: peregrine81: yeah, about as good as there is at the moment.

23:20 konr: I must change the namespace with (ns *args*), right?

23:25 Chouser: or 'in-ns'

23:43 konr: is the *ns* variable something contained inside each package, ie, with a foo/*ns* and a bar/*ns*?

23:51 Chouser: no, it's clojure.core/*ns*

23:51 ,(var *ns*)

23:51 oh, no clojurebot. anyway, paste that in a repl to see the full name of a the var *ns*

23:52 konr: hmmm, it's strange. I have two repls connected to a server, and each of them has a different value of *ns*

23:53 when I change *ns* in one of them, shouldn't *ns* change globally?

23:54 tomoj: how do you connect a repl to some running clojure code?

23:54 Chouser: vars can have thread-local values

23:55 so if the server has one thread per connection, they'd be independant of each other.

23:55 or it could be doing something else to keep the two repls from messing each other up.

23:58 tomoj: ah, clojure.contrib.server-socket looks helpful

23:58 konr: tomoj: I'm using vimclojure... you can start as many repls as you'd like

23:58 tomoj: yeah, your question just reminded me of that question

23:58 konr: the strange thing is that user/foobar is the same for all of them

Logging service provided by n01se.net