#clojure logs

2009-08-16

00:07lowlycoderwhat's the comment char in clojure?
00:07Anniepoo; end of line
00:07andyfingerhutsemicolon
00:08Anniepooyou can ifdef out a form by preceeding it with #_
00:26lowlycoderso structs are just maps?
00:26rlblowlycoder: yes, though optimized for the named elements.
00:26andyfingerhutwith some space efficiency enhancements, yes
00:29lowlycoderinteresting, thanks
00:29andyfingerhutkinda cool that you can still add other keys to them if you really want to
00:31lowlycoderclojure does not allow defining of reader macros
00:32lowlycoderhow do I violate this condigion?
00:32lowlycoder*condition*
00:32technomancynext time someone complains about Clojure stacktraces point them to JRuby... it gets the line number significantly wrong frequently
00:32technomancylowlycoder: patch LispReader.java and recompile
00:33Anniepoolowlycoder - it means you can't decide that you don't like #^{} for metadata and want that to be something else
00:39lowlycodertechnomancy: nice; thanks
00:47lowlycoderso 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)
00:48Anniepooit is for the simple case
00:48tomojit's only tail recursive if you make it tail recursive
00:49tomojwell.. any tail recursive function is tail recursive
00:49tomojbut clojure will not automatically optimize
00:49tomojyou have to be explicit if you want optimization
00:55lowlycoderso I can't write functions like:
00:55lowlycoder(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?
00:55lowlycoderdoes "optimize it myself" mean convert it to a do loop?
00:56replacalowlycoder: just replace the second foo with recur and you'll be good
00:58tomojthat is not clojure code anyway..
00:58lowlycoderhey; i'm converting over slowly
00:59tomojfrom what?
00:59tomojdoesn't look like any lisp I've used either :)
00:59replaca,(let [f (fn [a b] (if (= a 0) b (recur (dec a) (inc b)))) ] (f 10000000 10000000))
00:59tomojthe bot isn't here :(
00:59replaca:(
00:59replacawell, running it is an exercise for the reader
01:00tomojworks fine
01:00lowlycoderwhy is implementing trampolines so hard?
01:00replacai knew that :-)
01:00tomojwe have trampolines
01:00tomojclojure.core/trampoline
01:01tomojthey aren't necessary for simple tail recursion like the above
01:01lowlycoderwell, the above is a leaky abstraction
01:01lowlycoderit makes me have to think to use recur
01:01tomojyup, sorry
01:01tomojit's the JVM's fault
01:01replacalowlycoder: yeah, it's supposed to be. Rich doesn't want to hack in a solution when it should be solved at the JVM level
01:02tomojmaybe the JVM will have TCO someday
01:02replacathat's his assumption, I think. It is under discussion, but not at the top of the list
01:03lowlycodergreat; so we don't have a solution until the JVm changes, even thouch in theory we could?
01:03replacathat's probably true
01:03replacaunless Rich changes his mind
01:03tomojweird
01:04tomojI've heard multiple times that it's flat out impossible
01:04replacain real life, I haven't noticed it to be much of a pain point
01:04tomojwithout the qualification "unless we do ___, which we don't want to"
01:04replacawell, for the recur case, Rich could do the optimization himself in the compiler
01:04replacabut the trampoline case is a bunch harder
01:05replacaRich has tried to compile to very clean code in general in order to best leverage the JVM's strengths
02:08Anniepooarchitectural question
02:09AnniepooI'm going to implement a database of resources
02:09Anniepooessentially takes a string and returns a ID for a resource that's expensive to make
02:11Anniepooso I'll keep a memory resident copy of a file (durability isn't important here)
02:11Anniepooand modify and write
02:12Anniepoois it better to make the file format be a def and just load it?
02:40arbschtso close yet so far. got clojure-clr to sort-of-kind-of build on mono, but not yet load :(
02:45tatofoohow 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
02:48arbscht,(int-array [0 10 10])
02:49tatofooarbscht: :O thanks, sorry for my ignorance but what's the , for?
02:50arbschtthat usually triggers clojurebot to evaluate the expression
02:50lowlycoderwhat's clojure's obsession with [] ? why does let even use [] to separate the vars from the body?
02:50tatofoohehe, ah ok, than you I'll try that
02:50arbschthowever clojurebot is missing in action today :/
02:52arbschtlowlycoder: it's a feature of clojure's homoiconicity
02:53lowlycoderwhat does it mena?
02:53lowlycoderthe word's too big for me
02:54Anniepooclojure code and clojure data are one and the same
02:54arbschtclojure's code is represented by clojure data structures
02:54arbschtmore info at http://en.wikipedia.org/wiki/Homoiconicity
02:55lowlycoderthis doesn't seem to explain why let is based on vectors rather than lists
02:55lowlycoderperformane reasons?
02:55lowlycoderso for anyting whose length we know at compile time, use vectors instead of lists?
02:56Anniepoolowly, vectors aren't assumed to be functions
02:56arbschtoh, partly for aesthetic reasons (too many parens), but also to differentiate from operator calls
02:57Anniepooyou'll come to appreciate having both structures
02:57lowlycoderit's also weird that (let [[x y] [1 2 3]] ... ) just drops the 3
02:58lowlycoderit seems like it should throw an error of some kind
03:01tomojI find it very useful that it doesn't throw an error
03:03lowlycoderClojure=> (import '(package Class+))
03:03lowlycoder#<CompilerException java.lang.ClassNotFoundException: package.Class+ (REPL:1)>
03:03lowlycoderwhy doesn't this work?
03:04lowlycoder(import '(java.io InputStream File))
03:04lowlycoderwhy doesn't that use [] instead of () ?
03:04lowlycoderespecailly since it'l reduce the need for '
03:05arbscht(import [java.io InputStream File]) works
03:07lowlycoder(round 1.2) --> goes to 1, not 2 as mentioned in the book
03:08arbschtstu halloway's book?
03:08lowlycoderya
03:08tomojlowlycoder: you're not supposed to type the code in the grey boxes
03:08tomojI suppose you've realized this
03:08tomojit's just a typo
03:12tatofoo:O I was wondering about that '( in the import aswell, didn't know you could use [] :D
03:16lowlycoderso do is just == begin?
03:17arbschtwhat's begin?
03:17tomojyou mean begin from ruby?
03:17lowlycoderbegin from scheme
03:18tomojoh.. dunno
03:18tomojprogn from CL
03:22lowlycoderhmm, so recur does tail recursion on a singl efunction
03:22lowlycodercan i have a set of functions that recur on each other?
03:22lowlycoderi.e. the last expr in f is (g ...), and the last expr in g is (f ...)
03:27tomojlowlycoder: that's in the book
03:27lowlycoderhaven't gotten to there yet
03:27lowlycodercan you tell me?
03:27tomoj5.4
03:27tomojthere are a few different ways to solve that problem
03:28tomojyou're probably looking for trampoline
03:30tomojbut laziness or solving the problem another way can be prettier
03:43lowlycoderhow does def and defn differ?
03:43lowlycoderI'm confused on when to use the two
03:46arbschtdefn is defined in terms of def. use defn when you intend to define a function
03:46lowlycoderwhy not juse use def all the time?
03:50arbschtI guess you could if you wanted to
03:50mudphoneconvenience
03:50arbschtdefn has the advantage of being nicer to read, with an easy way to add docstrings
03:55lowlycoder(defn indexed [coll] (map vector (iterate inc 0) coll))
03:55lowlycoder(defn index-filter [pred coll] (when pred (for [[idx elt] (indexed coll) :when (pred elt)] idx)))
03:55lowlycoder(index-filter #{\a \b} "abcdbb")
03:55lowlycoderno way, is the ${} ... using advantage of the fact that sets are functions of it's members?
04:21tomojyep
04:21tomojcool, huh? :)
04:21lowlycodera little too magical for my liking
04:22lowlycoderi 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
04:22tomojthere is no "convert a set into a function" in the syntax
04:22tomojsets ARE functions
04:24tomoj#{} is just reader syntax for sets
04:27tomojif you want to be more verbose for some strange reason you can use (set '(\a \b))
04:28tomoj..and if you don't like sets as functions you can go ahead and use (contains? (set '(\a \b)) \a)
04:29tomojpersonally I think (#{\a \b} \a) is a lot cooler :D
04:29lowlycoderi don't like verbosity
04:29lowlycoderi just don't like things that are hardcoded for me
04:29tomojyou don't have to use the set reader macro if you don't want to
04:30lowlycoderi think reader macros are cool; and the syntax introdued is pretty elegant
04:30lowlycoderi'm just annoyed that I can't modify it to my future needs :-D
04:30tomojuser reader macros cause problems that rich decided were not worth the trouble
04:33lowlycoderdoes clojure require the use of capital letters at all?
04:33lowlycoderor are all names separated by - by default?
04:34tomojnames are separated by whatever you separate them with.. I don't understand the question
04:34arbschtnames in the clojure api do not. names imported from java might
04:34lowlycoderlangauges like c/java tend to use things like CamelCase
04:34lowlycoderI was just curious what clojure tends to use
04:34tomojconvention is lisp-case
06:34ZabaQI know Common Lisp fairly well, but I have no clue about Java. How much pain am I letting myself in for?
06:36ChousukeHmm.
06:36arbschtnone, I should hope. I came to Clojure from CL and that was painless.
06:36ChousukeZabaQ: You'll have to learn to read javadocs at least :)
06:36Chousukebecause while you won't have to write java, it's still very useful to know the java libraries.
06:38Chousukethough clojure.contrib does contain wrappers for a lot of the basic functionality that clojure.core leaves to java
06:42ZabaQChousuke: Hmm. I haven't looked at clojure-contrb yet. Perhaps I should.
06:42ChousukeYeah. Pretty much everyone uses it anyway.
06:43Chousukeand yet there is no proper release of it :P
06:43Chousukeso you'll need to git it :)
06:47ZabaQI'm going to need ant
06:49Chousukeunfortunately :P
06:50ZabaQI 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.
06:50ZabaQI assume it's much happier in Java-land.
06:51Chousukewell, it's still a programming language with XML syntax
06:51Chousukeand not in a good way like xslt
06:52arbschtbetter ant than visual studio solution files...
06:52Chousukebut fortunately, most of my use of ant just involves calling the targets :P
06:52arbschtnot that you have to do much more than "ant jar" or the like
06:52arbschtright
06:58ZabaQant complained about not being able to find tools.jar. Is that bad?
06:59Chousukehm
06:59Chousukeyou're probably missing some dependency?
07:07ZabaQI wan't using the right JRE. There's an anicent one lurking on this machine
07:16ZabaQclojure.contrib.monads!?
07:17ZabaQhmm. there is a lot of stuff in there.
07:17Chousukeyeah :)
07:18ZabaQBUILD SUCCESSFUl. Wahey. I think I need to read docs for a bit..
07:18Chousukewhich version of clojure are you using?
07:18ZabaQgit
07:18ZabaQhead
07:18Chousuke'k. then contrib will work fine too
07:19Chousukecontrib master only works with clojure master; there's a 1.0-compatible branch too though.
07:19ZabaQright
07:20Chousukealso see http://java.ociweb.com/mark/clojure/
07:24ZabaQjavadocs are best read in an ordinary browser, I take it?
07:24Chousukethat's what I do.
07:24Chousukeand Clojure docs from slime :P
07:25Chousuke(well, function docs anyway)
07:26ZabaQah, 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.
07:26ZabaQ(metaphorically).
07:26Chousukeheh.
07:27ZabaQI think slime has a mode that gives you slimey functionality in an *inferior-lisp* buffer: I'll try that.
08:05ZabaQIt's a Lisp-1. Oh dear.
08:07ChousukeI haven't yet figured out how that's supposed to be a problem :)
08:11ChousukeI always hear stuff about how lisp-1's have hygiene problems and whatnot but I honestly don't know what they're talking about.
08:11eevar_and having to use "funcall" blows chunks imo
08:16osaundersI wanted to have a value called range but couldn't.
08:16osaundersThen again maybe that would have been a bad name.
08:17osaunders... in a Lisp-2
08:17Chousukewell, you can have the range value but it'll shadow the function def :P
08:18Chousukethat's one think I'll give to lisp-2 :)
08:18osaunders,(let [range (range 10)] (print range))
08:18Chousukebut not worth funcall IMO :P
08:18osaundersDude, where's clojurebot?
08:18Chousukeno idea :/
08:19Chousukehiredman is gone too so hmm.
08:22osaundersIs hiredman related to clojurebot?
08:22Chousukehe made it. :P
08:22osaundersAh.
08:23osaundersFather then. :-)
08:24ChousukeClojurebot actually started as a gist.
08:24Chousukebut then I wanted to hack on it a bit and cloned the gist and put it in a proper github repo :P
08:24Chousukethat's why the early history doesn't have very interesting commit messages.
08:26Chousuke(and why github says hiredman's repo is a fork of mine)
08:26osaundersYou credit stealer you.
08:27ChousukeI haven't touched it in half a year, though
08:30Chousukethe beginning: http://github.com/hiredman/clojurebot/blob/2381e7989977b8999aa0f863ef0a50415bb6e5fc/clojurebot.clj
08:34ZabaQLisp-1 isn't a big deal, you have to be more careful about names, mainly.
08:34Chousukein Clojure at worst you end up shadowing them locally
08:35Chousukeunless you do trickery in a macro to force a capturing expansion.
08:39ChousukeSyntax-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.
08:40Chousukethough doing it makes your macro look ugly, which is probably just a good thing
08:44osaundersBrainfart is Windows 7 out?
08:44Chousukeno.
08:44arbschtprogress... clojure-clr now loads on mono, but dies anyway :)
08:44osaundersOK. Thanks for clearing that up.
08:45Chousukebut apparently there's an RTM build already
08:45osaundersRead The Manual build?
08:45ChousukeRelease to manufacturing or something? the gold master :P
08:46ZabaQIt might actually tempt me to upgrade from Win2k
08:46ChousukeWin2k :|
08:47osaundersWow I clicked on 90% of all the links on Hacker News today.
08:47osaundersNormally it's about 40%
08:55ZabaQI don't suppose there's anything like (describe ) in CL?
08:56danlei(doc ...)
08:57danleiactually more like documentation, but closest
08:58arbscht(meta ...) covers some of the difference too
09:01cemerickwell, (meta #'...), anyway :-)
09:04danlei(meta #'symbol) pretty much feels like (symbol-plist 'symbol), but modern CLs usually don't put such information in plists anymore.
09:09cemerickgood thing clojure isn't a modern CL ;-)
10:55syamajalai'm trying to figure out swank
10:55syamajalauser=> java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)
11:00danlei(add-classpath "file:///path/to/swank-clojure/")
11:00danlei(require 'swank.swank)
11:01danlei(swank.swank/start-server "/path/to/tmpfile/")
11:01danlei(swank.swank/start-server "/path/to/tmpfile.tmp")
11:03danlei(add-classpath is considered bad style, but it's ok for figuring things out)
11:19syamajaladanlei: that seems to work, or at least i can do slime-connect from emacs that way
11:19danleiok
11:19syamajalaideally i would like to just be able to do M-x slime-clojure and be presented with a repl
11:20syamajalaand i have stuff setup that way right now in my .emacs its just that clojure can't find the swank stuff
11:20danleiyou 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:20syamajalaand i know no nothing of java and all this classpath stuff. i'm coming from lisp...
11:21danleiin emacs, you can set swank-clojure-extra-classpaths
11:22danlei- here's what I have for cygwin
11:22danlei(when (eq system-type 'cygwin)
11:22danlei (setq swank-clojure-jar-path
11:22danlei "e:/cygwin/home/danlei/build/clojure/trunk/clojure.jar"
11:22danlei swank-clojure-extra-classpaths
11:22danlei '("e:/cygwin/home/danlei/coding/lisp/clojure/")))
11:22danlei
11:22danleito give you an idea
11:22syamajalai just used your java -server -cp line
11:23syamajalain a script
11:23danlei(actually, what I once HAD in my .eamacs :)
11:23danleiok
11:23syamajalathat seems to work
11:23danleiglad to hear it works
11:28syamajalaok now my setup is exactly the way i want it
11:52markaddlemanhey 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:09Chouserthere 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:11markaddlemanthanks.
12:15osaundersYou know what would help a lot.
12:15osaundersA related functions list for each function.
12:16Chouseryeah.
12:16ChouserI made a weak attempt at that on the clojure.org site
12:16osaundersAlso each function could probably do with it's own page.
12:16Chouserlisting groups of functions for each data structure.
12:16osaundersWhere can I find that?
12:17Chouserhttp://clojure.org/data_structures#toc16 for example
12:18osaundersHm, it's a good start.
12:18Chouserbut yes, a page per function, with several examples, related function links, discussion of performance for various data structures, etc. would be nice.
12:18Chouserthough creating it is only a fraction of the work -- then it has to be maintained. :-/
12:18osaundersExactly. I couldn't put it better myself.
12:19osaundersWell, it's a wiki. With enough people these things are easily maintained.
12:19osaundersSmall corrections here and there by several people.
12:19syamajalais there a hyperspec-lookup type thing?
12:19osaunders(doc symbol)
12:19osaundersIs that what you mean?
12:20syamajalayeah i guess thats good enough for now
12:20osaundersI mostly don't believe in good enough.
12:22osaundersIs there a nice way to convert ([x y] [x y]) into [x y x y]?
12:23osaundersChouser: Do you think I should post on the list with idea to improve the documentation?
12:23osaunders*ideas
12:27osaundersOh concat!
12:28dreishosaunders: What good would wishing out loud do? If you want it, why not actually do something about it?
12:29osaundersThere are many reasons not to act.
13:48gcvis there any way to make a thread "inherit" a dynamic binding from wherever it's created?
13:48gcve.g., I'd like (binding [*x* 3] (.start (Thread. (fn [] (println *x*))))) to print 3
13:49gcv(assuming something like (def *x* 5) on the outside)
13:49Chousukedo (let [*x* *x*] (Thread. #(println *x*)))
13:50Chousukethat captures the dynamic binding as a local one so the thread can access it.
13:53gcvChousuke: that's pretty good, but doesn't work if the thread gets created outside the lexical scope of the let form
13:54gcvit doesn't allow access to *x* outside the lexical scope in general, which is what I'm trying to accomplish
13:54Chousukebut that way lies concurrency trouble.
13:55gcvsure, but *x* might be an immutable value, in which case it would be fine
13:55gcvthere'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:56Chousukevalues bound with binding can be changed thread-locally.
13:57ChousukeI suppose you might be able to do (let [foo *x*] (Thread. (fn [] (binding [*x* foo] (somestuff)))))
13:57gcvnot if I don't have control over the thread invocation
13:58Chousukethen there's no way. :P
13:58Chousukeyou need a ref. :/
13:59gcvif 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:59gcvhmmm, how would a ref help?
13:59Chousukehm, I guess it wouldn't in that case.
14:01ChousukeI can't think of a way to do what you want.
14:02Chousukeis it possible for you to run an "init" function in the new thread, when it's created?
14:03Chousukeif you can, you could perhaps use push-thread-bindings to set up the bindings for the thread.
14:03Chousukeor hm, that's not in master yet I guess ;/
14:04Chousuke(Var/pushThreadBindings is though)
14:04gcvpush-thread-bindings? that sounds promising
14:04gcvwhere should I look for that code?
14:04Chousukeit's what binding does undercover
14:04Chousukeit just also does a popThreadBindings :)
14:05Chousuketake a look at the binding macro. it should be easy enough to understand.
14:05gcvyup, got it. thanks
14:06gcvso 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:06gcvsounds like cake :)
14:08Chousukethere's also getThreadBindings
14:08Chousukefor getting the parent thread bindings :P
14:11gcvChousuke: nice. thank you
14:23d2dchatdoes 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:26gcvd2dchat: wow. wild. maybe something there screws up pseudorandom numbers?
14:27dreish(iterate rand-int 100) passes the prev rand-int return val as the argument to the next call to rand-int.
14:27d2dchatahhh
14:27d2dchatthat make sense
14:27d2dchathaha
14:27dreishThere might be a better way to put it, but:
14:28dreish,(take 10 (repeatedly #(rand-int 100)))
14:28dreishOh, cjbot is offline.
14:28d2dchatahh works :)
14:31tomojthat's a cool problem though
14:31tomojhow many numbers on average do you get before you wind up at zero
14:34dreishAround 5.18 or 5.19.
14:35tomojyeah, but.. I wonder how you'd actually figure it out
14:35tomojheading to #math
15:04tomojaha
15:04tomojthe answer is 14466636279520351160221518043104131447711/2788815009188499086581352357412492142272
15:05dreishWhy?
15:05tomojsomeone in #math gave an elegant argument for why the answer is 1+1/2+1/3+...1/n
15:06tomojie the harmonic numbers
15:06dreishInteresting.
15:11konrhave you guys used qt with clojure?
15:15d2dchatIs there a way to rescue exceptions in clojure?
15:16d2dchatkonr: that sounds interesting :)
15:17d2dchatkonr: I have not but, I think there is a Java binding to Qt
15:17d2dchatI would start there
15:25tomojd2dchat: you mean java exceptions?
15:25d2dchatYes
15:25tomojd2dchat: http://clojure.org/special_forms#try
15:25d2dchatMy program is evaluating division by zero occasionally and I just want it to ignore it silently and move on
15:26d2dchattomoj: ah! Thanks!
15:34osaundersd2dchat: Testing the divisor with zero? beforehand may be cleaner and more performant.
15:35d2dchatosaunders: Would be, but this framework is too generic.. :(
15:35Chousukeosaunders: unless you're doing millions of divisions and only a few of them will be zero
15:35osaundersd2dchat: OK.
15:35Chousukein those cases, catching the exception may actually be faster
15:36osaundersChousuke: True.
15:36d2dchatWell, all kinds of exceptions *could* happen
15:36d2dchatif one happens, I just want it to do nothing
15:37d2dchatand move on
15:37d2dchatGenetic Programming :)
15:37osaundersThe concern with that is there may be exceptions that you don't want to ignore that you'll catch.
15:37d2dchatYea, I will have to build that in somehow.. good point :)
15:41tomojare you evolving sexps?
15:43d2dchattomoj: yes
15:43tomojawesome
15:44osaundersWhat's that?
15:44d2dchatI'm new to clojure
15:44d2dchatand it took me a week to do
15:44d2dchat(on and off after work)
15:44tomojclojure seems intuitively harder for that than other things, but I've never tried anything like it
15:44d2dchatWhich is pretty incredible
15:45tomojI 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:45d2dchatYa, I had to play with it a bit
15:45d2dchatWhy's that?
15:45tomojbut like I said I've never done any genetic programming
15:45tomojwell, lazy seqs and first class functions and all
15:46d2dchatright
15:46tomojseems like it would be difficult to have something write e.g. combinations of map/filter/reduce using anonymous functions that even compiled successfully
15:46tomojor did anything meaningful if they did compile
15:46d2dchatI'm going to do some tests on lists
15:46d2dchatI just finished arithmetic so
15:47d2dchatWhich worked out pretty well :)
15:47tomojcool
15:47tomojI'm interested in writing a neuroevolution library in clojure
15:48d2dchatI found the answer to life, the universe and everything using my framework just now
15:48d2dchat:)
15:48tomojhaha
15:48osaunders42?
15:49d2dchat(* (- 2 4 2) (/ 7 2 2) (- 7 9 4))
15:49d2dchat(/ (* 6 9 3) (/ 2 7 8) (* 6 3 6))
15:50d2dchatoh clojurebot
15:50d2dchatwhere art thou?
15:50osaundersWe're not sure.
15:51osaundersHe belongs to hiredman though and he's not around either.
15:59bryanjswiftanyone 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:45mebaran151what's the difference between doto and ->?
16:46mebaran151oh I see, doto returns the original object
16:49Chousermebaran151: and feeds the original object into each step. -> feeds each expression into the next.
16:49mebaran151ah
16:49mebaran151I just discovered ->, it's a very neat way to design stuff I'd normally do pesudo-imperatively with a number of let bindings
16:50LauJensenAnyone here skilled with nginx that I can hijack for a private 2 min chat ?
16:51mebaran151I've kind of set up nginx before
16:51mebaran151are you trying to set up a reverse proxy
17:00ZabaQI'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:01ZabaQwhat the hell are newt and nativewindow?
17:08JAS415quick question:
17:08JAS415> (.split "snipper403.html" ".")
17:08JAS415>#<String[] [Ljava.lang.String;@383118>
17:08JAS415i try to split on a period
17:08JAS415split doesn't work
17:09ZabaQhmm. newt is a text UI library..
17:09JAS415>(second (.split "snippet403.html" "3"))
17:09JAS415> (second (.split "snippet403.html" "3"))
17:09JAS415>".html"
17:09JAS415anything else works
17:11JAS415ooh do i have to escape the .?
17:11drewr,(.split "foo.html" "\.")
17:12JAS415ah okay, thanks :-)
17:12drewrwhoops, try (seq (.split "foo.html" "\\."))
17:12drewrclojurebot must have taken Sunday off
17:15syamajalawhy does using ns break tab completion in clojure mode in emacs?
17:17JAS415ahh
17:17JAS415very nice
17:24syamajalaslime with clojure is frustrating
17:24syamajalamaybe i should try eclipse
17:25JAS415what's frustrating about it?
17:25JAS415rather
17:25JAS415what are you finding to be frustrating
17:25syamajalait just doesn't seem to be as polished as slime with a common lisp
17:26drewrsure, slime/swank was written for CL
17:26JAS415i can see that
17:27drewrI'm amazed at how well clojure/swank works honestly
17:42syamajalai think i would rather deal with slime and clojure than use eclipse
17:58tomojns doesn't break tab completion for me
18:54lowlycoderi asked this a few days back, but lost the answer -- what's the best opengl library for clojure?
18:55ChousukeAnd I think I suggested penumbra. :P
18:56lowlycodermy irc logs agree
18:56lowlycoderyou in fact stated it at 14:54 last time
18:56lowlycoderoops, I think I just gave away my time zone
18:56Chousukesomewhere across the atlantic? :P
18:57lowlycoderdepends on which side of the atlantic you're on
18:58Chousukeeast side.
18:58Chousuke:P
18:58lowlycoderi don't understand geography
19:01JAS415ok so
19:01JAS415i'm trying to save an image to file
19:02JAS415i'm using something like this
19:02JAS415(javax.imageio.ImageIO/write img ext file)
19:02JAS415passing this : (#<ToolkitImage sun.awt.image.ToolkitImage@1bb02e> jpg #<File /home/jon/hacking/clj/current-work/cache/images/markcc_normal.jpg>)
19:02lowlycoderi 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:02JAS415and returining
19:02JAS415Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: No matching method found: write
19:03JAS415this
19:03JAS415followed by a stacktrace
19:04Chousukeyour arguments probably have the wrong type.
19:04JAS415im guessing it is something to do with using a toolkit image and imageio together
19:04JAS415hmm
19:04JAS415clojure is great, java is annoying
19:05ChousukeIt'd help a lot if Clojure told you what parameter types the method call was attempted with
19:05JAS415yeah that would be nice
19:05lowlycodererr, penumbra ... does it have any docs?
19:05lowlycoderlike how the heck do I run the examples
19:06Chousukecheck the wiki?
19:06lowlycoderthere's a wiki?
19:06lowlycoderi only found mailing list posts
19:06Chousukeevery github page has a wiki
19:07Chousukebut other than that, it doesn't seem there's much documentation besides the readme
19:07lowlycoderthe readme doesn't say much
19:07lowlycoderwant to help me get this to work? :-)
19:08Chousukeyou'll probably just need to add everything in the /lib dir to your classpath
19:09Chousukein addition to the penumbra lib of course
19:10lowlycodereh, screw this; i'll just use jogl
19:10lowlycoderand yet write my own bindings in addition to cloggle, penumbra
19:10ChousukeI think in java 6, -cp lib/*:penumbra-dir-here/:clojure.jar ought to work
19:10Chousukelowlycoder: or you could mail the author :P
19:10lowlycodermail ... is that like asynchronous irc?
19:12lowlycoderokay, I can't get jvax.media.opengl
19:12lowlycoderi suspect this is eomthign wrong with my java installation
19:12lowlycoderhow do I get it?
19:13Chousukeit's probably the set of jars in the lib/ dir of penumbra :P
19:14lowlycoderhow can I check if my java is loading /usr/share/java/jogl-1.1.1+dak1.jar
19:14lowlycoder/usr/share/java/gluegen-rt-1.1.1+dak1.jar
19:14lowlycoderand /usr/share/java/jogl.jar
19:14lowlycoder/usr/share/java/gluegen-rt.jar
19:14JAS415yup converting to a buffered image worked
19:14lowlycoder ? I have jogl installed already
19:15JAS415haha
19:15lowlycoder?
19:15JAS415they should rename it 'BufferedImageIO'
19:15JAS415ImageIO is misleading
19:15Chousukelowlycoder: you'll have to specify the classpath manually anyway :/
19:15Chousukelowlycoder: it's how java works ;/
19:16Chousukethere's a way to tell jvm to load all jars from a single dir though.
19:16lowlycoderit doesn't autoload all from /usr/share/java ?
19:16Chousukeno, it doesn't
19:17lowlycodergreat, it works now
19:17lowlycoderthanks :-)
19:20tomojthe apparent lack of console ui libraries for java depresses me
19:20tomojI suppose it comes with platform independence
19:21lowlycoderspeaking of which
19:21lowlycoderis there a good terminal enulator in java?
19:21Chousuke:/
19:21ChousukeI'm not aware of one. why?
19:24tomojI'm thinking I need to use the JNI with ncurses or something
19:30osaunders_Does first post need to be moderated on http://groups.google.com/group/clojure ?
19:43Chousukeosaunders_: IIRC yes.
19:43osaunders_Chousuke: OK. Waiting game for me then I guess.
19:54lowlycoderhow 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:55lowlycoder(import '(javax.media.opengl.fixedfunc)
19:55lowlycoder is not cutting it
19:55lowlycoder(i do have an ending ), it's just not shown sinre more are included
19:57Chousukelowlycoder: you don't import functions; you import classes.
19:58lowlycoderAll Known Implementing Classes: DebugGL2, DebugGL2ES1, DebugGLES1, FixedFuncHook, FixedFuncImpl, TraceGL2, TraceGL2ES1, TraceGLES1
19:58lowlycoderso i have to import one of those?
19:58Chousukemost likely.
19:58Chousukeor you can import just the interface too if you only need access to the statics.
19:59lowlycoderno, I need to use glShaderModel
20:00lowlycoderhttp://clojure.googlegroups.com/web/opengl-gears.clj?gda=gTJ_y0EAAABDIkriCAGxFgqh3JA2kVqHjmUnUmFxkzZFmBPeskNnImG1qiJ7UbTIup-M2XPURDQ2vNdh001Siw0x8QiEtM34WlKsreMtIDAb3JYcIi6O-A&amp;gsc=FWPSYAsAAADf7lsqqJAqFfo_UvfMxMwC <-- can you help me get this to work?
20:01ChousukeI think I'll have to get some sleep now :/
20:01lowlycoderfair enough, thanks for all your help :-)
20:01Chousukebut looks like that's very old clojure code.
20:01Chousukethe dotos are missing dots for java methods.
20:02Chousukethe old syntax for doto was (doto javaobj methodcall (methodcall2 args)), but that was changed to (doto obj .methodcall (.methodcall2 args) clojure-fn)
20:03lowlycodergreat, it moved me on to a different error
20:03lowlycoderyay; thanks
20:03lowlycoderhow has doseq changed?
20:03lowlycoder (doseq i (range (+ 1 teeth))
20:03lowlycoder (let [angle (/ (* i 2.0 (. Math PI)) teeth)]
20:03lowlycodergives: #<CompilerException java.lang.IllegalArgumentException: doseq requires a vector for its binding (opengl-gears.clj:34)>
20:03Chousukeit now takes [i seq]
20:03Chousukelike let
20:04lowlycoderwoot
20:04lowlycoderif you can stay awake for another 10 mins
20:04lowlycoderI think I can get this to work
20:04lowlycoderline 46 now
20:05Chousukeit looks like there's not much besides the dotos and doseqs
20:05lowlycoderwoot
20:05lowlycoderthis runs
20:05Chousukeand lots of dots :(
20:05lowlycoderand ... gets me a blank screen :-(
20:05lowlycoderbut no exceptions
20:06lowlycoderhmm, i will conttinue debuggint this
20:06lowlycoderthakns for all your help :-)
20:06Chousukeno problem. Now I will try to sleep :P
20:06Chousukelater.
20:06lowlycodercheers
20:12lowlycodercrap, the javax.media.opengl.GLAutoDrawable stuff looks kinda out of date
20:27konrGuys, 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:42tomojkonr: did you eval the ns form?
20:52konrtomoj: yes
20:52konrtomoj: hmm, wait..
21:00tomojthe doto needs to be evaled in the com.ociweb.demo namespace
21:00tomojI can't tell what editor that is
21:00konrhaha, vi
21:00tomojin emacs I'd just C-c C-k to compile the whole file
21:00konrapparently, the problem is with the DISPLAY variable
21:01konrI've set it now to 0:0, but I'm getting the "cannot connect to display" error...
21:01tomojwhy would DISPLAY cause an "unable to resolve classname" error?
21:01tomojthat's odd
21:02konractually that particular error was because I hadn't evaluated the ns
21:04konrHmm, I've set DISPLAY to :0 and no longer I'm getting an error, but the doto form returns nil
21:05tomojthat's odd
21:05konr(and doesn't show up the "Hello World" window)
21:05tomojthat means (JFrame. "Hello") is null
21:05tomojis that even possible?
21:05konrlet me comment everything else...
21:06tomojdoto is supposed to return the thing the stuff is done to
21:07konrhmm, it's not returning anything
21:07tomojdo you have a repl?
21:07konryes
21:07tomoj(JFrame. "Hello") just returns nil?
21:10konrnope, 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:10tomojok, so something is wrong with the doto
21:10tomojit should return whatever (JFrame. "Hello") returns
21:11konrhmmm, apparently it is the "(.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)" line
21:11tomojthat's probably a bad idea anyway, I'd think
21:12tomojif you're running this in a long-running clojure session in the background
21:13tomojit works in my slime repl though
21:14tomojbut then if I close the window, slime dies
21:14konrhmmm
21:23konris anybody using vimclojure?
21:23peregrine81konr: I was wondering the same thing
21:25konrperegrine81: haha, how do you deal with namespaces? it seems that after I eval a (ns) form with \et, *ns* doesn't change
21:26peregrine81konr: I've never actually used it I was looking more for reviews/opinions
21:26konrperegrine81: hmmm, it is pretty good. Much better than the similar plugins for common lisp
21:29tomojkonr: maybe try doing (in-ns 'whatever.whatever) first
21:29tomojin the repl or with \et I guess, not sure how vimclojure works
21:30tomojand by first I mean second
21:32Knekkquickest way to check if elem is a member in list?
21:33dreish(some #{elem} list)
21:34Knekkthanks
21:35tomojdo lists return true for contains? ever?
21:35konrtomoj: 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:36dreishtomoj: If you mean (.contains '(1 2 3) 2), yes, that works too.
21:36tomojno, I meant contains?
21:36tomoj(contains? '(1 2 3) 1) is false
21:36paulphello 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:37dreishtomoj: No, it will fall through the if/else if/else if/... in Rt.contains() and return false.
21:37dreishRT.contains(), that is.
21:38tomojah
21:38tomojseems kinda strange t ome
21:38tomoj(contains? #{1 2 3} 1) is true
21:39dreishYes, I might have had it throw an exception if given a non-indexable object.
21:39tomojor at least explain in the docs what "non-indexable" means :)
21:40tomojoh, it sortof hints at the fact that it doesn't work for lists
21:40tomojsince it says constant/log time
21:45konrshouldn't the clojure server have a single *ns* variable?
21:46dreishpaulp: 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:46paulpyeah, that's kind of cheating though, just bytecode reuse.
21:47paulpI was hoping to tackle some kind of scala problem I can't handle with scala proper, metaprogramming maybe.
21:47dreishIs it just me, or is github.com heavily broken a lot lately?
21:47paulpdreish: it is not just you.
21:47dreishThat's a relief. I've been getting server errors for at least a week trying to look at the Clojure network graph.
21:47dreishThought maybe I was clicking it the wrong way.
21:48paulpI'm sitting here unable to get the clojure source, making me sad
21:48paulpand I pay github, too.
21:48dreishOkay, it's all over the twitterwebs.
21:49paulpthe irony of github bringing a single point of failure to git never ceases to amuse
21:51dreishLooks like it went down about 4-5 hours ago.
21:52paulpwtf github gentlemen!
22:21peregrine81So is pragmatic programmer: Clojure a good place to start for a first time lisper?
22:37Chouserperegrine81: yeah, about as good as there is at the moment.
23:20konrI must change the namespace with (ns *args*), right?
23:25Chouseror 'in-ns'
23:43konris the *ns* variable something contained inside each package, ie, with a foo/*ns* and a bar/*ns*?
23:51Chouserno, it's clojure.core/*ns*
23:51Chouser,(var *ns*)
23:51Chouseroh, no clojurebot. anyway, paste that in a repl to see the full name of a the var *ns*
23:52konrhmmm, it's strange. I have two repls connected to a server, and each of them has a different value of *ns*
23:53konrwhen I change *ns* in one of them, shouldn't *ns* change globally?
23:54tomojhow do you connect a repl to some running clojure code?
23:54Chouservars can have thread-local values
23:55Chouserso if the server has one thread per connection, they'd be independant of each other.
23:55Chouseror it could be doing something else to keep the two repls from messing each other up.
23:58tomojah, clojure.contrib.server-socket looks helpful
23:58konrtomoj: I'm using vimclojure... you can start as many repls as you'd like
23:58tomojyeah, your question just reminded me of that question
23:58konrthe strange thing is that user/foobar is the same for all of them