#clojure logs

2008-10-30

00:00Chousersure. I'm off to bed. Have a pleasant evening.
00:01_sohail_you too
01:17scgilardiI'd like to get a list of files in a directory in classpath. I know a classpath-relative path but not an absolute path. It occurred to me to use findResource, but (.findResource (clojure.lang.RT/baseLoader) "clojure/contrib/sql/sql.clj") returns nil at the same time as (.getResourceAsStream (clojure.lang.RT/baseLoader) "clojure/contrib/sql/sql.clj") returns a stream. That confuses me.
05:45AWizzArdMoinsen
05:49asbjxrnSomething changed in the macro code recently?
05:54asbjxrnI used to have a macro (defmacro foo [& funcs] `(bar ~(fn [] ~@funcs)))
05:54asbjxrnThat now throws an exception: "Can't embed unreadable object in code: "
05:55H4nsasbjxrn: does not look right to my (untrained) eye anyway
05:55H4nsthe first ~ unquotes the whole (fn...) form, so the additional unquote is invalid and the error message makes sense.
05:56asbjxrnTrue that.
06:00asbjxrnIt did end up doing what I wanted it to do, though. Haven't managed in the new svn release.
06:01H4nswhat do you want that to do?
06:05asbjxrnWell, "bar" puts that func into a hash, later in a rendering function I pull that function out again (after binding some variables like mouse position), and evaluate it.
06:06H4nswhy do you unquote the (fn...) form?
06:06asbjxrnThe trick is that if I call (foo (line 0 0 mouseX mouseY)), mouseX and mouseY is not valid outside the rendering function.
06:06asbjxrnGood question. I wrote this quite a while ago.. :)
06:07asbjxrnThat's my only defense :-/
06:07jdzasbjxrn: are you sure you veed macros at all?
06:07jdzneed even
06:07asbjxrnYes, otherwise mouseX and mouseY will be evaluated when I call foo.
06:08jdzwell, that's because you are using macros...
06:08jdzasbjxrn: i'm pretty sure that what you do can easily be done using functions...
06:09asbjxrnI'm pretty sure it can't :)
06:09jdzyou just stuff appropriate functions in your map and then call them, passing all necessary parameters
06:10jdzthe less context-dependent your functions are the happier you will become in the future. trust me.
06:11asbjxrnImagine (on-mouse-click (background 0) (stroke 200 100 100) (line 0 0 mouseX mouseY))
06:11jdzimagine (on-mouse-click [mX mY] (background 0) (stroke 200 100 100) (line 0 0 mX mY))
06:12H4nsor (on-mouse-click (background 0) (stroke 200 100 100) (line 0 0 (:mouseX *context*) (:mouseY *context*))
06:13H4nsi fully agree that capturing random names in macros is generally bad style.
06:13jdzH4ns: i'd still prefer my approach :)
06:14H4nsjdz: less extensible, requires knowledge of the function signature at the call site.
06:14H4nsjdz: what if there is a mouseZ available? change all the callers? not nice.
06:14jdznot really
06:14jdzimagine (on-mouse-click [mX :mouseX mY :mouseY] (background 0) (stroke 200 100 100) (line 0 0 mX mY))
06:15asbjxrnH4ns: How do you stop (:mouseX *context*) from being called when you call (on-mouse-click)?
06:15H4nsjdz: different, but repetetive
06:15H4nsasbjxrn: #(...)
06:15jdzi consider magic *context* ugly. but that may be just me.
06:15H4nsjdz: it is not magic, it is just context.
06:15asbjxrnMy on-mouse-click is a macro that puts the commands in place.
06:16jdzasbjxrn: i'm trying to convince you that on-mouse-click does not have to be a macro
06:16H4nsasbjxrn: well. remove the first tilde and don't listen to us.
06:16asbjxrnThink scripting language.
06:16asbjxrn(def panel 100 100 (background 0))
06:16H4nsasbjxrn: first rule of using macros: don't
06:17asbjxrn(draw-fun (line-width 10) (ellipse 0 0 mouseX mouseY))
06:19asbjxrnjdz: Two problems: in draw-fun I want to be able to combine functions.
06:20asbjxrnjdz: I have many variables, mouse positions, key pressed, size of window etc.
06:20H4nsasbjxrn: what prevents you from creating an anonymous function with #()?
06:20asbjxrnTo require the function to accept all the variables is messy.
06:20H4nsasbjxrn: yes - that is why i would propose using _one_ instead of multiple special variables, and name the special variable according to the convention
06:21H4nsasbjxrn: that way, you'll just script your gui in clojure rather than inventing something new, with funny capturing semantics
06:23asbjxrnNot quite as clean, though...
06:23jdzi claim that making functions depend only on their parameters is a good thing.
06:24H4nsjdz: it is generally a good thing, which does not automatically make passing context in special variables a bad thing. one just needs a good reason to do so.
06:24jdzthat's what makes them parallelization-friendly
06:24H4nsjdz: convenience can be such a good reason.
06:24H4nsasbjxrn: i'm not sure if i want to discuss "clean"
06:24H4nsoh, well, yes, i am sure. i do not want to discuss "clean"
06:25asbjxrn:-)
06:25jdzyeah, i'd consider my proposed approach much cleaner than asbjxrn's :
06:26asbjxrnSure, from a theoretical point of view.
06:27jdzasbjxrn: nope, on the most practical point of view.
06:27jdzwhich is code maintenance
06:28asbjxrnI wrote this inspired by processing.
06:28asbjxrnI wanted something similar for the user point of view.
06:28asbjxrnWhich means the user first sets up a window with (setup 100 100)
06:29asbjxrnthen uses macros like (draw (background 0) (line 10 10 100 100) (whatever))
06:29asbjxrnand (on-mouse-move (line pmousex pmouseY mouseX mouseY))
06:30asbjxrnAnd things immediately gets updated in the window.
06:30jdzthere are only two things that change when mouse is moved. and making those things explicit is a good thing.
06:31jdzor even more -- the code that responds to mouse move event only wants two things from the event, and depends only on those two.
06:31jdzso only those two should appear in the code
06:31jdzif code depends on more, well, then make those explicit, too.
06:32jdzi think CLX does it this way
06:33H4nsjdz: if i understand things right, asbjxrn wants to create something that is easy to use for beginners, failing to recognize that beginners will eventually become experts and then recognize that with the apparent simplicity comes bad design.
06:33jdzasbjxrn: so you either set your goal to be as close to Processing API as possible, or make it distinct enough so people don't come up with wrong expectations.
06:34jdzH4ns: this is not the first time when our understanding is very similar. have i seen you on #lisp maybe? :)
06:34H4nsjdz: not entirely impossible :)
06:35jdzyay, double negatives.
06:35asbjxrnH4ns: there are limitations of course. You can't override the pre-defined variables. And yes, simplicity is the goal here.
06:36jdzasbjxrn: the point is thas this simplicity is superficial, and it comes at a cost.
06:36H4nsthink php
06:36jdzand it breaks down when users become advanced enough
06:37jdzand you lose flexibility
06:45asbjxrnH4ns: Just using anonymous function worked
06:47asbjxrnCan't remember why I ended up with that extra ~ back when
06:50asbjxrnActually, that was only in my setup macro which requires extra stuff (size of window mostly) . my draw/mouse/keyboard stuff just uses anonymous functions.
06:56Chousukehttp://wordwarvi.sourceforge.net/ :D
07:00Chousuke(maybe someone needs to make an emacs version)
08:24Lau_of_DKAfternoon guys
08:25Lau_of_DKIve noticed that JEditorPane reads Html just about as well as I read Russian - What are my alternatives?
08:26duck1123alternatives for reading HTML?
08:26Lau_of_DKFor rendering it in a Swing app
08:27duck1123ahh, I've never much used Swing, so I'm no help
08:28jdzthere is something that can render html
08:28jdzi'm sure i saw an exapmle of it in the mailing list or somewhere related to documentation lookup
08:28jdzwith code!
08:29H4nsjavax.swing.text.HTMLEditorKit should do
08:30Lau_of_DKI'll try to look into it
08:30asbjxrnH4ns: You just beat me to it.
08:30Lau_of_DKThanks guy
08:30Lau_of_DKs
08:31asbjxrnA google found this somewhat old, but maybe interesting lead:
08:31asbjxrnhttp://today.java.net/pub/a/today/2004/05/24/html-pt1.html#The_Swing_HTMLEditorKit
08:32asbjxrnCouple of links in the comments as well.
08:33cemerickLau_of_DK: you can hook in a native browser component to render HTML in a swing app. JDIC is the name of the corresponding, project, I think.
08:35duck1123so using a component like JLabel doesn't work very well
09:55Lau_of_DKasbjxrn, cemerick : Thanks! :)
10:02gnuvincehttp://lispy.wordpress.com/2008/10/25/lisp50-notes-part-vi-the-future-of-lisp/
10:02gnuvinceThat posts almost makes a savior out of Rich :)
10:09abrooksgnuvince: BTW, nice blog post. Is there an email address where you'd like me to send feedback? (Note, this channel is logged and indexed by Google so anti-spamify accordingly...)
10:10abrooksgnuvince: "nice blog post" == your post from last night.
10:11AWizzArdLau_of_DK: is Jambi enough to bring Qt closer to Clojure?
10:12gnuvinceabrooks: vfoley@gmail.com
10:12duck1123I really hope that talk makes it onto blip.tv
10:13AWizzArdduck1123: what talk?
10:13gnuvinceabrooks: I'm interested in all types of comments. I'm not a native English speaker, so notes on the language are fine, notes about the Clojure style are fine, etc. Chouser already suggested that I look into line-seq, which is really nice.
10:13duck1123the lisp50 talk
10:13gnuvinceAWizzArd: the Lisp50 talk.
10:13duck1123everythink I've heard about it says it was great
10:15Chousukeit sucks though that in most of the recorded talks it's impossible to hear the questions asked :/
10:15abrooksgnuvince: Thanks. I'll get back to you later tonight (GMT-5).
10:15abrookstomhickey did a nice job of transcribing the questions for the Boston Lisper's talk.
10:16gnuvinceabrooks: thanks a lot.
10:22Chousergnuvince: your English was perfect.
10:23Chousergnuvince: native language is French?
10:23gnuvinceYes.
10:24Chouserhave you considered blogging about Clojure in French? I imagine there are plenty of non-English speakers who might be interested in Clojure but have far fewer resources at hand.
10:28leafwdoes line-seq close the reader and thus releases the file handler when done?
10:28leafwi.e. when all lines have been read.
10:29leafwand does it cache lines already read? I guess it does--would be nice to have a version that doesn't.
10:30Chouserif you don't hang onto the head of the seq, I don't think it'll keep the lines in memory.
10:31Chouserline-seq does not close the file, you have to open and close it yourself.
10:32gnuvinceChouser: I do want to make a blog post to present Clojure in French. I don't think I'll do the tutorial in French though, most good French programmers speak English.
10:32Chouserrhickey has mentioned before that there's a general issue of cleaning up after seqs over stateful objects (like open files) -- right now it's all manual and therefore error-prone
10:32Chousergnuvince: ok
10:33gnuvinceBut a high level introduction to the language is definitely in my plans.
10:37Lau_of_DKAWizzArd, http://paste.lisp.org/display/66213 <-- This combined with Jambi brings Qt a whole lot closer, but there is still considerable ground to cover
10:38AWizzArdDoes it look like a few days-weeks of work? Or more in the area of 5+ months?
10:39Lau_of_DKI cant really say. So far it looks like open roads ahead, with some Qt exploration involved. But 'the unexpected' might pop its head up more than a few times. But I'll let you know once I make some head-way
10:40wwmorgan_what's wrong with Jambi?
10:40ChouserIsn't Jambi just another Java lib? Can't you just use it?
10:41Lau_of_DKChouser, there's no 'just' about it from where Im standing
10:42Lau_of_DKAnyway, Im away for a few minz/hours, if you have the time, please lisp-paste an example of a Qt GUI app, designed in 'designer' running from Clojure, I'd be ever so happy :)
10:42kib2gnuvince: I would be glad to read your tuts, even in French !
10:44gnuvincekib2: you speak French?
10:44kib2I'am French, and I'm currently learning Clojure
10:44gnuvinceCool
10:45gnuvinceNew Now Know How...
10:45gnuvinceHave you ever been in #programmeur?
10:45kib2never...worth a look ?
10:46kib2I've started something to write a Clojure tutorial (a Qt app, but in Python sorry :)) : http://www.flickr.com/photos/kib2/2984219379/sizes/l/
10:54leafwquestion about namespaces
10:54leafwif I was to add or overwrite a function in an existing namespace,
10:55leafwwhat would one do: (in-ns 'inspector) ... then define whatever function, which would be then under inspector namespace?
10:55gnuvinceIt's not a bad place, some knowledgeable people, mostly C and C++ programmers, I'm the only one with any interest in functional languages. It's about 2/3 Quebecers, 1/3 European with the occasional guy from Morocco
10:55leafwthat didn't work.
10:56scottjI'm trying to use the sql contrib with MS SQL Server. I downloaded sqljdbc.jar and put that in the classpath, now I' defining my db variable and I set :classname to "com.microsoft.sqlserver.jdbc.SQLServerDriver" and :subprotocol to "sqlserver" but what should :subname be? and where do I put the server name, user name, password, and database name?
10:57Chouserleafw: in what way did it not work?
10:58leafwjava.lang.Exception: Unable to resolve symbol: binding in this context (NO_SOURCE_FILE:1) at clojure.lang.Compiler.analyze(Compiler.java:3814)
10:58leafwand so on.
10:58leafwI guess my interpreter messed it up. Never mind
10:58leafwwill have to come up with a better strategy to catch clojure's output for print into a REPL
10:58leafwI am currnelyt using (binding *out* <any entered text here> )
10:59wwmorgan_leafw: in general, prefer the ns macro to explicit in-ns, use, etc
10:59wwmorgan_in your case, the ns macro would have done the clojure/refer for you
11:00Chouserbut the inspector namespace should already have names like "binding" in it.
11:01duck1123scottj: I know for mysql, I had to set :subname to "//localhost/dbname"
11:01Chouserscottj: I don't know what you mean by "db variable". My one experiment with db work in clojure, I used java.sql.DriverManager/getConnection
11:02duck1123and then just add in :user and :password, anything it doesn't recognize gets added as query params
11:02leafwwwmorgan_: so you'd use (ns 'inspector) instead
11:02wwmorgan_chouser: hmm. Perhaps he was doing (in-ns 'inspector) instead of (in-ns 'clojure.inspector), or he hadn't loaded inspector.clj
11:02Chouserwwmorgan_: oh! both excellent points.
11:03wwmorgan_leafw: (ns clojure.inspector (:use (clojure inspector))) works for me
11:06leafwthanks.
11:37brainusHello there. Why wouldn't {:['a' 'b'] 2} work? I am trying to use a small vector a key.
11:38Chouser'a' doesn't make sense. you can use either a string "a" or a character \a
11:39gnuvincebrainus: {["a" "b"] 2}
11:39Chouseroh, and :[] doesn't make sense. a vector is a fine key [\a \b]
11:40brainusah, excellent. thanks.
11:40djpowellIf I wanted to create map keys that have metadata, then I can't use keywords, but would functions like this be reasonable: (defn #^{:doc "A persons first name"} field-first-name [o] (o field-first-name)) - it would then work as both (field-first-name obj) and (obj field-first-name) like keywords do
11:41djpowellI guess a macro would make it easier to create such fn keywords
11:42Chouserdjpowell: interesting idea!
11:43ChouserI'd never thought of it. I guess you're right -- it would work.
11:43Chouserthe map would print kinda ugly.
11:43djpowellyeah, that is true
11:43duck1123then you just have to make a macro to make it easier to create those
11:45djpowelli hadn't thought about them not printing nicely though, that would suck
11:50Chouseryou could add a new print-method to handle fns that prints just their name if they have some kind of metadata flag. :-)
11:51ChouserThis is all to put a bit of documentation on a map key?
11:51Chousukecan't you put the documentation on the map itself?
11:53lisppaste8Chouser pasted "QtJambi with UI via designer, for Lau_of_DK" at http://paste.lisp.org/display/69450
11:54Lau_of_DKChouser, will you please stop by DK so I can give you a kiss ?
11:56Chouserit could clearly use a couple helper functions, but I don't see any huge multi-week issue lurking there.
12:05djpowellhmm, actually, regarding the fns as keywords idea, you can get the same functionality just by using symbols, and it prints nice too
12:07djpowell(def #^{:doc "A persons last name"} field-last-name) ; (def m1 {'field-last-name "Dave"}) ; (m1 'field-last-name)
12:10djpowellI hadn't realised that invoking a symbol calls get on its argument
12:11Chouserdjpowell: yeah, just like keyword. Looks funny to me, though.
12:12Chousukeyou can also do (def field-last-name 'field-last-name) and then (field-last-name m1) :P
12:14ChouserChousuke: oh, that's wild.
12:14Chousukekind of circular. a var whose value is the symbol that names the var.
12:17drewrdjpowell: You don't need semicolons. :-)
12:18djpowellha, i know
12:18djpowellChousuke: a bit like my earlier example, a function whose definition calls get on a map with the function as the key
12:19Chousukewell, a symbol appears to be such a function. :)
12:20Chouserplus this lets you redef field-last-name later, to completely screw with access to your map
12:20Chousukeheh
12:25Chousukedoing the (def foo 'foo) makes foo basically a keyword without the :. it evals to itself.
12:26djpowellyeah, but it is mutable, which isn't really desirable
12:31ChousukeHm, well, t's basically an accessor function for the map. Most functions are redefinable -- whoever does so for anything important is in no position to complain, though.
12:33Chouserthe lookup will go through an extra step of indirection (the var) compared to using a literal symbol or keyword.
12:50djpowelli was thinking that the var would be in the map, but it will resolved to the symbol at the point of assoc-ing, and get-ing
13:20kib2I've made a Pastebin for Clojure : http://clojurepastebin.appspot.com/
13:33djpowellHmm, is it possible to create a macro that expands to something like: (def #^{:doc x} y 123) or equivalent?
13:35djpowellI'm thinking that I might be getting into trouble with #^ being reader syntax, but I can't use with-meta, because def requires an actual literal symbol as it's first argument
13:41djpowellI can't see how to generate '(def #^{:doc "test"} x 4)' with a macro because I can't quote #^, and '(def (with-meta (symbol "x") {:doc "test"}) 4)' isn't valid syntax for def
13:55wwmorgan_djpowell: check out the source of def.clj in clojure-contrib to see how they do it
13:59djpowellah, thanks
14:17AWizzArdWas there something experimental that allows me to have something like a callback function that is called after an agent has finished?
14:20ChouserAWizzArd: there's (agent state validate-fn)
14:20AWizzArdoki, let me check if that is what I had in mind
14:20Chouserbut that's not supposted to have side-effects
14:24AWizzArdWhat could happen if it had site-effects?
14:25ChouserAWizzArd: dunno, but it's a mis-use of the feature.
14:25Chouseroh, you might actually want add-watch
14:26AWizzArdah yes, that was it
14:37AWizzArdRight now there is nothing like (list-all-watchers-of agent) yes?
14:42Chouserlooks like watchers is private and I don't see an accessor
14:42Chouserof course you could have a convention of tossing each watcher into the metadata somewhere or something.
14:43AWizzArdright
14:43AWizzArdChouser: btw, what is the watcher supposed to do? Why do I add a watcher and a callback? Wouldn't the callback be enough?
14:44AWizzArdThe callback functions has 3 parameters of which one is the watcher which could in principle be called from within the callback
14:45ChouserAWizzArd: hm, not sure. I've never used add-watch.
14:47ChouserAWizzArd: perhaps it's so you can re-use the same callback function for multiple watchers?
14:47AWizzArdthat could be possible.. but still the question stays what those two guys will be doing
14:48Chouserthe callback is a fn, the watcher appears to be just any old value you want.
14:48AWizzArdThe role of the watcher is not so clear to me right now.
14:48AWizzArdHmm yes, the watcher could be any 1st class object it seems
14:48ChouserIt's used as an id, a handle for use when you remove for example
14:48gnuvinceChouser: I've updated my blog post draft with the comments you made. Using line-seq made the program more succinct and easier to explain.
14:49Chousergnuvince: ok, great.
14:51gnuvinceI'll wait to hear from abrooks tonight before I post.
14:52cemerickrhickey: did you have any reaction of note to my suggestion w.r.t. user.clj? http://groups.google.com/group/clojure/browse_thread/thread/6951a19912adfb8a
14:54rhickeycemerick: NB is being overly pedantic there, and many have complained. The idea behind user.clj is to be pretty easy, getting involved in nested classpath could negate that. These just first thoughts, I haven't decided anything yet
14:59cemerickrhickey: Yeah, I agree on both points. I was thinking that perhaps a .clojure file in the home directory would be a good possibility (which would also break the illusion that user.clj is a good place to put startup initialization code, etc)
15:14AWizzArdBtw, the callback function that you add with (add-watcher agent watcher callback) does not need to have three parameters. As this runs in the same thread as the function we sent to the agent it means that *agent* is bound already correctly.
15:37AWizzArdhttp://clojure.org/data_structures#toc81 says that ArrayMaps will maintain keys in order. But when associng/conjing more data to it might make it become a hash-map.
15:38AWizzArdSo, what is the 'maintains key order' part then?
15:38AWizzArdWould not any map that stays unchanged keep its order?
15:41Chousercompare (hash-map :a 1 :b 2 :c 3) and (array-map :a 1 :b 2 :c 3)
15:41Chouserarray-map guarantees that a seq over it will get keys in the order you gave when you constructed it. Not so with hash-map.
15:43AWizzArdTree Maps for example stay sorted even when I assoc new stuff onto it.. that's why I was wondering
15:45Chouseryes, but that's in sorted order not necessarily original order. compare (sorted-map :c 1 :b 2 :a 3) and (array-map :c 1 :b 2 :a 3)
15:46AWizzArdSure, I understand the difference. I just thought that array maps will keep the order even when you assoc new elements later
15:51Chousukemaybe clojure is trying to save you from doing stupidly inefficient things with the map :/
15:52drewrHm, cast doesn't do what I thought.
15:52Chousercast does hardly anything.
15:53drewrI'm getting an interface back from a factory, but I need the concrete class.
15:53Chouseryou can't have an instance of an interface.
15:54Chouseryou can use (class ...) on it to see what it really is.
15:54drewrI'm getting a com.sun.org.apache.xerces.internal.dom.ElementImpl, but I need to cast it to a org.w3c.dom.Element.
15:56drewrAt least I think so.
15:56Chousukeis Element the interface? or what.
15:56ChouserHave you tried just using it?
15:57drewrI'm trying to .appendChild on a DocumentImpl and it says the node can't be inserted there.
15:57drewrFrom what I can determine, HIERARCHY_REQUEST_ERR occurs when the node isn't the right type.
15:57drewrYes, Element is the interface.
15:57drewrHere's the code I'm trying to clj-ize: http://www.rgagnon.com/javadetails/java-0511.html
15:59drewrNot wholesale, just trying to mimic the xml creation for a different purpose.
16:02Chouserdrewr: don't you need an Element instead of a Document?
16:02AWizzArdAnd btw, why xml? ;-)
16:03AWizzArdYou can store your data trees directly as s-expressions
16:03Chousukedrewr: can you show the code you have now?
16:04lisppaste8drewr pasted "xml generation" at http://paste.lisp.org/display/69465
16:05drewrAWizzArd: True, but I'm not sure I'll be able to use the reader to read it back.
16:06Chouserdrewr: that worked for me
16:06drewrHm.
16:06drewrAh, I get that error when I try to append another.
16:07AWizzArddrewr: the Clojure reader has no side effects... unlike CLs reader it does not intern stuff that it reads
16:08drewrChouser: And then xml is #=(com.sun.org.apache.xerces.internal.dom.DocumentImpl. "[#document: null]")
16:08drewrWhy null?
16:09Chouserdrewr: you can only have one element in a document
16:09Chouserthat element (the "document element") can have any number of children
16:09drewrAh, good call.
16:09Chouserso trying to add a second element to the document is failing for you
16:10Chouser(.getDocumentElement xml) shows the one element you added
16:10Chousernot sure what the "null" is about -- that's the Java object's toString method producing it.
16:11ReplRatIs there a JSON reader and printer?
16:11drewrReplRat: I've played with the json-lib, and it's OK.
16:12ReplRatdrewr: where is it? i didn't see it on Google.
16:12drewrBut it didn't serialize java.sql.Timestamps correctly.
16:12drewrhttp://json-lib.sourceforge.net/usage.html
16:13ReplRatah. I keep forgetting to look for Java libs instead of Clojure libs.
16:13drewrI should be able to attach a custom processor to the JsonConfig, but I lost interest by that point.
16:17abrooksI'm trying to transform a list of lists of three items ((1 2 3)(4 5 6)(7 8 9)...) into three lists ((1 4 7 ...)(2 5 8 ...)(3 6 9 ...)).
16:17abrooksI need a chart visually showing some of the seq transform functions.
16:18abrooksMy brain gets stuck trying to remember them all.
16:18drewrThat's a great idea.
16:18abrooksAh... Hm. I could do this with lazy-cat.
16:19Chouserapply map list
16:19Chouser(apply map list foo)
16:20abrooksI tried thinking through this with (apply map list foo) but it didn't work in my head. Maybe my brain is broken.
16:21gnuvinceChouser: crazy trick!
16:21abrooksIt works but I still am not thinking about it right.
16:21gnuvinceI tried to find how to do exactly this last weekend.
16:21abrooksChouser: Thanks. :)
16:21gnuvinceI was toying with (apply #(map list %&) xss)
16:22gnuvinceDidn't work<
16:22Chouserabrooks: I'm beginning to think a flowchart or something like it might work as well as the grid we were trying to build.
16:22Chouserfor many of these tricky problems, there are actually not many tools that will work.
16:23AWizzArdIf you can wait from time to time for cgrand you can get often extremly nice solutions :-)
16:23Chouserfor example, trying to talk through multiple lists in parallel -- pretty much just "map" I think. "for" won't do it (it nests instead). most of the other seq functions only take one seq.
16:23ChouserAWizzArd: heh, exactly.
16:25Chouserso with map, you now have the right numbers, but they're args not a list. I've tried to use "identity" in such circumstances, but of course identity only wants one arg. "list" or "vector" do what you want.
16:25Chouserand finally you need apply if you're given a list of lists so that map can get at them.
16:30abrooksChouser: A flow chart! Nice.
16:31abrooksChouser: A seq transform expert system! :-D
16:31Chouserright
16:32Chouser"is your input a single seq, or multiple" "is your input seq made up only of seqs" ...
16:32Chouserbut since an actual expert system of flow chart would get bogged down in ridiculous details and corner cases, I'm thinking perhaps a blog post.
16:33abrooksDoes your data structure have a spinal chord? -> Chordates...
16:33gnuvinceSPINAL TAP!
16:33abrookser.. cord.
16:33abrooksgnuvince: Heh!
16:35abrooksChouser: You bring up another point that I had sort of been thinking of which is sort of a catch-phrase list. parallel-lists -> [maps], folding -> [partition, for], nesting -> [for], etc..
16:36abrooksI guess that's sort of what we were trying to do in the spreadsheet but this notion was allowing for looser defined categories.
16:37ChouserI'm sympathetic with the idea that the spreadsheets categories might be too narrow.
16:38abrooksI think the fundamental taxonomy of the operations is too subtle to be useful. Going with a small handfull of generalities probably starts you in the proper direction.
16:42AWizzArdDo we have the enclojure developer here?
16:50Chouserthat whole team is apparently swamped until after the election.
17:04PupenoHello.
17:04PupenoIs there any particular moment when setting swank-clojure-extra-classpaths has an effect?
17:11AWizzArdDoes (seq col) create a fresh list of all items in col? Or does it use some internal tricks on the java side to produce something that for me as a user looks like a list? I ask because seq returns extremly fast, and it seems to be not lazy.
17:12Chouserseq never copies any underlying collection. Usually it creates a new object that acts as a view on some other object.
17:13AWizzArdOkay, so this is what I meant by "trick"
17:16Chousera notable exception is PersistentList, which itself implements ISeq. So calling seq on a list just returns the very same list.
17:17AWizzArdyes
17:18Chousukevectors don't seem to implement ISeq :/
17:18Chousukeis there a reason for that?
17:20ChouserYeah, it wouldn't be natural. But you can call seq on a vector and get a APersistentVector$Seq
17:23gnuvince_What's the significance of the $?
17:23kotarakNested class
17:24ChouserIn Java source code that looks like APersistentVector.Seq, but APersistentVector is a class not a package so the internal name uses a $ instead of a dot
17:25Chouseryou see it in some exceptions, in .class file name, and in Clojure.
17:26ReplRatIs there a Clojure wiki that anyone can edit?
17:26Lau_of_DKHow do I test i a symbol has previously been declared?
17:27ChouserReplRat: wiki link on clojure.org
17:27wwmorgan_Lau_of_DK: (resolve 'foo)
17:27Lau_of_DKwwmorgan_, thanks
18:05Chousukehmm
18:07kotaraksosososo
18:08ChousukeI'm trying to figure out a neat way to implement a version of partition that keeps the remainder, but my best (working) attempt so far uses reverse which isn't optimal :/
18:09ReplRatwould it be possible (or desirable) to implement a condition/restart system like CL's in closure? I'd like, for example, to say what happens when a undefined symbol is evaluated.
18:09Chousukehm, I should be more careful too... 41884 java 176.7% 36:43.44 20 555 207 77M 37M 87M 259M
18:19gnuvince_Chousuke: something like this?
18:19gnuvince_user=> (my-partition 4 (range 10))
18:19gnuvince_((0 1 2 3) (4 5 6 7) (8 9))
18:21Chousukegnuvince_: yeah
18:21gnuvince_here's the code
18:21gnuvince_<mini-flood>
18:21gnuvince_(defn my-partition [n xs]
18:21gnuvince_ (when (seq xs)
18:21gnuvince_ (lazy-cons (take n xs)
18:21gnuvince_ (my-partition n (drop n xs)))))
18:21gnuvince_</mini-flood>
18:22ChousukeI'm pretty sure I tried that :/
18:22ChousukeI wonder what I did wrong
18:22gnuvince_Don't beat yourself too much, it was probably a little detail you forgot.
18:23gnuvince_That happens to me all the time.
18:28AWizzArdwell, humans suck at programming
18:28Chousukeah, I know what I did
18:28AWizzArdIt's time we let our computers do that for us :-)
18:28ChousukeI forgot the (when (seq coll) ...
18:29gnuvince_Chousuke: ah :)
18:30gnuvince_AWizzArd: you saw the movie "Eagle Eye", haven't you?
18:30AWizzArdhmm, maybe
18:30AWizzArdI usually forget movies fast after I saw them
18:31gnuvince_AWizzArd: it's in theaters now, it's about an AI that goes rogue
18:31gnuvince_(how original...)
18:36AWizzArdMaybe we all are AIs that go rogue from time to time. I personally plan to use Clojure extensively for AI programming.
18:37AWizzArdI should try to make a bot which can outperform wwmorgan_ who also seems to be some kind of bot. You ask a question about what a function is called, and the moment you press enter you can already see his answer.
18:37gnuvince_AWizzArd: are you very busy at the moment?
18:37AWizzArdnot very
18:38gnuvince_Would you mind reading a draft of a blog post I made on Clojure? It's the first part of a small tutorial, and I want to get input from the people here to make sure it's OK.
18:38AWizzArdsure
18:39kib2gnuvince : sure :)
18:39gnuvince_http://fornost.homeip.net:81/vince/clojure-comics1.html
18:39gnuvince_Here it is
18:39gnuvince_you can send comments at vfoley@gmail.com
18:39cemerickenclojure users: I just posted to the enclojure google group a rough patch to enclojure's head that adds support for multiple remote REPLs. If you are so brave as to try it, I welcome feedback/suggestions, mostly because I'm groping through the dark on a number of fronts in that context.
18:52AWizzArdhmm, apropos variables... when we have (def x 1), how much sense does it make to call x a variable?
18:53wwmorgan_sounds fine to me
18:54AWizzArdyes, to me also, because I am used to it
18:55AWizzArdalthough beginners could ask what exactly is variable in it
18:55AWizzArdmaybe a beginner would suggest to call it a constant
18:56wwmorgan_I wouldn't call it a constant
18:57AWizzArd(def pi 3.1....) "The variable pi is used ...."
18:59AWizzArdWell, we need a name for the things that follow after def and variable sounds nice
19:02kib2gnuvince : ping
19:04gnuvince_pong
19:06kib2http://kib2.alwaysdata.net/tempo/gnuvince.html
19:06kib2more readable
19:07AWizzArdkib2: now only put it all into a frame with a width of 800px
19:07AWizzArdso that people with widescreen displays also can read it :-)
19:08gnuvince_kib2: I'll be posting it on Wordpress
19:09kib2AWizzArd: my tool does not do that for the moment, I don't want to modify it by hand :)
19:10kib2gnuvince : I'm going to sleep now, I'll read it in bed and give you a feedback tomorrow, ok ?
19:10gnuvince_kib2: sure thing.
19:10kib2See you
19:10Lau_of_DKAWizzArd, its not fully tested, but it seems that as of now, using the Qt-designer (and its standard widgets only, text-boxes, inputboxes, calendars all thats) you can design a form and run it from clojure, incl. hooking up slots/events.
19:12AWizzArdLau_of_DK: this is good news... I am looking forward to hear what you will find out in the coming weeks about it. Perhaps it really is fully functional already. This would make especially you and a bunch of other people happy. And if not you might have very concrete info what exactly is not working as you wish.
19:16Lau_of_DKAWizzArd, hang on 3 minz, I'll show you something
19:17AWizzArdLau_of_DK: one thing that would be very nice is a step-by-step tutorial that explains how to make a webstart application that you can simply click on a website and get a minimal Qt app that shows "Hello World".
19:19AWizzArdThis would tell how to publish code that you wrote in Clojure so that other people can use it, it would explain how to make a minimal webstart application, and it would also give an example on how to do Qt with Clojure.
19:23Lau_of_DKThats not too far out in the future
19:23Lau_of_DKHave you worked with their designer yet ?
19:24AWizzArdI have no idea what the designer is
19:24Lau_of_DKOk, with this new stuff that Chouser cooked up, we can load ui's designed in the 'designer' directly in Clojure
19:25AWizzArdLau_of_DK: you could download something like http://camstudio.org/ and put a little video on youtube
19:26Lau_of_DKIn 1 minute, I'll show you how to build a webbrowser using the designer
19:26Lau_of_DKIt also has tools for text-boxes with code-highlighting, calendars, video-renderers and so on
19:27Lau_of_DKhttp://www.bestinclass.dk/download/designer.mpeg <-- I appologize for the resolution, go fullscreen
19:31AWizzArdThanks. The designer looks clean and professional.
19:32AWizzArdNow it would be interesting to make a .jar file that a user simply needs to doubleclick
19:32Lau_of_DKIts good stuff - So now once I clear up a little import problem, you can design a gorgeous crossplatform GUI in seconds, with powerful functionality, and drive it directly from clojure
19:32Lau_of_DKThats not a problem
19:33Lau_of_DKThe problem right now is just getting the full functionality of Qt into Clojure
19:33AWizzArdYou can make a tutorial video, with spoken language available on youtube. This could explain it all step by step to total newbies. Some of them might be driven to Clojure by that.
19:34AWizzArdIf it looks easy and colorful people will enjoy it. And hundreds of your watchers will send around their own programmed webbrowser to their friends :-)
19:35AWizzArd"Yeah, I made it. Ima progamer expert in Qt-Closhure"
19:35Lau_of_DKHow about you handle the PR, and I'll put in some more work on the functionality :)
19:36Chousukeheh
19:36AWizzArdyeah, let's think about it
20:18Lau_of_DKAWizzArd, this is what you want right? http://dist.trolltech.com/developer/download/webstart/
20:18AWizzArdyes
20:19AWizzArdI tried that before
20:19Lau_of_DKk
20:19AWizzArdnow only for your 100% Clojure example, a simple hello world
20:19Lau_of_DKk
20:38sohailLau_of_DK, that mpeg.. that's not showing any clojure things is it?
20:46Lau_of_DKNo, its showing the GUI of the designer. With the designer you design a nice form/window/dialog, and that window can be driven from Clojure
20:49sohailLau_of_DK, I see
20:49sohaildoes qt jambi let you use anonymous classes for slots and stuff?
20:49Lau_of_DKyes, with a litle modding made possible by jamii, it actually does
20:49Lau_of_DKWith this much code, you can load a seriously complex GUI
20:49Lau_of_DK(let
20:49Lau_of_DK [ ui (QUiLoader/load (QFile. "code-ui.ui"))]
20:49Lau_of_DK (.show ui)
20:49Lau_of_DK (.connect (.triggered (.findChild ui Object "action_Exit")) ui "close()")
20:49Lau_of_DK (QApplication/setStyle (QStyleFactory/create "Oxygen"))
20:49Lau_of_DK (QApplication/exec)))
20:50Lau_of_DKAnd it will render with Oxygen widgets, which are really pretty :)
20:50Lau_of_DKhttp://paste.lisp.org/display/66041
20:50Lau_of_DKWith this, you can use the slots anonymously
20:51sohailthat's cool
20:51Lau_of_DKyea its extremely cool
20:52sohailI wrote a qt binding for CL that was better but not very portable it seemed :-)
20:52Lau_of_DKOh :) Feel free to paste it
20:52sohailwell better when you used slots anyway... :-)
20:55lisppaste8sohail pasted "qtcl for Lau_of_DK" at http://paste.lisp.org/display/69479
20:56sohailLau_of_DK, I much prefer you doing it for clojure though ;-)
20:56Lau_of_DKDont worry I will, just looking for inspiration
20:57Lau_of_DKI'll have to read through it tomorrow though, we're coming up on 02:00 AM here, which means time for bed - Have a good one all
21:34gnuvince_What's this binding audit thing?
21:36Chouseraudit?
21:37gnuvince_http://richhickey.backpackit.com/pub/1597914
21:39Chouseroh, that. He wants to change doseq, if-let, and such that do bindings to use vectors.
21:39gnuvince_(doseq [e coll] body)?
21:39Chouserexactly.
21:40gnuvince_ok
21:40gnuvince_What about condp and fcase that I keep hearing about?
21:40Chouserso that requires digging through boot.clj to make sure that every single one is covered.
21:41ChouserI don't think those bind any locals.
21:59fbru02hey all ! :) I have a newby question ! :)
21:59fbru02can i shoot them ?
22:01gnuvince_fbru02: shoot away, if somebody has the answer, they will answer.
22:05fbru02ok :) I programmed in python ruby c# and haskell but many of this problems I think it have to do much with lisp notation than with clojure in general but Im learnig clojure .... 1) (defn functioname [ parameter1 & parameter2] ) what does the & stnad for ? and 2) (let x (into #{} x)) #{} stands for creating a set ?
22:07gnuvince_1) the & indicates a rest parameter
22:07gnuvince_Since you know Python, here's something equivalent:
22:07gnuvince_(defn foo [a & b] [a b]) == def foo(a, *b): return [a, b]
22:07fbru02cool
22:08gnuvince_2) yes, #{} is the literal syntax for set.
22:09danlarkingnuvince: actually (defn foo [a & b] [a b]) and def foo(a, *b): return [a, b] aren't exactly the same
22:09danlarkinthey're very similar.. it's the same idea, but they are different
22:09danlarkinin the python one *b will be all arguments passed to foo
22:10danlarkinnot just "the rest" like in clojure
22:10gnuvince_danlarkin: no, it'll be just the rest
22:10gnuvince_>>> def foo(a, *b): return [a, b]
22:10gnuvince_>>> foo(1,2,3,4)
22:10gnuvince_[1, (2, 3, 4)]
22:12danlarkingnuvince_: oops... that's embarassing, I guess you're right.
22:12gnuvince_;-)
22:15fbru02_sorry
22:15gnuvince_uy... is that Uruguay?
22:15fbru02_yes !
22:16fbru02_nice country but we don't have many lispers here :(
22:20fbru02_thanx both one more thing and #(operator % (var1) var2) is syntax sugar for making a lambda function?
22:22Chouseryep: (fn [x] (operator % (var1) var2))
22:22Chousernote you can't use #() instead of a function like: (fn [x] {:foo x})
22:24fbru02_uh , I thouhgt that you didnt have to use put fn[x]
22:25fbru02_ah sorry now I get it : (fn[x] (op % (var1)var2)) == (fn #{op % (var1) var2)) right?
22:27Chouserno, (fn [x] (op x)) == #(op %)
22:27Chouseralso no #{} and #() and #"" all mean different things
22:29fbru02_ah yes we discussed #{} before it was for making a set, what #"" means ?
22:30Chouser#"" is a regular expression literal
22:31Chouserthese are explained at http://clojure.org/reader
22:31fbru02_ok thanks man, I'm goint to hit the bed now I think
22:32Chouser11:30 there?
22:32fbru02_1230 because we are on summertime
22:32Chouserok. sleep well!
22:32fbru02_ok thanks mate , later ! :)
22:40abrooksgnuvince: I am wrapping up looking at your blog post. I started a while ago but got derailed when a friend called. :-/
23:30wwmorganlisppaste8: url
23:30lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
23:33lisppaste8wwmorgan pasted "Good library to do this?" at http://paste.lisp.org/display/69484
23:36bradbev_I'd like to use zip_filter & xml from the contrib package, but keep getting Could not locate Clojure resource on classpath: clojure/contrib/zip_filter/zip_filter.clj. I've manually loaded zip_filter & clojure.xml.
23:37wwmorganbradbev_: try starting clojure with clojure-contrib in your classpath
23:37bradbev_ah, OK...
23:40Chouserwwmorgan: sorry, I've got nuthin' Don't want to roll your own TCP protocol? :-)
23:41wwmorganI don't want to have to worry about _anything_
23:51abrooksHeh. I hadn't seen this: http://www.lisp50.org/schedule/schedule/mccarthy_files/doing-it-wrong.jpg
23:52bradbev_thanks wwmorgan that works.
23:57wwmorganbradbev_: check out the ns macro for a very clean way to handle almost all of your dependencies
23:58bradbev_wwmorgan: I saw that, but didn't click on to needing the classpath correct. I thought just loading the files from slime would get be the right stuff. Do the JAR files contain compiled Clojure code?