#clojure log - Jul 01 2009

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

0:00 holmak: i'm pretty sure it is

0:00 i would be rather surprised if it were _not_ deterministic

0:02 durka42: it seems to be from left to right

0:02 i would like that to always be the case :)

0:03 _fullets: http://clojure.org/evaluation says left to right.

0:05 justin`: 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

0:07 grrrt: if 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

0:08 {:player1 [card1...cardn] :player2 [card1'....cardn'] :dealer [card1"...cardn"]}

0:09 you could create a function that accepts a structure such as this as its arguments and returns a new one where some cards changed hands

0:09 justin`: ah and then just, like asoc player1 with (first dealer) and dealer with (rest dealer) to draw?

0:09 grrrt: yes something like that could work

0:09 justin`: cool

0:10 thanks, taking me awhile to get used to this

0:10 grrrt: yeah same here actually :)

0:11 durka42: (next dealer)

0:11 justin`: ah

0:13 durka42: rest is now for use only inside lazy seqs

0:13 grrrt: I didn't know that

0:14 is that for 1.0.0 too?

0:19 durka42: grrrt: yes as far as i know, it's been the case since lazy

0:19 grrrt: hmm I must admit I haven't kept up with that.

0:19 I should, really

0:48 justin`: i feel like its going to be extemely difficult to program a card game in functional style

0:49 arohner: justin`: it seems like a deck of cards would just be a vector of cards

0:49 or, a ref to a vector of cards

0:49 justin`: 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

0:50 yeah but what if i want to send the top card of the deck to a player's hand?

0:50 arohner: the player's hand is also a ref to a vector of cards

0:50 or their hand could be a set

0:50 so then moving a card would be a transaction

0:51 justin`: hmm

