#clojure logs

2009-07-01

00:00holmaki'm pretty sure it is
00:00holmaki would be rather surprised if it were _not_ deterministic
00:02durka42it seems to be from left to right
00:02durka42i would like that to always be the case :)
00:03_fulletshttp://clojure.org/evaluation says left to right.
00:05justin`hey guys I'm trying to make program a deck of cards that can deal out cards to players, etc. Is it worth it trying to do this using only immutable data and say, tracking the top card of a deck and moving it down while copying the top card to a players card to deal? or should I keep redefining the deck or should I do something in java? I'm a newb and kinda lost
00:07grrrtif you consider a datastructure containing 1 or more lists of cards, one for each player and one for the deck, you can have a function that operates on that structure
00:08grrrt{:player1 [card1...cardn] :player2 [card1'....cardn'] :dealer [card1"...cardn"]}
00:09grrrtyou could create a function that accepts a structure such as this as its arguments and returns a new one where some cards changed hands
00:09justin`ah and then just, like asoc player1 with (first dealer) and dealer with (rest dealer) to draw?
00:09grrrtyes something like that could work
00:09justin`cool
00:10justin`thanks, taking me awhile to get used to this
00:10grrrtyeah same here actually :)
00:11durka42(next dealer)
00:11justin`ah
00:13durka42rest is now for use only inside lazy seqs
00:13grrrtI didn't know that
00:14grrrtis that for 1.0.0 too?
00:19durka42grrrt: yes as far as i know, it's been the case since lazy
00:19grrrthmm I must admit I haven't kept up with that.
00:19grrrtI should, really
00:48justin`i feel like its going to be extemely difficult to program a card game in functional style
00:49arohnerjustin`: it seems like a deck of cards would just be a vector of cards
00:49arohneror, a ref to a vector of cards
00:49justin`am I just missing something? is it worth pursuing? decks and hands seem to be pretty dependant on state and I'm trying to come up with something but it seems like every new small feature is a huge hurdle
00:50justin`yeah but what if i want to send the top card of the deck to a player's hand?
00:50arohnerthe player's hand is also a ref to a vector of cards
00:50arohneror their hand could be a set
00:50arohnerso then moving a card would be a transaction
00:51justin`hmm
00:52arohner(dosync (let [card (first @deck)] (commute deck (rest %)) (commute hand (conj card %))
00:53justin`ah thanks
00:54arohnerthat probably won't compile, but should give you an idea of what I'm talking about :-)
00:55justin`yeah sort of, at least it gives me some stuff to look up :)
00:55arohnerthe general idea is both the hand and the deck are refs that you alter in the same transaction
00:56arohnertake a card out of the deck and put it in the hand
00:57arohnerHTH, I'm going to bed
00:57justin`thanks have a good one
02:12Lau_of_DKTop of the morning gents
05:27AWizzArdAnyone here who uses jswat successfuly with Clojure? I attached it to my session, opened a file and put a breakpoint into a line where I want the program to stop. The breakpoint is active, but when I call the function that includes it, the program does not pause, and I can't step through it. Ideas?
05:54samwisemHello. I'm trying to write a more complicated 'ns' macro and I'm finding it a little confusing. If I want to use only 'defnk' from clojure.contrib and only 'myfunction' from my.lib, how do I structure my ':use' list?
06:09Chousukesamwisem: something like (:use (clojure.contrib [whatever :only (defnk)] (my [lib :only (myfunction)]))
06:10samwisemok thanks
06:10ChousukeI'm not sure about that though.
06:10Chousukens needs more examples.
06:10samwisemi agree
06:10samwisemis there a rule-of-thumb as to when to use vectors [] and lists () in ns?
06:11Chousukehmm
06:11Chousukewell, a vector is a libspec
06:12samwisemaah that makes sense
06:12Chousukewhile a list is a prefix list, like (clojure.contrib sql monads [dataflow :as dflow])
06:13samwisemok that makes a lot more sense now thanks
06:52dmiles_afki would like to load as a script engine into 3 differnt objects.. i am thinking that each will have a global defined "self" and "parent".. i'd like the various script engines to find each other via the "parent" . 'self' can be defined indevidually right? since i would have 3 instances of clojure right?
06:52dmiles_afkor would i define self lexically and use one engine?
06:53dmiles_afkoops sorry. actually thet will each have differnt definations of the various source functions
06:53dmiles_afkthet/they
06:54dmiles_afkso things like (def (on-chat "from" "text") ..) they might each have a differnt impl of on-caht
08:26achimhi! in case someone hasn't seen it yet: there's a free pragpub pdf mag out, with rhickey interview and stuart halloway on error-kit - http://pragprog.com/magazines
08:27Chouserachim: thanks, didn't know about that.
08:42lpetitHi all
08:50Chouserlpetit: good morning
08:54lpetitChouser : good afternoon (here in France :-) )
08:55lpetitIf I have values in ref and I want to be sure to read a consistent state, is there something better than doing (dosync [@ref1 @ref2]) ?
08:59Chousernope, I think that's it.
09:00Chouserants.clj does essentially that in 'render'
09:01lpetitOk. I thought there was maybe some more performent better primitive
09:01Chouserthat'll run pretty fast.
09:02lpetitsomething like (multi-refer ref1 ref2) that could then return [...] and also conveys some meaning. I think in multi-user apps such as webapps, this idiom (dosync [<many derefs]) is certainly very common ?
09:03lpetitI'm missing clojurebot. Do you know whether someone put an equivalent live REPL accessible via the web ?
09:04Chousernot that I know of.
09:05achimlpetit: maybe http://lotrepls.appspot.com/ ?
09:13rhickeyhttp://www.deucestm.org/
09:13AWizzArdAnyone here who knows how to use JSwat + Clojure? It did not stop at my breakpoints in the previous version I had installed (4.3, now 4.5, and now I have Java 6 Update 14), but this time I even can't set breakpoints anymore.
09:14AWizzArdI can't set breakpoints in jswat and also not in NetBeans.
09:15lpetitachim: thanks
09:33AWizzArdrhickey: do you run Java 6 Update 14 under Windows?
09:34AWizzArdIs it possible that in this Java version debugging Clojure is not possible anymore?
09:34AWizzArdWhen I open .java files in jswat I can set break points. When I open a .clj file this is not possible.
09:42AWizzArdrhickey: do you have jswat 4.5 installed?
09:43rhickeyAWizzArd: no
09:44AWizzArdok
09:53cemerickAWizzArd: there is some known issue with setting breakpoints in some recent update of JDK 6 -- affects the entire jvm IIRC
09:55cemerickheh, Deuce is configurable e.g. @Atomic(retries=64)
09:55cemerickrhickey: they're coming for you ;-)
09:56rhickeycemerick: I'm ready - I don't think the 'just do everything like you used to and wrap in atomic' is going to succeed. Clojure is a big bet that it isn't
09:57cemerickugh, it does runtime instrumentation via -javaagent
09:58rhickeyimmutability is key
10:00cemerickI guess we're going to see a half-dozen STM impls on the jvm/clr. A shame, as there's likely only one right way to do it.
10:16AWizzArdcemerick: do you use update 14?
10:31Chouserwhat a great system -- write obscure and complex clojure code and then wait around for Halloway to document it.
10:32cgrand:-)
10:38samwisemWhy does "(map Integer/parseInt strings)" fail with "unable to find static field", but "(map #(Integer/parseInt %) strings)" work just fine? Do java static methods not count as first-class clojure functions?
10:39Chouserexactly
10:39Chouserjava methods (instance and static) are called via special forms -- they are not first-class functions.
10:40Chouser(macroexpand '(Integer/parseInt x)) ==> (. Integer parseInt x)
10:40samwisemI didn't know '/' was a macro. Thanks for explaining that.
10:40Chouserwell...
10:41samwisemit's a special form?
10:41Chouser<classname>/<static thing> is expanded at macro-expand time.
10:41laz0rhi, just started playing around with clojure, and I am wondering: what is the difference between (),[] and nil?
10:42Chousersamwisem: you can't define your own macros like / so it's not just a regular macro
10:43Chousersamwisem: but on the other hand foo/bar is just a symbol, so if the compiler can't find a matching class/static thing, it'll just leave it as a symbol for later namespace resolution.
10:43laz0ri had a hard time implementing my own reduce function because i used (nil? <somelist>), it always gave me NullPointerExceptions while compiling, I eventually found out that (empty? <somelist>) would do the trick
10:43samwisemok thanks
10:43Chouser(macroexpand '(namespace/foo x)) ==> (namespace/foo x)
10:44Chouserlaz0r: since Clojure has several collection types, it doesn't make sense for 'nil' to mean an empty one of any one of those types
10:44Chouserlaz0r: so nil is its own thing -- it means nothing at all, or Java null.
10:45rhickeyhmm... some stuff from http://clojure.org/lazy should be moved to http://clojure.org/sequences page - seems like some people are having trouble writing lazy-seqs correctly
10:45rhickeyoh, I see it is linked, nm
10:45Chouserlaz0r: [] is an empty vector, () is an empty list, {} is an empty map, etc.
10:45Chouserrhickey: I linked it not very long ago.
10:45rhickeyah
10:46laz0rChouser: ok, i thought [1 2 3] were lists, but if those are vectory, then why does (rest []) produce (), instead of []?
10:47laz0ror nil, which i expected in the first place
10:47Chouserrhickey: someone pointed out there were bad links to nthrest and such, so I fixed those and added a link to "lazy" not quite a week ago.
10:47laz0ri guess () will mean empty for all the different collection types?
10:47Chouserno
10:47rhickeyChouser: ok, thanks!
10:48Chouserlaz0r: most functions that operate on seqs (like first, rest, next, etc.) call 'seq' on their collection argument.
10:49Chouseroops
10:49Chousersorry, not quite right -- 'rest' should not be in that list.
10:50Chouserlaz0r: 'next' does what you'd expect, because (seq []) returns nil, and (next nil) also returns nil.
10:50laz0rmmh, ok
10:51rhickeyChouser: rest calls seq on its argument
10:51laz0rbtw. is there an easy way to look at the source code of the clojure core functions?
10:51rhickeyit doesn't force its return
10:51laz0rlike reduce for example
10:51Chouser'rest' is for dealing with lazy seqs in a way that is careful not to realize anything more than necessary. Specifically, the thing that 'rest' returns may be an empty seq, while next will always return nil instead.
10:52arohnerAWizzArd: I have successfully used jswat
10:52Chouserlaz0r: do you have clojure-contrib?
10:52laz0ri don't think so
10:52laz0roh, well, yes i have it
10:52Chouserlaz0r: it currently requires 'git' to get a recent version . :-/ nobody's made a downloadable yet
10:52Chouseroh, good.
10:53laz0rtheres at least a directory named like that in my clojure dir
10:53Chousermake sure clojure-contrib/src is in your classpath
10:54Chouserthen you can (use '[clojure.contrib.repl-utils :only [source javadoc show]])
10:54laz0rok, i'll try that out
10:54Chouserthen (source reduce) will print reduce's source code
10:55Chouseror you can just open core.clj and search
10:55rhickeyworks for me :)
10:55Chousukearr.
10:56ChousukeIt's always a pain to use a computer that's not mine.
10:56laz0rjust pasting the above line into the emacs REPL thing and then doing (source reduce) worked
10:56ChousukeI'm always pressing caps lock, thinking it's control :(
10:57ChouserChousuke: my caps lock is ctrl
10:59ChousukeChouser: yeah, so is mine. but I'm using my dad's computer at the moment.
10:59ChouserChousuke: in other words, so do I but it just works...
10:59Chouserah!
10:59ChouserI see. :-P sorry.
11:00Chousukewell, at least I have vimperator on this thing.
11:00ChousukeI have to remember to disable it though.
11:00AWizzArdarohner: what jdk version and what jswat version was/is it?
11:04arohnerAWizzArd: jswat-3.16, JDK 5 on OSX
11:05arohnerhaven't needed to use jswat since I moved to JDK 6
11:11AWizzArdarohner: ok, i see. I tried jswat 4.3 on jdk6-11 with not too much success. I could set breakpoints, but they were ignored.
11:11AWizzArdNow on jdk6-14 with jswat 4.5 I even can't set breakpoints for Clojure programs anymore. Only for .java files I can.
11:16mccraigwhat's the clojure name for the function which takes a list of sequences as params and returns a sequence of sequences wherein each element has one element from each sequence param
11:17mccraige.g. (foo [1 2 3] [4 5 6]) => [[1 4] [2 5] [3 6]]
11:17Chousukemap vector
11:18Chousukeor list, if you want lists.
11:18mccraigah, cool. thx
11:30AWizzArdIs there a better way than loop to traverse multiple collections (of the same size) simultaneously and conj up a result? Something like for with two or three bindings, but which steps through all of them at once.
11:31rhickeyAWizzArd: map
11:32AWizzArdah yes i see, it takes many args, good
11:35rhickeyAWizzArd: JSwat 4.5 working for me:
11:35rhickeyProduct Version: JSwat 4.5
11:35rhickeyJava: 1.6.0_13; Java HotSpot(TM) 64-Bit Server VM 11.3-b02-83
11:36rhickeybut the highlighting isn't, for .clj files. That is, you can set a breakpoint from the menu, but will get no visual indication, similarly, will step through code but not highlight current line - seems to be all display issues, not debugging features
11:37Drakesonhow would you parse arbitrary (possibly dirty) html?
11:40ChouserDrakeson: http://home.ccil.org/~cowan/XML/tagsoup/
11:41ChouserDrakeson: that can be used with clojure.xml/parse or clojure.contrib.lazy-xml/parse-trim
11:42Drakesonthanks
11:45Chouserthis was just over a year ago... seems much longer: http://groups.google.com/group/clojure/browse_thread/thread/5dc04b83b28b4530
12:23AWizzArdrhickey: okay, I see now that I can select breakpoints from the menu. What I do is: start slime+clojure, with "-server -Xmx1024m -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8888".
12:24AWizzArdThen I load-file a .clj file, in emacs but also in jswat. I then set a break point in jswat in function foo (at several lines in there) and call that function in the repl. No break, no stepping, I just get the result.
12:24AWizzArdIs that also how you do it?
12:25ericthorsenrhickey: (defn foo [x y] {:pre [(even? x) (odd? y)]} (+ x y))
12:26ericthorsenrhickey: should I not be able to see the pre/post condition as meta data on the vector in :arglists?
12:26ericthorsenrhickey: (meta (first (:arglists (meta #'foo))))
12:26ericthorsenreturns nil
12:26ericthorsenrhickey: The conditions are being executed
12:30Chouserericthorsen: it looks like the pre/post map gets passed into the fn form directly, not attached to metadata
12:31Chouser(binding [*print-meta* true] (prn (macroexpand '(defn foo [x y] {:pre [(even? x) (odd? y)]} (+ x y)))))
12:31ericthorsenChouser: I'm looking at the macro now
12:35Chouserheh. the fn macro just turns them into asserts in the body of the fn.
12:36Chouserso no way to get them back out after compilation, or even discover that they're there.
12:37ericthorsenChouser: hmm...originally they were attached to each vector in the arglists so I could inspect them with a tool.
12:37ericthorsenChouser: that was a prototype...
12:38ericthorsenrhickey: was this by design? Or is there another way for me to get at that stuff after compilation?
12:39ericthorsenof course I could just parse the forms myself...
12:39Chouserwhen c-in-c is done... :-)
12:39ericthorsenlol
12:48ZabaQwow. busy channel. I thought there'd be 4 people here, tops..
13:13drewrDang, no props for Chouser in the error-kit writeup.
13:14rhickeyericthorsen: no, only is you use the metadata form
13:14rhickeyif
13:14rhickeynot with the conditions as map following arglist
13:17ericthorsenrhickey: got it so: (defn foo #^ {:pre [(even? x) (odd? y)]} [x y] (+ x y))
13:17ericthorsengets me there (with the scary syntax)
13:17rhickeyuser=> (defn foo #^{:pre [(even? x) (odd? y)]} [x y] (+ x y))
13:17rhickey#'user/foo
13:17rhickeyuser=> (map meta (-> #'foo meta :arglists))
13:17rhickey({:pre [(even? x) (odd? y)]})
13:18ericthorsenrhickey: that works. I should have thought to try that
13:18rhickeynp, I still haven't decided how best to convey with map following arglist, but planned
13:18ericthorsenrhickey: I liked your more elegant syntax and was hoping to have it all :)
13:18ericthorsenrhickey: sounds good
13:31drewrChouser: I think I like continue-bind better than bind-continue. Seems more consistent.
13:42rhickeydrewr: weird, yes, no props for Chouser :(
14:09rhickeyericthorsen: now propagates to arglist metadata: http://github.com/richhickey/clojure/commits/master
14:14Chouserheh, I had to read that a couple times before realizing rhickey was not actually denying me props because I used the name bind-continue
14:16Chouserdrewr: All the names in error-kit felt awkward to me.
14:16rhickey:)
14:16Chouserrhickey: nah, you're just denying me props for writing error-kit at all.
14:17Chouserdrewr: the idea with bind-continue was that it's almost like (binding [continue...
14:18Chouserand also that continue* is for invoking a continue-like thing, so *continue give a vaguely transitive feel for creating one in the first place.
14:19Chouser...thought really, I'd prefer some entirely new word to use instead of "continue" error-kit ends up using it as a noun, which it just isn'.
14:20Chousukerestart?
14:21Chousukehmm, that's ambiguous too
14:21Chouserthe noun form of continue is of course continuation, but that means something else entirely.
14:23ChouserI'm pretty ambivalent about it now. I think error-kit could be rescued from the object system it accidentally includes, but it still contains a lot of complexity that I'm not sure anybody needs.
14:23Chousermaybe people will read Halloway's article and start making use of it. I think I understand it better myself now. :-)
14:27drewrThat's the effect it had on me... that I'll try to use it now. I wasn't quite convinced that I needed conditions since I'm not a CLer.
14:27drewrI didn't realize error-kit was mature enough either.
14:29Chouserdrewr: well, it does still say EXPERIMENTAL at the top. :-)
14:29slashus2Everything is experimental to some degree ;-)
14:33replacaChouser: I give you props for throwing it out there! I recall that when you did you said it was an idea for discussion.
14:34drewrI'm still curious as to what rhickey would use instead of conditions. He used to mention when people would ask about Clojure's support for CL-style conditions that Clojure can get you 90% of the way there.
14:34drewrWould that be by catching Java exceptions and returning maps that contain closures to other behavior?
14:35drewrI try to keep my code small enough that I don't get into these kinds of situations, but I have the suspicion that I could do a better job handling errors.
14:36drewrI guess error-kit seems to do basically that, wrapped in a DSL.
14:36Chouseryeah
14:37rhickeyI am highly dubious of the non-local flow control aspects of conditions
14:38Chouserbut I've never used CL enough to come close to touching conditions, so error-kit tries to provide the same features without me really understand why those features exist or what they're used for.
14:39drewrChouser: I think knowing that is what has scared me away from it. :-)
14:39rhickeyhttp://groups.google.com/group/clojure/browse_frm/thread/90eae0f570989254/476de8d71ca13b61?#476de8d71ca13b61
14:39Chouserand I think CL conditions are built on CLOS (or at least something very CLOS-like), which cause me to include a little object system in error-kit that I am now rather suspicious of.
14:39Chouserdrewr: that's a very reasonable reaction. :-)
14:41Chouserif you only use error-kit's 'continue' and not 'continue-with', there's no use of exceptions for flow control.
14:41rhickeypassing a dynamically-bound policy fn is great, leaping out, not so great, and going to be a problem with threads, I think we need a new model for problem notification given high concurrency - the person who cares is no longer necessarily on your stack
14:41rhickeytrue for exceptions too
14:42drewrThat's the kind of thing I've been doing with error seqs that different threads publish problems they encounter.
14:42drewrConsuming those errors are what I haven't quite decided how to do.
14:42rhickeyright, error queues or something
14:43Chouseryeah, it'd be huge if java exceptions could be routed into error queues or whatever in a way that could be handled in lexical rather than dynamic scope.
14:45Chouserthat could address some current gotchas for errors in agents, lazy seqs, etc.
14:50drewrTrue.
15:06weissjis there a way to get command history in the repl?
15:08Chouserweissj: if you use rlwrap or jline with it
15:08weissjChouser: cool thanks
15:10duck1123some (most?) of the editor-integrated repls offer it too
15:12weissjduck1123: not the eclipse one :( or at least i couldn't figure out how to make it work
15:13duck1123I use nothing but slime personally
15:13duck1123I'm pretty sure the vim one has it too
15:14weissjduck1123: any pointers how to run with slime?
15:15duck1123http://technomancy.us/126
15:18duck1123I've been having some problems with the clojure-project function, I'm worrking on it now
15:19duck1123it's so hard to not use clojure syntax when programming in elisp
15:20weissji don't know if i'm ready to start learning emacs :) maybe i'll stick with vim for now
15:21duck1123there's a program called clojure-box that supposedly has everything packed up for you
15:21duck1123I've never bothered with it because I had emacs set up already
15:22duck1123you could probably get up and running with learning a minimal ammount of emacs
15:23duck1123emacs is bad for productivity. (the first month)
15:23weissji don't know if i've got the will to embark on that now
15:23weissjif vi proves unworthy i'll try it
15:24duck1123I don't use vi, but from what I hear from the people that do, the clojure support is pretty decent
15:25weissjcool
15:25weissjthis clojure-box? it's windows only and emacs :(
15:25weissjhttp://clojure.bighugh.com/
15:26duck1123i could've sworn i saw someone port it to nix
15:26weissjstill it's emacs, i was looking for vim
15:27duck1123gorilla? but there is another one from the same guy. don't know which is better
15:27weissji'm taking a look at vimclojure
15:27Chouserweissj: that's the latest
15:27kotarakgorilla is merged into vimclojure
15:29sgsHi. I'm really a newbie to clojure. have done sth with CL in the past. Can anybody help me with this very simple 'problem'? http://clojure.pastebin.com/m6b1b557f
15:31Chousersgs: (zipmap structure (map ...))
15:32sgsChouser: Thank you. Great.
15:33Chousersgs: BTW, "modern" syntax for java instance method calls is (.split #"," %)
15:33kotarakAnd the seq is not necessary, no?
15:33Chouserkotarak: I think that's right
15:34Chouserbecause zipmap will call seq on both its args, so handing it the array from .split should be fine.
15:34duck1123also, it's probably best to get into the habit of putting it into a namespace with the (ns) macro
15:36duck1123sgs: are you the guy I replied to this morning on twitter?
15:36sgsduck1123: Definately not :) Never used twitter in my life...
15:37duck1123ok, someone was talking about using clojure to parse csv files this morning
15:39duck1123kotarak: that was basically my comment. OpenCSV or fnparse
15:40duck1123I know some of the corner cases with csv can get pretty nasty
15:40sgsI havent even thought about using a library for parsing csv because I know exactly whats going to be in the files, no surprises at all - small files also.
15:40duck1123then your solution will probably be fine
15:48duncanmis there a way to append to the classpath from the REPL?
15:49kotarakduncanm: add-classpath, but is comes with problems at times...
15:50technomancyduncanm: short answer: you need to know your classpath before you launch your JVM
15:50kotarakduncanm: or extract / link stuff into a special directory in your classpath
15:52cemerickyeah, unzipping new jars into a directory you've set up for that purpose is the cleanest approach, IMO
15:52cemerickis anyone using clojure with osgi? That might make things more straightforward.
16:15eyerisIs there an (if) syntax that lets you call multiple forms for either the true or false paths?
16:15kotarakeyeris: you have to use do
16:15eyerisOkay
16:15kotarak(if test (do st uf f) (do oth er stu ff))
16:16eyerisI thought there was something like that, but when I searched the API page, I didn't find it.
16:16kotarakIf there is only one branch: when get's it for free (when test foo bar baz)
16:16eyerisI see it now on the Special Forms page.
16:42weissjwhat's a good way to write a x^y math function? (defn ** [x y] (reduce * (repeat y x))) works but doesn't that create a long list of numbers for no good reason? or does the laziness come in here so that it uses constant memory?
16:44gnuvince_weissj: depends what kind of exponentiation function you want.
16:44Chouserweissj: laziness does cause that to use constant memory
16:44drewrMath/pow
16:44gnuvince_weissj: you could use Java's built-in ones.
16:45Chouserweissj: I'll allow others to address whether that means it's a good way to define exponent or not. :-)
16:45gnuvince_If you want something for integers, the reduce technique is O(n), but it's possible to have a O(lg n) function
16:47weissjok, i'm not as concerned about getting the math wrong as i am about writing what i intended to write. i intended to write a function that repeatedly multiplies by x, y times
16:47weissjby wrong, i mean less efficient
16:47weissjbut i didn't intend for it to create a list in memory with y items
16:48weissjsounds like i achieved that at least :)
16:48Chouserwould it be seen as mean by anyone to have a quote board?
16:48Chouser"by wrong, i mean less efficient" amuses me greatly. :-)
16:48weissji am glad you are amused
16:49weissjwhat i meant was, i'm just trying to learn clojure here, not write a great function
16:49gnuvince_Hang on...
16:49weissjgo ahead and quote me :)
16:49Chouserweissj: no, I completely understand. What you *meant* was perfectly reasonable and make sense.
16:50weissjhehe
16:50Chouserweissj: what you *said* is funny. :-)
16:50Chouserand that's what quote boards are for.
16:50weissjeven though i didn't mean it the way it sounded, i think it still works literally :)
16:50weissjless efficient == wrong
16:50weissjhehe
16:51Chouserweissj: for a case like that today, loop/recur might be faster. Not sure if that will still be true after chunks are fully in.
16:52Chouserweissj: but reduce/repeat is so clear, I'd hate to mess with it. It won't blow you heap.
16:59lisppaste8gnuvince pasted "O(n) exp vs O(lg n) exp" at http://paste.lisp.org/display/82877
17:01Chouserinteresting. but exp2 consumes stack at O(ln n), right?
17:24gnuvince_Chouser: I guess so
17:24gnuvince_,(/ (Math/log 1000000) (Math/log 2))
17:25gnuvince_No bot, eh?
17:25Chousernope :-(
17:25gnuvince_Anyway, for x^1000000 that's only 20 levels of depth
17:26kotarakhiredman on vacation?
17:27Chouserah
17:28kotarakwell, clojurebot is a laborious bot, he deserves a vacation, no? :)
17:39durka42kotarak: soon it'll be lobbying for health insurance and shorter working hours too!
17:39kotarakhehe
17:40durka42while you're here: is there a good way in vimclojure to bind a key to simulate repl input?
17:40durka42i want to add a mapping for (require :reload-all (.name *ns*))
17:43kotarakdurka42: you can probably do :nmap <mapping-here> :call vimclojure#ExecuteNailWithInput("Repl", "(require :reload-all (.name *ns*))", "-r", "-n", b:vimclojure_namespace)<CR>
17:43kotaraknot tested, though
17:45durka42do you mean the repl id, not the namespace?
17:46durka42b:vimclojure_repl._id
17:46kotarakrepl id? no, the namespace
17:46kotarakFor this code, you don't the repl.
17:46kotarakyou don't need...
17:46durka42oh, ok
17:46durka42because there is just one clojure instance at the backend
17:47kotarakYes. The namespace is changed via the -n. So *ns* will be correct (I hope)
17:48durka42yep
17:48durka42thanks
17:48kotaraknp (still hoping that it works... ;) )
17:48durka42seems to anyway
17:50durka42:nmap r :call vimclojure#ExecuteNailWithInput("Repl", "(require :reload-all (.name *ns*))", "-r", "-n", b:vimclojure_namespace)<CR><CR>
17:51kotarakTwo <cr>?
17:51durka42yes
17:51durka42after the first one it says press enter to continue
17:51kotarakOh ok.
17:53kotarakhehe..
18:22Drakesonis there an easy way to turn the format of the output of clojure.xml/parse to the input format of clojure.contrib.prxml?
18:23Drakesonnamely, {:tag :a :attrs {:id "somthing} :content ("a" "b")} -> [:a {:id "something"} "a" "b"]
18:24Drakesonalso, do these formats have names?
18:55technomancysix of the top sourceforge hits for "lisp" are written in Java
18:56technomancytwo of them are rhickey's past projects. =)
18:58kencauseyI don't really think sourceforge has an accurate representation of the world of Lisp
19:07ATLientechnomancy: Just want to say thanks for the emacs-starter-kit and the PeepCode meet Emacs screencast. Made it a breeze for me.
19:10technomancyATLien: great; glad to hear it
19:23vagifHello. i'm using clojure 1.0. contib.sql returns java Booleans for boolean fields instead of clojure true/false. This breaks if checks. Is this fixed already in trunk ?
19:27kencauseyvagif: My understanding is that the Clojure 1.0 release is of Clojure only and not a reflection on the status of clojure-contrib
19:28kencauseyI suggest checking out from github and checking yourself
19:30kencauseyvagif: last update to contrib.sql appears to be from 6/22
19:39vagifthx, i'll try it from trunk
20:00vagifI tried coljure and contrib from trunk with same results. Boolean fields return as java Boolean, not as clojure true/false
20:03kencauseyvagif: http://www.assembla.com/spaces/clojure-contrib/tickets It doesn't appear that it's a known issue
20:03technomancyisn't Java true unified with Clojure true?
20:04technomancyor is it just nil/null?
20:05kencauseyvagif: technomancy makes a good point, what is the problem? http://clojure.org/special_forms
20:09kencauseyhttp://clojure.org/java_interop#toc37 may also be relevant
20:21ChouserIt may be related to (if (Boolean. false) :oops) ==> :oops
20:24Chouserbut I can't see where in clojure.sql the boolean's getting generated
20:30Chouserhm, or perhaps is the underlying db driver instead...
20:31Chouservagif: if it's the latter, I guess your best route is to use (boolean x) to cast x to the canonical Boolean/TRUE or Boolean/FALSE
21:00sgsCan anyone recommend a nice java library to create charts (2 axis, i.e account balance)?
21:03newbie_hey guys, can anyone provide some example snippet on how to use re-groups, i am trying to capture the group from this match (re-find #"-----------(.*?)</pre>" quakes-html ) docs say i should pass an match passing re-find is not working?
21:10Chousersgs: maybe http://www.markmfredrickson.com/code/
21:11sgsChouser: Thanks.
21:12Chousernewbie_: (re-find #"--(.*?)</pre>" "--hello</pre>") returns ["--hello</pre>" "hello"] ...what else do you need?
21:14newbie_thanks with a huge output i missed its a vector should have tested with a small input.
21:16vagifChouser: Booleans are returned from database. Actually there's 3 way clash when working with booleans from sql database.
21:17vagif1. all boolean database fields are returned as java Booleans. Which means that i cannot simply test them, i have to do it explicitly (= true bla)
21:17vagif2. If database field is null, it will not be considered false, so i cannot test (= false bla), when bla is null
21:18vagifthe only correct way to deal with database booleans from clojure is to explicitly test them for true (= tru bla) or (no (= true bla))
21:23Chouser(boolean x) will return canonical false for any Boolean false and for nil, canonical true otherwise
21:28vagifChouser: thx, i'll try it out.
22:11newbie_I am using (apply str (line-seq buf ) ) to read file in to string how can i add \n after each line new lines in the string seems to be lost?
22:26Chouserline-seq is removing them for you.
22:26Chouserif you are reading from a file name you can use 'slurp'
22:28Chouserotherwise you could re-insert newlines like this:
22:28Chouser(apply str (interleave (line-seq buf) (repeat \newline)))
22:30newbie_thank you that worked
22:31Chouseryou're welcome
23:39newbie_can i set pattern options like DOTALL while using re- functions?
23:46Chousernewbie_: #"(?s)..."
23:55newbie_thanks that worked but can you explain it a bit? is this a java thing or clojure ? how can i pass other flags if i need to?
23:59Chouserit's a java thing.