0:52 arohner: (dosync (let [card (first @deck)] (commute deck (rest %)) (commute hand (conj card %))

0:53 justin`: ah thanks

0:54 arohner: that probably won't compile, but should give you an idea of what I'm talking about :-)

0:55 justin`: yeah sort of, at least it gives me some stuff to look up :)

0:55 arohner: the general idea is both the hand and the deck are refs that you alter in the same transaction

0:56 take a card out of the deck and put it in the hand

0:57 HTH, I'm going to bed

0:57 justin`: thanks have a good one

2:12 Lau_of_DK: Top of the morning gents

5:27 AWizzArd: Anyone 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?

5:54 samwisem: Hello. 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?

6:09 Chousuke: samwisem: something like (:use (clojure.contrib [whatever :only (defnk)] (my [lib :only (myfunction)]))

6:10 samwisem: ok thanks

6:10 Chousuke: I'm not sure about that though.

6:10 ns needs more examples.

6:10 samwisem: i agree

6:10 is there a rule-of-thumb as to when to use vectors [] and lists () in ns?

6:11 Chousuke: hmm

6:11 well, a vector is a libspec

6:12 samwisem: aah that makes sense

6:12 Chousuke: while a list is a prefix list, like (clojure.contrib sql monads [dataflow :as dflow])

6:13 samwisem: ok that makes a lot more sense now thanks

6:52 dmiles_afk: i 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?

6:52 or would i define self lexically and use one engine?

6:53 oops sorry. actually thet will each have differnt definations of the various source functions

6:53 thet/they

6:54 so things like (def (on-chat "from" "text") ..) they might each have a differnt impl of on-caht

8:26 achim: hi! 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

8:27 Chouser: achim: thanks, didn't know about that.

8:42 lpetit: Hi all

8:50 Chouser: lpetit: good morning

8:54 lpetit: Chouser : good afternoon (here in France :-) )

8:55 If 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]) ?

8:59 Chouser: nope, I think that's it.

9:00 ants.clj does essentially that in 'render'

9:01 lpetit: Ok. I thought there was maybe some more performent better primitive

9:01 Chouser: that'll run pretty fast.

9:02 lpetit: something 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 ?

9:03 I'm missing clojurebot. Do you know whether someone put an equivalent live REPL accessible via the web ?

9:04 Chouser: not that I know of.

9:05 achim: lpetit: maybe http://lotrepls.appspot.com/ ?

9:13 rhickey: http://www.deucestm.org/

9:13 AWizzArd: Anyone 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.

9:14 I can't set breakpoints in jswat and also not in NetBeans.

9:15 lpetit: achim: thanks

9:33 AWizzArd: rhickey: do you run Java 6 Update 14 under Windows?

9:34 Is it possible that in this Java version debugging Clojure is not possible anymore?

9:34 When I open .java files in jswat I can set break points. When I open a .clj file this is not possible.

9:34 * rhickey doesn't run Windows usually

9:42 AWizzArd: rhickey: do you have jswat 4.5 installed?

9:43 rhickey: AWizzArd: no

9:44 AWizzArd: ok

9:53 cemerick: AWizzArd: there is some known issue with setting breakpoints in some recent update of JDK 6 -- affects the entire jvm IIRC

9:55 heh, Deuce is configurable e.g. @Atomic(retries=64)

9:55 rhickey: they're coming for you ;-)

9:56 rhickey: cemerick: 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

9:57 cemerick: ugh, it does runtime instrumentation via -javaagent

9:58 rhickey: immutability is key

10:00 cemerick: I 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:16 AWizzArd: cemerick: do you use update 14?

10:31 Chouser: what a great system -- write obscure and complex clojure code and then wait around for Halloway to document it.

10:32 cgrand: :-)

10:38 samwisem: Why 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:39 Chouser: exactly

10:39 java methods (instance and static) are called via special forms -- they are not first-class functions.

10:40 (macroexpand '(Integer/parseInt x)) ==> (. Integer parseInt x)

10:40 samwisem: I didn't know '/' was a macro. Thanks for explaining that.

10:40 Chouser: well...

10:41 samwisem: it's a special form?

10:41 Chouser: <classname>/<static thing> is expanded at macro-expand time.

10:41 laz0r: hi, just started playing around with clojure, and I am wondering: what is the difference between (),[] and nil?

10:42 Chouser: samwisem: you can't define your own macros like / so it's not just a regular macro

10:43 samwisem: 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:43 laz0r: i 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:43 samwisem: ok thanks

10:43 Chouser: (macroexpand '(namespace/foo x)) ==> (namespace/foo x)

10:44 laz0r: 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:44 laz0r: so nil is its own thing -- it means nothing at all, or Java null.

10:45 rhickey: hmm... 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:45 oh, I see it is linked, nm

10:45 Chouser: laz0r: [] is an empty vector, () is an empty list, {} is an empty map, etc.

10:45 rhickey: I linked it not very long ago.

10:45 rhickey: ah

10:46 laz0r: Chouser: ok, i thought [1 2 3] were lists, but if those are vectory, then why does (rest []) produce (), instead of []?

10:47 or nil, which i expected in the first place

10:47 Chouser: rhickey: 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:47 laz0r: i guess () will mean empty for all the different collection types?

10:47 Chouser: no

10:47 rhickey: Chouser: ok, thanks!

10:48 Chouser: laz0r: most functions that operate on seqs (like first, rest, next, etc.) call 'seq' on their collection argument.

10:49 oops

10:49 sorry, not quite right -- 'rest' should not be in that list.

10:50 laz0r: 'next' does what you'd expect, because (seq []) returns nil, and (next nil) also returns nil.

10:50 laz0r: mmh, ok

10:51 rhickey: Chouser: rest calls seq on its argument

10:51 laz0r: btw. is there an easy way to look at the source code of the clojure core functions?

10:51 rhickey: it doesn't force its return

10:51 laz0r: like reduce for example

10:51 Chouser: '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:52 arohner: AWizzArd: I have successfully used jswat

10:52 Chouser: laz0r: do you have clojure-contrib?

10:52 laz0r: i don't think so

10:52 oh, well, yes i have it

10:52 Chouser: laz0r: it currently requires 'git' to get a recent version . :-/ nobody's made a downloadable yet

10:52 oh, good.

10:53 laz0r: theres at least a directory named like that in my clojure dir

10:53 Chouser: make sure clojure-contrib/src is in your classpath

10:54 then you can (use '[clojure.contrib.repl-utils :only [source javadoc show]])

10:54 laz0r: ok, i'll try that out

10:54 Chouser: then (source reduce) will print reduce's source code

10:55 or you can just open core.clj and search

10:55 rhickey: works for me :)

10:55 Chousuke: arr.

10:56 It's always a pain to use a computer that's not mine.

10:56 laz0r: just pasting the above line into the emacs REPL thing and then doing (source reduce) worked

10:56 Chousuke: I'm always pressing caps lock, thinking it's control :(

10:57 Chouser: Chousuke: my caps lock is ctrl

10:59 Chousuke: Chouser: yeah, so is mine. but I'm using my dad's computer at the moment.

10:59 Chouser: Chousuke: in other words, so do I but it just works...

10:59 ah!

10:59 I see. :-P sorry.

11:00 Chousuke: well, at least I have vimperator on this thing.

11:00 I have to remember to disable it though.

11:00 AWizzArd: arohner: what jdk version and what jswat version was/is it?

11:04 arohner: AWizzArd: jswat-3.16, JDK 5 on OSX

11:05 haven't needed to use jswat since I moved to JDK 6

11:11 AWizzArd: arohner: 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:11 Now on jdk6-14 with jswat 4.5 I even can't set breakpoints for Clojure programs anymore. Only for .java files I can.

11:16 mccraig: what'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:17 e.g. (foo [1 2 3] [4 5 6]) => [[1 4] [2 5] [3 6]]

11:17 Chousuke: map vector

11:18 or list, if you want lists.

11:18 mccraig: ah, cool. thx

11:30 AWizzArd: Is 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:31 rhickey: AWizzArd: map

11:32 AWizzArd: ah yes i see, it takes many args, good

11:35 rhickey: AWizzArd: JSwat 4.5 working for me:

11:35 Product Version: JSwat 4.5

11:35 Java: 1.6.0_13; Java HotSpot(TM) 64-Bit Server VM 11.3-b02-83

11:36 but 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:37 Drakeson: how would you parse arbitrary (possibly dirty) html?

11:40 Chouser: Drakeson: http://home.ccil.org/~cowan/XML/tagsoup/

11:41 Drakeson: that can be used with clojure.xml/parse or clojure.contrib.lazy-xml/parse-trim

11:42 Drakeson: thanks

11:45 Chouser: this was just over a year ago... seems much longer: http://groups.google.com/group/clojure/browse_thread/thread/5dc04b83b28b4530

12:23 AWizzArd: rhickey: 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:24 Then 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:24 Is that also how you do it?

12:25 * ericthorsen rh

12:25 ericthorsen: rhickey: (defn foo [x y] {:pre [(even? x) (odd? y)]} (+ x y))

12:26 rhickey: should I not be able to see the pre/post condition as meta data on the vector in :arglists?

12:26 rhickey: (meta (first (:arglists (meta #'foo))))

12:26 returns nil

12:26 rhickey: The conditions are being executed

12:30 Chouser: ericthorsen: it looks like the pre/post map gets passed into the fn form directly, not attached to metadata

12:31 (binding [*print-meta* true] (prn (macroexpand '(defn foo [x y] {:pre [(even? x) (odd? y)]} (+ x y)))))

12:31 ericthorsen: Chouser: I'm looking at the macro now

12:35 Chouser: heh. the fn macro just turns them into asserts in the body of the fn.

12:36 so no way to get them back out after compilation, or even discover that they're there.

12:37 ericthorsen: Chouser: hmm...originally they were attached to each vector in the arglists so I could inspect them with a tool.

12:37 Chouser: that was a prototype...

12:38 rhickey: was this by design? Or is there another way for me to get at that stuff after compilation?

12:39 of course I could just parse the forms myself...

12:39 Chouser: when c-in-c is done... :-)

12:39 ericthorsen: lol

12:48 ZabaQ: wow. busy channel. I thought there'd be 4 people here, tops..

13:13 drewr: Dang, no props for Chouser in the error-kit writeup.

13:14 rhickey: ericthorsen: no, only is you use the metadata form

13:14 if

13:14 not with the conditions as map following arglist

13:17 ericthorsen: rhickey: got it so: (defn foo #^ {:pre [(even? x) (odd? y)]} [x y] (+ x y))

13:17 gets me there (with the scary syntax)

13:17 rhickey: user=> (defn foo #^{:pre [(even? x) (odd? y)]} [x y] (+ x y))

13:17 #'user/foo

13:17 user=> (map meta (-> #'foo meta :arglists))

13:17 ({:pre [(even? x) (odd? y)]})

13:18 ericthorsen: rhickey: that works. I should have thought to try that

13:18 rhickey: np, I still haven't decided how best to convey with map following arglist, but planned

13:18 ericthorsen: rhickey: I liked your more elegant syntax and was hoping to have it all :)

13:18 rhickey: sounds good

13:31 drewr: Chouser: I think I like continue-bind better than bind-continue. Seems more consistent.

13:42 rhickey: drewr: weird, yes, no props for Chouser :(

14:09 ericthorsen: now propagates to arglist metadata: http://github.com/richhickey/clojure/commits/master

14:14 Chouser: heh, 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:16 drewr: All the names in error-kit felt awkward to me.

14:16 * rhickey might still

14:16 rhickey: :)

14:16 Chouser: rhickey: nah, you're just denying me props for writing error-kit at all.

14:17 drewr: the idea with bind-continue was that it's almost like (binding [continue...

14:18 and 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:19 ...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:20 Chousuke: restart?

14:21 hmm, that's ambiguous too

14:21 Chouser: the noun form of continue is of course continuation, but that means something else entirely.

14:23 I'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:23 maybe people will read Halloway's article and start making use of it. I think I understand it better myself now. :-)

14:27 drewr: That'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:27 I didn't realize error-kit was mature enough either.

14:29 Chouser: drewr: well, it does still say EXPERIMENTAL at the top. :-)

14:29 slashus2: Everything is experimental to some degree ;-)

14:33 replaca: Chouser: I give you props for throwing it out there! I recall that when you did you said it was an idea for discussion.

14:34 drewr: I'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:34 Would that be by catching Java exceptions and returning maps that contain closures to other behavior?

14:35 I 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:36 I guess error-kit seems to do basically that, wrapped in a DSL.

14:36 Chouser: yeah

14:37 rhickey: I am highly dubious of the non-local flow control aspects of conditions

14:38 Chouser: but 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:39 drewr: Chouser: I think knowing that is what has scared me away from it. :-)

14:39 rhickey: http://groups.google.com/group/clojure/browse_frm/thread/90eae0f570989254/476de8d71ca13b61?#476de8d71ca13b61

14:39 Chouser: and 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:39 drewr: that's a very reasonable reaction. :-)

14:41 if you only use error-kit's 'continue' and not 'continue-with', there's no use of exceptions for flow control.

14:41 rhickey: passing 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:41 true for exceptions too

14:42 drewr: That's the kind of thing I've been doing with error seqs that different threads publish problems they encounter.

14:42 Consuming those errors are what I haven't quite decided how to do.

14:42 rhickey: right, error queues or something

14:43 Chouser: yeah, 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:45 that could address some current gotchas for errors in agents, lazy seqs, etc.

14:50 drewr: True.

15:06 weissj: is there a way to get command history in the repl?

15:08 Chouser: weissj: if you use rlwrap or jline with it

15:08 weissj: Chouser: cool thanks

15:10 duck1123: some (most?) of the editor-integrated repls offer it too

15:12 weissj: duck1123: not the eclipse one :( or at least i couldn't figure out how to make it work

15:13 duck1123: I use nothing but slime personally

15:13 I'm pretty sure the vim one has it too

15:14 weissj: duck1123: any pointers how to run with slime?

15:15 duck1123: http://technomancy.us/126

15:18 I've been having some problems with the clojure-project function, I'm worrking on it now

15:19 it's so hard to not use clojure syntax when programming in elisp

15:20 weissj: i don't know if i'm ready to start learning emacs :) maybe i'll stick with vim for now

15:21 duck1123: there's a program called clojure-box that supposedly has everything packed up for you

15:21 I've never bothered with it because I had emacs set up already

15:22 you could probably get up and running with learning a minimal ammount of emacs

15:23 emacs is bad for productivity. (the first month)

15:23 weissj: i don't know if i've got the will to embark on that now

15:23 if vi proves unworthy i'll try it

15:24 duck1123: I don't use vi, but from what I hear from the people that do, the clojure support is pretty decent

15:25 weissj: cool

15:25 this clojure-box? it's windows only and emacs :(

15:25 http://clojure.bighugh.com/

15:26 duck1123: i could've sworn i saw someone port it to nix

15:26 weissj: still it's emacs, i was looking for vim

15:27 duck1123: gorilla? but there is another one from the same guy. don't know which is better

15:27 weissj: i'm taking a look at vimclojure

15:27 Chouser: weissj: that's the latest

15:27 kotarak: gorilla is merged into vimclojure

15:29 sgs: Hi. 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:31 Chouser: sgs: (zipmap structure (map ...))

15:32 sgs: Chouser: Thank you. Great.

15:33 Chouser: sgs: BTW, "modern" syntax for java instance method calls is (.split #"," %)

15:33 kotarak: And the seq is not necessary, no?

15:33 Chouser: kotarak: I think that's right

15:34 because zipmap will call seq on both its args, so handing it the array from .split should be fine.

15:34 duck1123: also, it's probably best to get into the habit of putting it into a namespace with the (ns) macro

15:36 sgs: are you the guy I replied to this morning on twitter?

15:36 sgs: duck1123: Definately not :) Never used twitter in my life...

15:37 duck1123: ok, someone was talking about using clojure to parse csv files this morning

15:39 * kotarak is happy with OpenCSV... but it would be interesting to see something, eg. using fnparse

15:39 duck1123: kotarak: that was basically my comment. OpenCSV or fnparse

15:40 I know some of the corner cases with csv can get pretty nasty

15:40 sgs: I 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:40 duck1123: then your solution will probably be fine

15:48 duncanm: is there a way to append to the classpath from the REPL?

15:49 kotarak: duncanm: add-classpath, but is comes with problems at times...

15:50 technomancy: duncanm: short answer: you need to know your classpath before you launch your JVM

15:50 kotarak: duncanm: or extract / link stuff into a special directory in your classpath

15:52 cemerick: yeah, unzipping new jars into a directory you've set up for that purpose is the cleanest approach, IMO

15:52 is anyone using clojure with osgi? That might make things more straightforward.

16:15 eyeris: Is there an (if) syntax that lets you call multiple forms for either the true or false paths?

16:15 kotarak: eyeris: you have to use do

16:15 eyeris: Okay

16:15 kotarak: (if test (do st uf f) (do oth er stu ff))

16:16 eyeris: I thought there was something like that, but when I searched the API page, I didn't find it.

16:16 kotarak: If there is only one branch: when get's it for free (when test foo bar baz)

16:16 eyeris: I see it now on the Special Forms page.

16:42 weissj: what'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:44 gnuvince_: weissj: depends what kind of exponentiation function you want.

16:44 Chouser: weissj: laziness does cause that to use constant memory

16:44 drewr: Math/pow

16:44 gnuvince_: weissj: you could use Java's built-in ones.

16:45 Chouser: weissj: I'll allow others to address whether that means it's a good way to define exponent or not. :-)

16:45 gnuvince_: If you want something for integers, the reduce technique is O(n), but it's possible to have a O(lg n) function

16:47 weissj: ok, 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:47 by wrong, i mean less efficient

16:47 but i didn't intend for it to create a list in memory with y items

16:48 sounds like i achieved that at least :)

16:48 Chouser: would it be seen as mean by anyone to have a quote board?

16:48 "by wrong, i mean less efficient" amuses me greatly. :-)

16:48 weissj: i am glad you are amused

16:49 what i meant was, i'm just trying to learn clojure here, not write a great function

16:49 gnuvince_: Hang on...

16:49 * gnuvince_ is updating his Clojure copy

16:49 weissj: go ahead and quote me :)

16:49 Chouser: weissj: no, I completely understand. What you *meant* was perfectly reasonable and make sense.

16:50 weissj: hehe

16:50 Chouser: weissj: what you *said* is funny. :-)

16:50 and that's what quote boards are for.

16:50 weissj: even though i didn't mean it the way it sounded, i think it still works literally :)

16:50 less efficient == wrong

16:50 hehe

16:51 Chouser: weissj: 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:52 weissj: but reduce/repeat is so clear, I'd hate to mess with it. It won't blow you heap.

16:59 lisppaste8: gnuvince pasted "O(n) exp vs O(lg n) exp" at http://paste.lisp.org/display/82877

17:01 Chouser: interesting. but exp2 consumes stack at O(ln n), right?

17:24 gnuvince_: Chouser: I guess so

17:24 ,(/ (Math/log 1000000) (Math/log 2))

17:25 No bot, eh?

17:25 Chouser: nope :-(

17:25 gnuvince_: Anyway, for x^1000000 that's only 20 levels of depth

17:26 kotarak: hiredman on vacation?

17:27 Chouser: ah

17:28 kotarak: well, clojurebot is a laborious bot, he deserves a vacation, no? :)

17:39 durka42: kotarak: soon it'll be lobbying for health insurance and shorter working hours too!

17:39 kotarak: hehe

17:40 durka42: while you're here: is there a good way in vimclojure to bind a key to simulate repl input?

17:40 i want to add a mapping for (require :reload-all (.name *ns*))

17:43 kotarak: durka42: you can probably do :nmap <mapping-here> :call vimclojure#ExecuteNailWithInput("Repl", "(require :reload-all (.name *ns*))", "-r", "-n", b:vimclojure_namespace)<CR>

17:43 not tested, though

17:45 durka42: do you mean the repl id, not the namespace?

17:46 b:vimclojure_repl._id

17:46 kotarak: repl id? no, the namespace

17:46 For this code, you don't the repl.

17:46 you don't need...

17:46 durka42: oh, ok

17:46 because there is just one clojure instance at the backend

17:47 kotarak: Yes. The namespace is changed via the -n. So *ns* will be correct (I hope)

17:48 durka42: yep

17:48 thanks

17:48 kotarak: np (still hoping that it works... ;) )

17:48 durka42: seems to anyway

17:50 :nmap r :call vimclojure#ExecuteNailWithInput("Repl", "(require :reload-all (.name *ns*))", "-r", "-n", b:vimclojure_namespace)<CR><CR>

17:51 kotarak: Two <cr>?

17:51 durka42: yes

17:51 after the first one it says press enter to continue

17:51 kotarak: Oh ok.

17:52 * durka42 rebinds to gr because the default binding for r is rather useful...

17:53 kotarak: hehe..

18:22 Drakeson: is there an easy way to turn the format of the output of clojure.xml/parse to the input format of clojure.contrib.prxml?

18:23 namely, {:tag :a :attrs {:id "somthing} :content ("a" "b")} -> [:a {:id "something"} "a" "b"]

18:24 also, do these formats have names?

18:55 technomancy: six of the top sourceforge hits for "lisp" are written in Java

18:56 two of them are rhickey's past projects. =)

18:58 kencausey: I don't really think sourceforge has an accurate representation of the world of Lisp

19:07 ATLien: technomancy: Just want to say thanks for the emacs-starter-kit and the PeepCode meet Emacs screencast. Made it a breeze for me.

19:10 technomancy: ATLien: great; glad to hear it

19:23 vagif: Hello. 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:27 kencausey: vagif: My understanding is that the Clojure 1.0 release is of Clojure only and not a reflection on the status of clojure-contrib

19:28 I suggest checking out from github and checking yourself

19:30 vagif: last update to contrib.sql appears to be from 6/22

19:39 vagif: thx, i'll try it from trunk

20:00 I tried coljure and contrib from trunk with same results. Boolean fields return as java Boolean, not as clojure true/false

20:03 kencausey: vagif: http://www.assembla.com/spaces/clojure-contrib/tickets It doesn't appear that it's a known issue

20:03 technomancy: isn't Java true unified with Clojure true?

20:04 or is it just nil/null?

20:05 kencausey: vagif: technomancy makes a good point, what is the problem? http://clojure.org/special_forms

20:09 http://clojure.org/java_interop#toc37 may also be relevant

20:21 Chouser: It may be related to (if (Boolean. false) :oops) ==> :oops

20:24 but I can't see where in clojure.sql the boolean's getting generated

20:30 hm, or perhaps is the underlying db driver instead...

20:31 vagif: 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:00 sgs: Can anyone recommend a nice java library to create charts (2 axis, i.e account balance)?

21:03 newbie_: 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:10 Chouser: sgs: maybe http://www.markmfredrickson.com/code/

21:11 sgs: Chouser: Thanks.

21:12 Chouser: newbie_: (re-find #"--(.*?)</pre>" "--hello</pre>") returns ["--hello</pre>" "hello"] ...what else do you need?

21:14 newbie_: thanks with a huge output i missed its a vector should have tested with a small input.

21:16 vagif: Chouser: Booleans are returned from database. Actually there's 3 way clash when working with booleans from sql database.

21:17 1. 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:17 2. If database field is null, it will not be considered false, so i cannot test (= false bla), when bla is null

21:18 the only correct way to deal with database booleans from clojure is to explicitly test them for true (= tru bla) or (no (= true bla))

21:23 Chouser: (boolean x) will return canonical false for any Boolean false and for nil, canonical true otherwise

21:28 vagif: Chouser: thx, i'll try it out.

22:11 newbie_: 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:26 Chouser: line-seq is removing them for you.

22:26 if you are reading from a file name you can use 'slurp'

22:28 otherwise you could re-insert newlines like this:

22:28 (apply str (interleave (line-seq buf) (repeat \newline)))

22:30 newbie_: thank you that worked

22:31 Chouser: you're welcome

23:39 newbie_: can i set pattern options like DOTALL while using re- functions?

23:46 Chouser: newbie_: #"(?s)..."

23:55 newbie_: 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:59 Chouser: it's a java thing.

Logging service provided by n01se.net