#clojure logs

2009-03-04

00:26slashus2durka42: If the first is a symbol should it give an error?
00:26durka42i mean, would you ever use a symbol as doc
00:26durka42that seems strange
00:27durka42is doc required to be a literal string?
00:27slashus2It appears so.
00:27slashus2(def testing2 "test doc") and used testing2 and it didn't work.
00:31hiredmanuh
00:31hiredmanthat is because you just def'ed resting2 to a string
00:31hiredmantesting2
00:31hiredmanif you want to add a docstring with def you have to use #^
00:33ayrnieuyou can also add documentation after the fact, with .setMeta
00:34arohnerso struct-map takes the name of a defstruct, and key value pairs. i.e. (defstruct foo :a 1, :b 2)
00:34slashus2I was talking about doing something like (defn testing testing2 [x y] y)
00:34arohnerif I have a map of key value pairs, how do I call struct-map?
00:34hiredman,(doc defstruct)
00:34clojurebot"([name & keys]); Same as (def name (create-struct keys...))"
00:34hiredman,(doc create-struct)
00:34clojurebot"([& keys]); Returns a structure basis object."
00:34hiredmandoesn't say anything about values
00:35arohner,(doc struct-map)
00:35clojurebot"([s & inits]); Returns a new structmap instance with the keys of the structure-basis. keyvals may contain all, some or none of the basis keys - where values are not supplied they will default to nil. keyvals can also contain keys not in the basis."
00:35arohnerstruct-map wants a list of key value pairs, rather than a map
00:36lisppaste8slashus2 pasted "sigs" at http://paste.lisp.org/display/76450
00:36slashus2durka42: How does this look?
00:37durka42seems to make sense...
00:37durka42but i'm not an authority on these things
00:40slashus2hiredman: Do you think that this is acceptable?
00:40ayrnieuarohner, (apply struct-map some-struct (interleave (keys some-hash) (vals some-hash)))
00:41arohnerayrnieu: thanks
00:50arohneris there a built in function to replace the name of a key in a map, keeping the value intact?
00:51arohneri.e. (dissoc (assoc my-map new-name (my-map old-name)) old-name))
00:51durka42i think you just wrote said function :)
00:51cp2heh
00:51arohner:-) yeah, I was just wondering if I needed to write it
00:52RaynesSomeone said "Oh Clojure is Scheme for the JVM." I replied "Bite your tongue." Started a whole uproar as they thought I was dissing Scheme.
00:54arohnerRaynes: where was that conversation?
00:55Raynes#Haskell-Blah Nice guys <3 the uproar only lasted until I said "I would never dis Scheme".
00:55cp2lol
00:56ayrnieu"I would never diss Scheme, but I do think it so shameful for Clojure to be called 'Scheme for the JVM' that I demanded you harm yourself after saying that."
00:56ayrnieubut it's a silly thing to say, anyway. There are already several schemes for the JVM.
00:58Raynesayrnieu: You took that completely out of context.
00:58RaynesI never meant it as being shameful. Clojure is a world-a-way from being "Scheme for the JVM" that's all I meant.
01:00ayrnieuworld-a-way meaning 'world-a-better': if it had been asserted that Clojure was "Forth for the JVM", you'd react differently. This assertion is simply wrong.
01:01Raynesayrnieu: What are you even talking about?
01:01RaynesHad he have said "Fourth for the JVM" I would have asked him was he out of his mind.
01:01RaynesOf course I would of reacted differently.
01:01RaynesIt doesn't take a genius to realize I'm not putting Scheme down.
01:02RaynesThere is around 10 different ways one could take what I said.
01:02RaynesNot just "Scheme is shameful"
01:02RaynesAnyways, I need sleep.
01:02RaynesGood night.
01:03ayrnieuI suppose that it's conversations like this that led people to come up with 'EQ'.
01:04cmvkkEQ?
01:04ayrnieuEmotional Quotient. Like IQ.
01:04cmvkkohh.
01:22slashus2durka42: I will have to change that a little bit. cond isn't defined by that point, nor is symbol.
01:24redalastorIf I have a vector that that contain cartesian coordinates (something like [[3 17] [24 62] [21 99]]), how can I find the right-most or left-most value? If two values are right-most or left-most, any is fine.
01:25redalastorIn Python I'd use min and max but in clojure this would not work.
01:26cmvkk(reduce (fn [x y] (min x (first y)) myvec) ?
01:26redalastorI could always sort it but that seems wasteful.
01:27cmvkkwait that wouldn't work
01:27redalastorcmvkk: Thanks!
01:27redalastorWhy not?
01:27cmvkkwell i think that might be slightly broken, hold on.
01:27ayrnieusort it by the dimension of interest or else fold over it.
01:27cmvkk(reduce (fn [x y] (min (if (coll? x) (first x) x) (first y)) myvec)
01:28cmvkkotherwise when reduce calls it with the first two values it will choke on the first coordinate.
01:28redalastorthanks
01:29cmvkkoh and that will only return the left value, not the whole coordinate...
01:29cmvkkhmm...
01:30cmvkk(reduce (fn [x y] (if (< (first x) (first y)) x y)) myvec)
01:31Chouser(reduce (fn [x y] (if (pos? (compare x y)) x y)) coll)
01:32cmvkkooh compare does things i didn't realize it did.
01:34redalastorYes, interesting. I didn't know vectors were comparables.
01:34cmvkkif 'compare' can do that, i think 'min' ought to be able to do it too.
01:35redalastormin insists on comparing numbers
01:35cmvkkyeah. but clearly it would be trivial to write a min that works anywhere compare does
01:36redalastorYeah, that's what Python and Ruby (I think?) do.
01:36cmvkksame with max, <, >, etc...
01:36cmvkkcould be an efficiency thing I guess
01:37redalastorProbably. But they could be diffrently named.
01:37redalastorI kinda expect someone will tell us it already exists in contrib :)
01:42cmvkkman. defn is so much harder to write a macro over than defun was.
01:45ayrnieuyep. Clojure doesn't have some points of macro-hostility that Scheme has, but then it has superfluous syntax that must be checked and reconstructed properly.
01:47cmvkki have a bad habit of doing things like this: (defn get-filter-stuff [thing & stuff] ...)
01:47cmvkk"poor variable naming habits"
01:48ayrnieunames are hard.
01:48cmvkknames are hard, let's go shopping!
01:49cmvkkin this case, though, [thing & stuff] is everything in a defn but the name. so "thing" could be a string, an arglist, a function body...
03:21eevar2(conj 10 [1 2 3])
03:22ayrnieu,[(conj [1 2 3] 10) (cons 10 [1 2 3])]
03:22clojurebot[[1 2 3 10] (10 1 2 3)]
03:41eevar2,(doc conj)
03:41clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
03:41eevar2,(conj [1 2 3] 10)
03:41clojurebot[1 2 3 10]
03:41eevar2,(conj 10 [1 2 3])
03:41clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IPersistentCollection
03:42eevar2(conj [1 2 3] 10)
04:13BigTomHi
04:14BigTomdoes anyone have an example of reading a file, tweaking it, and writing it, using duck streams?
04:18BigTomI can do something with reading the whole file in processing it and writing it out but I was hoping to do it a line at a time
04:26BigTomOther question, can 'doseq' be considered a "strict" 'for'
04:26BigTom?
04:26hiredmannope
04:26kotarakBigTom: no. doseq returns nil and is purely for side-effects. for returns a seq
04:26hiredmanfor is not a loop
04:27kotarakclojurebot: for
04:27clojurebotfor is not used often enough
04:27kotarakclojurebot: for
04:27clojurebotfor is not a loop
04:28ayrnieuclojure doesn't need separate 'strict' procedures, anyway; you can dorun or doall a lazy one.
04:29hiredmaneager is the term
04:30kotarakdoall is so ugly....
04:30ayrnieuit turns out that people have many terms.
04:31ayrnieukotarak - (def work doall) ?
04:31ayrnieumaybe (def WORK! doall)
04:32kotarakayrnieu: I mean the concept itself. Not the name. I understand that for resource management, doall makes sense, but (dorun (map #(println ..) ..)) or (doall (map #(println ..) ..)) is *ugly*.
04:33ayrnieuoh, sure.
04:39ayrnieukotarak: (defmacro dolist [[v list] & body] `(loop [~v ~list] (when ~v (let [~v (first ~v)] ~@body) (recur (next ~v)))))
04:41kotarakayrnieu: what is the difference to doseq?
04:43ayrnieuif you mean to ask why anyone would use this instead of doseq: *shrug*.
04:44kotarakayrnieu: I'm a bit confused, what you want to tell me with this macro.
04:46ayrnieuthat's OK. I'm going to bed.
04:51Lau_of_DK,(int (* 100 (/ 1966 2864)))
04:51clojurebot68
04:51Lau_of_DKAccording to my head, that should give 69, why dont it ?
04:52HolcxjoLau_of_DK: It doesn't to rounding
04:52Holcxjo,(/ 1966.0 2864.0)
04:52clojurebot0.6864525139664804
04:52cmvkkyep, the real result is 68.64, which int just chops off the decimal part of.
04:52Lau_of_DKThats cheap
04:53Lau_of_DKDo we have a func for ceiling it ?
04:53cmvkkMath/ceil?
04:53Lau_of_DKor roudinging
04:53Lau_of_DKthanks
04:53cmvkkyou still have to call int if you want an int though; that always tripped me up.
04:53cmvkkfor some reason, (Math/ceil 68.64) will return 69.0 rather than 69.
04:54Lau_of_DKA little odd, but quickly fixed :)
04:54Lau_of_DKThanks for the help guys
04:55Holcxjo,(int (+ 1/2 (* 100 (/ 1966 2864))))
04:55clojurebot69
04:55cmvkkheh, that's one way of doing it.
04:55Holcxjotruncation becomes rounding if you add 1/2 (or subtract for negative numbers)
04:56HolcxjoMath/round is the other option
05:01kotarak,(.split "c.c" ".")
05:01clojurebot#<String[] [Ljava.lang.String;@adb24>
05:01kotarak,(seq (.split "c.c" "."))
05:01clojurebotnil
05:01leafwHolcxjo: that (int (+ 0.5 x)) is the best way to round in java/c/c++, AFAIK, all errors considered
05:01kotarakAm I missing something=
05:02kotarak?
05:02hiredman,(count (.split "c.c" "."))
05:02clojurebot0
05:02hiredman,(count (.split "c.c" "\."))
05:02clojurebotUnsupported escape character: \.
05:02hiredman,(count (.split "c.c" "\\."))
05:02clojurebot2
05:02kotarakargh.
05:02kotarakhiredman: thanks
05:50lenstI don't like the new repl_utils. It seems to start some GUI junk.
05:51cgrandlenst: to start?
05:52cgrandcan you be more precise?
05:54lenstI'm running Mac OS 10.4 and when I load repl_utils I get a clojure.main process in my dock.
05:54cgrandand no actual window?
05:55lenstNo window. It probably loads some swing classes, and that makes the java process into a GUI process.
05:57lenstA
05:57lenstoops. And when it starts it becomes forground process and steals focus.
06:00cgrandlenst: can you try to evaluate javax.swing.JEditorPane in a fresh REPL to see if the simple loading of a gui class causes the process to appear in the dock?
06:01lenstIt does.
06:03lenstclojure.contrib.javadoc.browse/open-url-in-swing might be the problem
06:05cgrandlenst: ok, can you open an issue, I'll look at it.
06:11BigTom Thanks for the correction on doseq and for
06:16AWizzArdclojurebot: max people
06:16clojurebotmax people is 149
06:52timothypratleymacro question:
06:53timothypratleyI want to do something like this:
06:53timothypratley(defmacro fun [ & body]
06:53timothypratley `(let [name (javax.swing.JLabel. "hi")]
06:53timothypratley ~@body)
06:53timothypratley(fun (.getText name))
06:53timothypratley<- contrived example
06:54timothypratleyis that possible?
06:55Lau_of_DKsure is
06:56kotarak(defmacro fun [& body] `(let [~'name (javax.swing.JLabel. "hi")] ~@body))
06:56kotaraktimothypratley: but you should clearly document the capture
06:56timothypratley:)
06:57timothypratleygreat!
06:58kotarakI hope I don't go to Hell for giving such tips. ;)
06:58timothypratleyhow does it work? ~' is clearly unquote quote ---- does that avoid the namespacing --- or something else?
06:59kotarak~'name is the same as ~(quote name)
06:59clojurebot'Sea, mhuise.
06:59kotarakYou just have to remember, that ~ means "do the following in the context where the macro is defined".
07:00kotarakWhere everything else is done in the context the macro is called.
07:00kotarak(rough, but as a general guideline)
07:01kotarakSo ~'name means: "fill in (~) the quoted (') symbol 'name'"
07:01kotarakOne could as well say: ~(symbol "name")
07:02timothypratleyoooo
07:03timothypratleyI almost understand that :)
07:03kotaraktimothypratley: writing macros is actually simple. (I know, I know, ... let me explain)
07:04kotarak(defmacro foo [] `(bla blub))
07:04kotarakThis means simply: replace (foo) with (bla blub) and continue compilation.
07:05kotarakNow first step: ~
07:05kotarak`(bla ~blub)
07:05kotarakThis basically means: expand to a call to bla with the second argument replaced by blub from the enclosing context.
07:06kotarakblub could eg. be a macro argument.
07:06kotarak(defmacro foo [blub] `(bla ~blub))
07:06kotarakThis can also be any computation: ~(symbol blub)
07:06kotarakSecond step: ~@
07:07kotarakThis is a bit more complicated, because it "removes" an outer set of parens. So the unquoted thing must be a sequence.
07:08kotarak`(bla ~@[1 2 3]) => (bla 1 2 3)
07:08kotarakThis is maybe a simplified view, but I got me very far, when writing a macro.
07:08timothypratleyso far so good
07:09papermachineIs there a mirror for the blip.tv screencast?
07:13timothypratleyuser=> (macroexpand-1 '(foo))
07:13timothypratley(user/bla user/blub)
07:13timothypratleyuser=> (defmacro foo [] `(bla ~'blub))
07:13timothypratleyuser=> (macroexpand-1 '(foo))
07:13timothypratley(user/bla blub)
07:15timothypratleywe removed the name space qualifier, but presumably being in the current namespace blub and user/blub are the same?
07:15timothypratley(evidently not)
07:24timothypratleyOh I think I'm starting to see the light...
07:24timothypratleyuser=> (let [user/blub 2] blub)
07:24timothypratleyjava.lang.Exception: Can't let qualified name: user/blub (NO_SOURCE_FILE:12)
07:24timothypratleySo I understand your solution better now kotarak thanks
07:28djpowellWhat are the recent checkins related to constants all about?
07:31rhickeyrepresenting constants as bytecode yields big startup improvement on lowly hardware (like Android phones)
07:31Chouserdjpowell: they appear to be mostly about altering the indentation of else-if blocks
07:32Chouseror what rhickey said. :-)
07:34djpowellcool
07:34rhickeyI was hoping for a size reduction too, but no joy there
07:36djpowelldoes it help startup time a lot then?
07:38kotaraktimothypratley: ~'blub basically resolves blub in the context the macro is called, while simply blub is resolved in the context the macro is defined and then replaced by the fully qualified name. So when the macro is expanded, it references the same blub, that the macro knows about.
07:40djpowelljust tried it, it does seem faster
07:42timothypratleykotarak: thanks for the help :)
07:42kotaraktimothypratley: np :)
08:08Lau_of_DKAnyone here who has some experience with AXIS?
08:10banisterfiendLau_of_DK: my grandfather was a nazi
08:11Lau_of_DKIm talking about the Apache servlet system
08:11banisterfiendoh
08:13p_l...
08:13timothypratley1Kotarak: I have another macro question :) From your explanation I understand why this doesn't work:
08:13timothypratley1(defmacro my-set!
08:13timothypratley1 [obj constraint]
08:13timothypratley1 `(set! (. ~obj ~(symbol (name (first constraint)))) ~(second constraint)))
08:15timothypratley1because constraint can only have first/second taken if it is a form at macro compile time
08:16timothypratley1so (my-set! obj (:gridx 1)) works fine, but (my-set! obj c) where c is '(:gridx 1) doesn't
08:16timothypratley1but how can I get around that constraint?
08:19timothypratley1I suspect I must mix a function and a macro in some clever way... I can't make it just a function because set! is a special form hence why I'm trying to trick it.
08:23HolcxjoDon't use the tilde in front of (symbol and (second if you don't want it evaluated at macro-expansion time
08:26timothypratley1Holcxjo: but then (set! does not work at all because it expects a symbol, not a form).... I guess what I'm trying to do is an impossible chicken/egg scenario.
08:33Holcxjotimothypratley1: set! does not evaluated the symbol expression to see what it is?!?
08:33timothypratley1nope :(
09:00cemerickBuilding my first multimethod hierarchy. It's a joy so far.
09:00cemerickDidn't isa? imply instance? at one point, though?
09:01kotaraktimothypratley1: I'm afraid you can't. Macro cannot depend on such runtime information.
09:03kotarakcemerick: yes, instance? should also imply isa? (instance? String foo) <=> (isa? String (class foo)) (I'm not sure about the order for isa?, though)
09:04rhickey,(doc isa?)
09:04clojurebot"([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"
09:05kotarakso it probably should be (isa? (class foo) String). I always confuse the order.... :|
09:06cemerickah-ha, I was being thrown off by the same classname floating around in my ns, but from a different package.
09:10kotaraktimothypratley: that's a common mistake in macro development by the way. You correctly recognised the limits of a macro. Don't make the mistake of trying to hard to push this limit, eg. coming up with some eval using idea. This just gives more problems. See the limits of macros and you just improved your macro-fu by an order of magnitude. :)
09:12timothypratley:)
09:13cemerickis there a builtin that will return two colls given one coll and a predicate (where one of the returned colls is the result of filtering the input coll using the pred, the other is the result of removing)?
09:15timothypratley1cemerick: split-with
09:15cemericktimothypratley1: well, almost -- that uses take-while and drop-while
09:16kotarakrecursive split-with until the seq is consumed.
09:17kotarakhmmm... maybe not. Why not simply (defn unzip-with [pred coll] [(filter pred coll) (remove pred coll)])
09:18cemerickyeah, I already wrote that, but I figured there'd be a builtin.
09:18cemerickalso, I'm not so hot on pred being invoked 2n with approaches like that
09:18cemerickpicky, picky :-)
09:19kotarakhmmm... How would this be done lazily w/o calling pred 2n times?
09:19kotarakYou would need some kind of Queue, no?
09:20kotarakWhen I ask one seq and it finds an item, which doesn't belong there, it stuffs it into the Queue of the other.
09:20HolcxjoFirst create a (lazy) sequence of ((filter pref elem) elem) tuples and then split them?
09:23HolcxjoSomething like this? (defn unzip-with [pred coll] (let [checked (map #([(pred %) %]) coll)] [(map second (filter first checked)) (map second (remove first checked))]))
09:27lisppaste8cemerick pasted "split without 2n pred invocations (sloppy first cut)" at http://paste.lisp.org/display/76458
09:28cemerickthat's super-sloppy, but I gotta run for a bit
09:28kotarakWell, it's not lazy?
09:28cemerickright, not lazy, but I don't care about that in this case
09:30cemerickmy predicate in this case is pretty expensive and all of the results will be consumed anyway
09:41pjstadigI got past the classloader issue
09:41pjstadignow i (when starting a second repl) i get an arity exception
09:42pjstadigwrong number of args passed to: core$map
09:42pjstadigit happens in clojure/main.java when it tries to require the clojure.main namespace on line 38
09:43pjstadigi can connect JSwat and step through the code, bouncing between the java code and code in core.clj
09:43pjstadigmind blowing
09:49timothypratley1wohooo I solved by set! woes: (clojure.lang.Reflector/setInstanceField gbc (name (first c)) (second c))
09:49timothypratley1who needs stinking special forms?
09:53timothypratley1pjstadig are you able to debug exceptions with JSwat or is it too late by then?
09:56pjstadigi can step through until the exception happens
09:56pjstadigand when an uncaught exception happens i can see the call stack
09:56pjstadigand poke around
09:56timothypratley1great!
09:57pjstadigthis is weird
09:57pjstadigthe problem appears to be in the 'spread function
09:57pjstadigactually 'nil?
09:58danlarkinwell spread is private to core.clj
09:58Hookehello
09:58pjstadig'nil? is returning true for (nil? ArraySeq instance)
10:00danlarkin(doc nil?)
10:00clojurebotReturns true if x is nil, false otherwise.; arglists ([x])
10:00pjstadighehe
10:00pjstadigoh good point
10:01pjstadigso apply is calling (. f (applyTo (spread args)))
10:01HookeI'm trying technomancy's emacs clojure-mode. The clojure-install command gives me the error "(Shell command failed with error)" can anyone help, plz
10:03pjstadigspread returns nil
10:04pjstadigso it tries to apply f (which is loadlibs) to null
10:04pjstadigwhich is where i'm getting my exception
10:05danlarkinspread returns nil because the collection you pass is nill
10:05danlarkinI'm assuming
10:07shooverdanlarkin: what's the problem with jswat? are you on JDK 1.6?
10:08pjstadigno the collection is not nil
10:08pjstadigthe collection is [:require 'clojure.main]
10:09danlarkinshoover: java 1.5.0_16-133 on osx 10.5, when I launch it crashes with an NPE
10:10shooverdanlarkin: I think it needs 1.6
10:11danlarkinpjstadig: spread "expands" to as many args as the function accepts, what's the arglist on the function you're trying to call?
10:12danlarkinshoover: that would explain it, then, thanks
10:12cooldude127does swank-clojure allow using jswat for debugging without writing a shell script to start clojure?
10:13shooverdanlarkin: you'll need to wipe jswat and reinstall, taking pains to associate it with jdk 1.6. unfortunately I can't remember exactly how I did that
10:13shoovercooldude127: yes, it has a variable for extra jvm args
10:13cooldude127shoover: great
10:32cooldude127jswat is cool
10:47pjstadignope it's not a problem with 'nil?
10:47pjstadignil? is returning RT.F
10:48pjstadigfor some reason it is not thinking that Boolean.FALSE == Boolean.FALSE across VMs
10:48rhickeypjstadig: ouch
10:48HolcxjoA very philosophical POV
10:48rhickeythat will be a problem
10:49pjstadigit is probably something i'm doing wrong
11:14kotarakcemerick: how about this unzip-with? http://paste.pocoo.org/show/106457/
11:15kotarakgeneral comments welcome
11:25cgrandkotarak: I think you don't need to use PersistentQueue: vectors can suffice
11:27cgrandin make-seq, replace the cons with a concat and the alter by a ref-set []
11:28kotarakcgrand: ah, ok. :) Hadn't thought of that.
11:28kotarakJust a sec.
11:30kotarakhttp://paste.pocoo.org/show/106463
11:50rhickey(defn unzip-with [pred coll]
11:50rhickey (let [pvs (map #(vector (pred %) %) coll)]
11:50rhickey [(remove nil? (map (fn [[p v]] (when p v)) pvs))
11:50rhickey (remove nil? (map (fn [[p v]] (when-not p v)) pvs))]))
11:54kotarakrhickey: yes. Holcxjo proposed something similar.
11:55Holcxjorhickey: Can't the "(remove nil? (map ..." be done with some for ?
11:56rhickeykotarak: sorry, didn't see that
11:56HolcxjoAlso: What if any element *is* nil ? It'll appear on neiher of the output lists
11:57kotarakrhickey: np :)
11:59rhickeyHolcxjo: heh, just doing that, did you already post it?
12:01lisppaste8rhickey annotated #76458 "unzip-with" at http://paste.lisp.org/display/76458#1
12:01HolcxjoMy solution was an ugly (defn unzip-with [pred coll] (let [checked (map #([(pred %) %]) coll)] [(map second (filter first checked)) (map second (remove first checked))]))
12:01HolcxjoSorry for lack of formatting
12:02HolcxjoYou version on pastebin is certainly nicer
12:02HolcxjoHadn't thought of for until I saw your solution
12:04HolcxjoBTW: why "#(vector (pred %) %)" and not "#([(pred %) %])" ? Would you consider the latter too terse for readability?
12:04kotarakHolcxjo: #([]) is (fn [] ([]))
12:05kotarakNote the "call" to the vector.
12:05HolcxjoBah -- the #() syntax is a bit too brittle for my brain
12:07replacaThat is the one annoying thing to me about #(). It seems like about half the time I'm using it to create a quick vector. Well, that and the lack of nesting. :-)
12:07kotarakreplaca: then simply use #(vector ....)
12:15cemerickkotarak, rhickey: thanks for the impls, I'll keep those under my belt for when I need laziness
12:18replacakotarak: yeah, I do, it's just not as purty
12:26terhickey: I just discovered your podcast on iTunes -- thanks!
12:27terhickey: one other note -- you are a remarkably good speaker for a compsci guy
12:29rhickeyte: thanks, although I'm not really a compsci guy
12:30terhickey: you fooled me :)
12:30terhickey: did i hear right that you're just a professional developer that got an itch one day?
12:30mtz:)
12:31rhickeyte: yes, I'm just a developer
12:31tea good speaker AND humble
12:31tei'm beginning to like you more and more
12:31te:)
12:32cemerickwait, wait, wait -- a podcast, you say? :-D
12:32teindeed.
12:32rhickeycemerick: I think all the blip things end up as podcasts
12:33teIt's just his video of clojre for lisp programmers
12:33cemerickah, OK
12:33teor at least that's the one im watching right now
12:33teit would be cool to have someone comment weekly on the state of clojure, cool projects, etc.
12:33tecommunity = win
12:34teerr sorry: (= (community win))
12:35mtz(profit community)
12:36pjstadigte: i would listen to your postcast
12:36pjstadig*podcast
12:40zakwilson"I'm not really a compsci guy" -- rhickey
12:40zakwilsonAnd that's why you can get stuff done in Clojure.
12:41gnuvinceFor a non-compsci guy, you sure are knowledgeable about it
12:42Raynes"I should probably learn LISP, but it seems so foreign..." - Paul Graham
12:42zakwilsonI keep saying that about Haskell.
12:43rhickeygnuvince: I mean I'm not a researcher or anything, just a practitioner
12:43gnuvinceok
12:43BigTomis rhickey one of Zed Shaw's Coming Professional Masters ?
12:43BigTomhttp://www.zedshaw.com/essays/master_and_expert.html
12:43zakwilsonThough I think I may finally do it just to purify my mind after working on an especially bad PHP project (http://paste.lisp.org/display/76132).
12:43Rayneszakwilson: Haskell is fun.
12:45zakwilsonRaynes: I keep hearing that, but I haven't quite figured out why monads work. I almost get it, but not quite.
12:45Rayneszakwilson: When they say it's a mindfuck - They mean it.
12:46zakwilsonBut I need to do *something* to purge the evil from my mind (look at the paste, really).
12:46RaynesHowever, I never got to the monads chapter. Haskell gains and loses my interest several times over time.
12:46RaynesClojure stole my interest.
12:46RaynesMy god.
12:46RaynesThat's some nasty PHP.
12:47zakwilsonI get FP. Really strong static typing makes sense, though I'm not good at using it. Monads are the part I really need to get.
12:47zakwilsonRaynes: that printf call appered in three different files, slightly modified. The rest of the code is about as bad.
12:47danlarkinyou can write bad code in any language
12:48Raynesdanlarkin: But it's less hard to write it in Haskell.
12:48RaynesIn Haskell you either write good code or don't write it at all. There aren't many options.
12:48zakwilsondanlarkin: yes you can, and I'm not blaming PHP for the above badness. You could, in fact write essentially the same thing in Haskell.
12:48danlarkinor clojure for that matter
12:49RaynesClojure is a different story.
12:49zakwilsonAnything with printf or something like it... which is pretty much every general-purpose language.
12:49RaynesIt's easier to write bad code in Clojure than Haskell I feel, because you aren't held back by Haskell's strongness.
12:49gnuvinceI agree
12:49RaynesClojure will pat you on the back, Haskell will smack your face.
12:49Lau_of_DKRich might smack you aswell Raynes - Good evening all =)
12:50gnuvinceHaskell is like Gunnery Sergeant Hartman from Full Metal Jacket
12:50RaynesYou didn't see the context, it wasn't anything bad about Clojure.
12:50gnuvinceIt's gonna yell at you until all your shit is nice and square
12:50Lau_of_DKI know Raynes , I was just making a funny
12:50Raynes:p
12:51RaynesGood evening Lau_of_DK
12:51zakwilsonYes... Haskell will refuse to compile many common errors and warn you about a host of others.
12:52BigTomHi
12:52kotarakgnuvince: and finally it gets shot?
12:52BigTomI am processing a log file with for, which is nice and simple and works
12:52Lau_of_DKleafw or someone today, mentioned that (int (+ 1/2 x)) is the best way of rounding in c and java - Why is that?
12:52BigTomnow I want to sometimes generate a couple of lines for each log line
12:52BigTomis there a neat way of doing that?
12:53cmvkkhmm, so the for returns a list of lines?
12:53BigTomyup
12:53gnuvincekotarak: don't push analogies too far
12:53Lau_of_DKgnuvince: he always does that :)
12:53cmvkki guess you could wrap each output in an extra list, then do (map concat ...) on the result
12:53leafwLau_of_DK: (int (+ 0.5 x)) -- AFAIK, involves the least assembly instructions and does the right thing.
12:54Lau_of_DKisnt that a mapcat cmvkk ? :)
12:54Lau_of_DKah ok
12:54kotarakBigTom: (mapcat (fn [one-line] [one-line1 one-line2 one-line3]) log-lines)
12:54BigTomcmvkk: that's a thought
12:54BigTomHi kotarak :-)
12:54leafwLau_of_DK: I guess the clojure version would be (int (+ (float 0.5) x))
12:55BigTomThanks, that'll get me going again
12:55Lau_of_DKleafw: no 1/2 works fine
12:55leafwLau_of_DK: but 1/2 is not a primitive.
12:55Lau_of_DK,(+ 1/2 (* 100 (/ 68 20)))
12:55clojurebot681/2
12:55Lau_of_DKoops, forgot int
12:56Lau_of_DKBut yea, true, its not a primitive
13:11Lau_of_DKGents - Ive made a little webservice using compojure and I want the result to be an image which contains 1 colored bar and a pie-chart - i which direction should I be looking to accomplish this?
13:12danlarkindefinitely an image? or will you use a javascript api for charting?
13:12kotarakLau_of_DK: dejcartes?
13:12Lau_of_DKdejcartes is for swing apps I believe
13:12Chousergoogle charts
13:12Lau_of_DKdanlarkin: I think I need to supply and image, which another sige can just incorporate ala <img src="myservice?arg=1"/>
13:12kotarakLau_of_DK: it uses JFreeCharts, which can export images
13:13Lau_of_DKoh ok - I'll look into it
13:13Chouseryou could use dejcartes to produce a .png, but google's service would allow you to let their servers do the work.
13:13Lau_of_DKBut is it fast and stable?
13:13greghyou can have myservice?arg=1 redirect to google charts with the appropriate chart creation parameters
13:14Lau_of_DKI cant imagine GC being as flexibl as I need - The design its very clearly described
13:14greghit's probably at least worth a look: http://code.google.com/apis/chart/
13:15Lau_of_DKThanks greg
13:37canderaAnyone have a clue how a ref can get completely trashed? As in, I can still do (class @foo), but @foo results in an NPE. I can isolate so that commenting out one line of code makes the problem go away, but the line of code in question doesn't try to modify the ref...
13:38canderaI hesitate to suggest a Clojure bug (since I know how often it turns out to be the app, not the RT), but that's my best theory at present.
13:38jayfieldsclojurebot url
13:38jayfieldshmm, how do I get the url for pasting code?
13:38canderaThere's paste.lisp.org - is that the one you're thinking of?
13:39jayfieldsno, there's some way to get the clojurebot in this room to give you a url.
13:39jayfields@clojurebot url
13:39jayfields#clojurebot url
13:40Chouserlisppaste8: url
13:40lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
13:40Chousercandera: what does (class @foo) return? Can you do (def tmp @foo)?
13:40jayfieldsthanks Chouser.
13:41Chouserjayfields: np
13:41candera(class @foo) => clojure.lang.LazySeq
13:42canderaI can (def tmp @foo), but evaluating tmp throws the same NPE.
13:42replacacandera: yeah, cause it's lazy til you try to get the head
13:43replacacandera: so when you try to evaluate the head (with @foo) the evaluation throws an NPE
13:43replacacandera: that's my guess anyway
13:43canderaMakes sense.
13:43canderaStill leaves me guessing as to what the problem is, however. :)
13:47Chouseryou should get a stack trace from the NPE that shows the root cause
13:49canderaChouser: So, this is a game. The error that's thrown is from the next deref of the ref. The update occurs previously. If I make a change in the update code, it no longer barfs.
13:53AWizzArdwhat is an easy way to convert a java HashTable or HashMap into a Clojure map?
13:53Chouserright, the update code is apparently creating a new lazy seq
13:53AWizzArdis into the best way?
13:53Chousercandera: it's in the evaluation of one of the items in the lazy seq that the NPE is thrown.
13:54canderaChouser: Ah, duh. Man I thought I had finally internalized this laziness stuff...
13:54canderaChouser: Thanks! I'll proceed down that road.
13:55Chousercandera: here's a simple example, in case it helps: (def foo (lazy-cat [1 2 3] (.x nil)))
13:55Chouser(take 3 foo) will work fine
13:55Chouserbut just foo by itself blows up, because the repl will evaluate the whole thing in order to print it.
13:56ChouserAWizzArd: unless you're going to "update" the map, you should be able to just pass around the Java collection.
13:56canderaChouser: yep. That makes sense. Thanks again!
13:56AWizzArdChouser: well, in reality I have a HashMap with strings as keys. In Clojure I would prefer to have them translated into keywords
13:56ChouserAWizzArd: otherwise, (into {} the-map)
13:58ChouserAWizzArd: (zipmap (map keyword (keys the-map)) (vals the-map))
13:59Chouser(reduce (fn [m [k v]] (assoc m (keyword k) v)) {} the-map)
13:59AWizzArdbtw, does keys and vals guarantee the same order?
14:00Chouserif the underlying map does. I think but do not know that that's the case.
14:00AWizzArdprovided no other thread writes to the map while we want to zipmap them, is it guaranteed that the key/value pairs will still match?
14:01ChouserAWizzArd: you should verify that or use the reduce version
14:06lisppaste8jayfields pasted "user defined globals" at http://paste.lisp.org/display/76474
14:06lisppaste8jayfields annotated #76474 "using printer.clj" at http://paste.lisp.org/display/76474#1
14:08lisppaste8jayfields annotated #76474 "failing version" at http://paste.lisp.org/display/76474#2
14:09jayfieldsokay, so I want to use (defonce *flag* ...) to allow users to set a flag when consuming my library, but when I try to set the flag and consume the printer class I get a failure (code available at the last link from lisppaste8)
14:10jayfieldsI can get around this issue by defining the *flag* in the same namespace, but that seemed like poor form, or is that the correct way?
14:13tashafajayfields: dont know what you are trying to do, but have you tried "require" instead of "use" in the ns form
14:14jayfieldsnope, I check the docs. I don't know the difference.
14:17lisppaste8tashafa annotated #76474 "using require" at http://paste.lisp.org/display/76474#3
14:19jayfieldsthat code executes without throwing an exception, but 'hello' is printed
14:19tashafai think 'use' infers all the symbols in the corresponding namesapce into the current namespace
14:19jayfieldsbecause (I assume) *should-print* from helpers.printer is being used by print-hello
14:20jayfieldswhat I want to be able to do is define a flag that will cause the print not to happen.
14:22tashafai have no idea what *should-print* does... maybe someone more knowlegabel can help
14:23jayfields*should-print* is just the name of my flag
14:23jayfieldsyou could just as easily use *my-flag*
14:23jayfieldsthere's nothing special about it.
14:23tashafaand if that flag is set println shouldnt print?
14:23tashafaset to false that is
14:23kefkaIf I call a function at a top-level (using emacs shell) that blocks, is there any way to stop it without killing the whole toploop?
14:24jayfieldsdid you see helpers.printer?
14:24ayrnieukefka - no.
14:24tashafayeah
14:25jayfieldsoh, sorry, I missed some code, one second.
14:25lisppaste8jayfields annotated #76474 "print-hello that notices *should-print*" at http://paste.lisp.org/display/76474#4
14:26jayfieldssorry, missed the conditional logic the first time.
14:27jayfieldsso, given the last annotation, what I'm trying to do is let someone defonce *should-print* to false if they don't want the print to happen.
14:27tashafai think you may want to use a ref
14:29tashafaor be more functional
14:31RaynesNeeds moar functional.
14:31tashafaRaynes: ha, you know what i mean
14:32hiredmanwhy use a ref?
14:32jayfieldsokay. so the problem is, I need to define a test, and in one context, immediately run that test, and in another context, don't do anything.
14:32cemerickmy first day seriously using a hierarchy -- I seem to be writing a lot of code like (some #(isa? (class foo) %) [::type1 ::type2 ::typeN]). Is there a better (and likely faster) way to work with determine if an object is a match against some set of hierarchy "types" that are only available at runtime?
14:32hiredmanif you are using a ref you shouldn't use **
14:32jayfieldsI'm writing some tests that I want to execute one at a time sometimes, but also as part of a larger suite at other times
14:33hiredman** is used to mark things that are intended to be dynamicaly rebound
14:33jayfieldsI created a macro that defines the test (using deftest from test-is) and runs the test when I want to execute individually
14:33ayrnieujayfields - when you put this a library and have someone else use it, their defonce'd *should-print* will appear in another namespace. If you also export a (def *should-print* true) , then they could (bindings [*should-print* false] ...) to disable that. If you want a toplevel setting, then offer a ref for them to set or export a 'config' or like function that they can pass keywords to.
14:34RaynesI need to buy some ink so I can print the CA.
14:34tashafahiredman: true, no **, @your-flag
14:34jayfieldsbut I also want to not execute the individual test and run them all as a suite.
14:36tashafaReaynes: CA?
14:36lisppaste8jayfields pasted "run individual tests" at http://paste.lisp.org/display/76476
14:36shooverjayfields: have you looked at binding? by definition it establishes a binding per thread, but it works great for doing different things in different contexts
14:37hiredman^-
14:37hiredmanbinding and set!
14:37lisppaste8jayfields annotated #76476 "with *execute-individual-test* set to do nothing" at http://paste.lisp.org/display/76476#1
14:37hiredmanre-defing is bad, don't do it
14:37ayrnieujayfields - ^ my last answer
14:37jayfieldsI get binding, but it doesn't work in my case because I want the code to execute without doing anything extra when run in isolation.
14:38hiredman,(doc set!)
14:38clojurebotjava.lang.Exception: Unable to resolve var: set! in this context
14:38hiredmanbah
14:38ayrnieujayfields - OK, now read that last part. Use a ref internally but export a nice function by which they can control your library's behavior.
14:38hiredmanugh
14:43tashafawhat ayrnieu said... hiredman: are you disagreeing?
14:44jayfieldsokay, so in my test_runner namespace I'll use a ref, but I'll also create a function that changes that ref, right? And, couldn't I just use an atom?
14:45hiredman,(binding [*in* 1] (set! *in* 2) (println *in*))
14:45clojurebot2
14:45hiredmanYes
14:45ayrnieujayfields - yes, for the sake of offering decent interface that you can extend later. You could.
14:46hiredmanthe mechanism used for setting things like that in core.clj is set!
14:47hiredman,(do (set! *in* 2) (println *in*))
14:47clojurebotjava.lang.IllegalStateException: Can't change/establish root binding of: *in* with set
14:47hiredmanI see
14:49hiredmanwell
14:49hiredman*cough*
14:49shooverjayfields: can you paste examples of calling into helpers.test_runner?
14:49hiredmanif you do go the ref route, you will most likely want an atom instead
14:50canderaChouser: your advice was helpful in tracking down the problem. However, it's still weird: if I alter a vector via concat without first materializing it via vec, it still blows up.
14:50hiredmanunless there is the potentional for lots of contention
14:50shooverjayfields: re atom vs. ref, yes, atom is fine instead of ref if you don't need to synchronize with other state
14:50canderaThat is, (alter foo concat (additional-items)) blows on me, but (alter foo (fn [v] (vec (concat v (additional-items))))) does not.
14:51ayrnieu,(concat [1] [2])
14:51clojurebot(1 2)
14:52lisppaste8jayfields annotated #76476 "example using test_runner" at http://paste.lisp.org/display/76476#2
14:52jayfieldsshoover: there's a simple example
14:55shooverok, and from the REPL you'd want that def-test to define and run the test, but from a suite you'd want to define everything and then run them all at the end?
14:56jayfieldsshoover: I'm doing it in IntelliJ with La Clojure, but I believe the result is the same.
14:56Victorrhello, I can't get Slime to work with clojure, I get "java.lang.Exception: Unable to resolve symbol: lazy-seq in this context (core.clj:70)", does anyone have any hint?
14:57shooverhow about defining the default to actually run an individual test, so that works with IntelliJ, then define a suite-runner function that binds *execute-individual-test* to do nothing and inside that binding runs all the tests?
14:57VictorrI'm using the latest slime/swank/clojure from their repositories
14:57hiredmanVictorr: it has come up before
14:58AWizzArd,(map identity {:a 1, :b 2})
14:58clojurebot([:a 1] [:b 2])
14:58hiredmanVictorr: can you start the repl by itsself?
14:58AWizzArdIs there a function that will put the key/value pairs of a java HashMap or HashTable into a vector, as in that example above?
14:58Victorrhiredman: I can
14:59Victorrhiredman: it seems to me that perhaps lazy-seq moved? It is in clojure-contrib, yet I don't see a (:use) statement for it in swank's core.clj
14:59hiredmannah
15:00shooverjayfields: actually, I see that because your macro expands to code to run the test right away, you will need to use an atom or find a way for the suite to actually load tests.heartbeat's code in a binding that nulls out *execute-individual-test*
15:00hiredmanVictorr: I would check again that you have the latest everything
15:00shooveror manually def it in your IntelliJ interactive session to actually do something
15:00VictorrI just checked out from their repositories just now :-(
15:01hiredmanI don't use emacs, but other people have come in here with that Exception before
15:01Victorrgoogle is not turning up anything, unfortunately
15:01hiredmanI have four or five hits for that exception in my irclogs
15:02Victorrok, I'll see if I can irc logs for this channel..
15:02shooverVictorr: lazy-seq is defined in clojure.core in versions of clojure as of a few weeks ago. If it doesn't exist, swank is not running in a recent enough version of clojure
15:03shooverperhaps your swank-clojure settings are looking at the wrong clojure, or you haven't rebuilt clojure.jar?
15:03Victorrok, I'm pretty sure I just downloaded the latest clojure, but I'll try again
15:03VictorrI'll build from source
15:03hiredmanthe latest release is way old
15:04hiredmanand I am sure the latest swank/slime/etc won't work with it
15:04Victorrhiredman, thanks a lot, indeed building clojure from source fixed it!
15:08cooldude127did PersistentQueue disappear or something?
15:09kotarakcooldude127: just used it today clojure.lang.PersistentQueue/EMPTY
15:10cooldude127shouldn't have, looks like it's in the source tree. so why does simply typing clojure.lang.PersistentQueue into the REPL spit an error
15:10cooldude127i have some code that was using it and worked fine, and now when i try to load that file it whines
15:10jayfieldsthanks shoover.
15:10kotarakcooldude127: well. it does not for me
15:11kotarak,clojure.lang.PersistentQueue
15:11clojurebotclojure.lang.PersistentQueue
15:13cooldude127ok, i did ant in the clojure dir, killed SLIME, brought it back and we're good
15:13cemerickit would be very handy if when-let could accept more than one binding, returning nil if any binding in the binding-form is nil
15:14ayrnieucemerick - 'whereas' is a name for a syntax like this. It makes some legalistic sense :-)
15:14cemerickayrnieu: is that what CL calls it?
15:15ayrnieucemerick - CL doesn't have a name for it, but the name came up in a discussion on comp.lang.lisp
15:15cemerickah
15:16cemerickit doesn't seem like another name should be at all necessary
15:16cemerickat least given when-let's general charter
15:18ayrnieuyeah, the limitation is arbitary. I'll post a patch.
15:18taggart,(abs -2)
15:18clojurebotjava.lang.Exception: Unable to resolve symbol: abs in this context
15:18jwinter,(Math/abs -1)
15:18clojurebot1
15:19taggartaha interop
15:19jwinter:)
15:20taggartam I correct, that that is calling java.lang.Math.abs()?
15:20taggartor is it a namespaced clojure func?
15:20ayrnieuthat is calling Math.abs()
15:20cooldude127taggart: you should look at clojure.contrib.math
15:21taggartah yes thanks
15:21cooldude127it provides better definitions of certain math functions like abs and sqrt that work on all numeric types
15:21cooldude127including clojure's ratios
15:22jwinterclojure.contrib.math url:http://github.com/kevinoneill/clojure-contrib/blob/a19a1d1921618fe802e57fb835eb98c2164e51ba/src/clojure/contrib/math/tests.clj
15:26tashafaquestion, this might not even apply to clojure so please forgive me
15:27cooldude127go for it
15:27tashafaim using the lazy-xml from clojure.contrib to parse xml from a url
15:27tashafaim getting the sax parse error "Content in prolog"
15:28tashafaand i know the cause
15:28Chousertashafa: what's the value of clojure.contrib.lazy-xml/has-pull
15:28Chouseroh.
15:29Chousergood, then. :-)
15:29lisppaste8ayrnieu pasted "n-binding when-let" at http://paste.lisp.org/display/76480
15:29tashafathe xml from the server doesnt start with <?xml ... ?>
15:30tashafaanyway i can modify the stream before i send it to parse-trim
15:31lisppaste8ayrnieu annotated #76480 "oh, right, we have zero? at this point" at http://paste.lisp.org/display/76480#1
15:32tashafaChouser: has-pull is false
15:33tashafaThe exact SaxParseException is "Content is not allowed in prolog."
15:33Chousertashafa: ok, that just means you're a sax parser (instead of pull parser) running in its own thread using a blocking queue for communication with the main thread.
15:35tashafaok... so i need to chage has-pull to true?
15:35Chousernono, it's fine.
15:35Chouserbut since you were getting an error from the parser, it might be useful to know which parser.
15:36Chouserif you don't specify one, it'll use the pull parser if available, otherwise the builtin sax parser
15:37tashafahas-pull is def'ed false
15:37cemerickayrnieu: looks good, but it should probably assert (pos? (count bindings)) too
15:38tashafaso i dont see how it would use parse-seq-pull which in turn usess the pull parser
15:39ayrnieucemerick - (let [] ...) also works. The user doesn't need to be protected here, and it helps with macros over when-let [including when-let itself, here].
15:40cemerickah, I didn't realize that (let [] ) worked.
15:40tashafai do have XPP in my calss path
15:40tashafaclasspath*
15:42lisppaste8ayrnieu annotated #76480 "grammar-fix in assert string" at http://paste.lisp.org/display/76480#2
15:43tashafaunless i change lazy_xml/has-pull to true in the source
15:44tashafawhich i dont want to do
15:44tashafa:-/
15:47ayrnieu(def x 1) (.bindRoot #'x 2) x => 2
15:49tashafaanyways back to the original question
15:50tashafacan a stream be modified before being used?
15:50tashafaif so, how?
15:51pjstadigso after some tests with a simple java app...
15:52pjstadigit appears that I shouldn't expect Boolean.TRUE to be == across VMs
15:52pjstadigI could make Boolean.TRUE a root so that it is the same instance across VMs, but I get an error when I try to do that
15:53pjstadigso they either need to be compared using equals or .booleanValue == .booleanValue
15:53pjstadigor i could create another static field make it a root and make sure that field is always used instead of Boolean.TRUE and Boolean.FALSE
15:54pjstadigwe almost have that with RT.T and RT.F, but there are some cases where Boolean.TRUE and Boolean.FALSE are used directly
15:55tashafalet me rephrase...
15:56tashafaall i need to do is parse some xml, the xml is valid but has no prolog and i have no way to modify the stream
15:57tashafato add the prolog
15:58tashafaactually its the xml declaration
15:58tashafaand i think the saxparser chokes on this
15:58Chousertashafa: (load "lazy_xml/with_pull") is supposed to re-def has-pull if it successfully loads xpp
15:59tashafaChouser: but (load "lazy_xml/with_pull") is only called when has-pull is true
16:00tashafa([s] (if has-pull (parse-seq-pull s) (parse-seq s startparse-sax)))
16:00tashafa(defn- parse-seq-pull [& _]) (try (load "lazy_xml/with_pull") ...
16:01dcnstrctClojure + HtmlUnit FTW!! it's the ultimate web-interaction testing system. It totally blows away any of the Ruby libs for this kind of thing.
16:01tashafaor i'm i missing somethign
16:02tashafabrb... meeting :(
16:03Chousertashafa: no, that code is unusual and confusing. It may be buggy, but not in the ways you've mentioned yet.
16:03Chousertashafa: feel free to ping me when you get back.
16:03dcnstrctinfact I'm finding so many java libraries that are better than most of the Ruby stuff I'm used to dealing with.. it's just that they were so painful to use before.. but now...
16:07jwinterwhat are you comparing HTMLUnit to?
16:13Hookehi
16:18Rayneshttp://groups.google.com/group/LSharp/browse_frm/thread/f966f9a809cc702b Read what Rob said. (Yes this is relevant.)
16:22tashafaIm back
16:22ChouserHooke: hi
16:23Hookehi Chouser :)
16:23Chousertashafa: the 'try' is not part of the definition of parse-seq-pull. It could probably do with a blank line in there.
16:24tashafaah
16:24tashafai see
16:24Chouserif you really want to try using xpp, which may or may not solve your real problem, you could try commenting out the try and catch parts
16:25Chouserthat should give you a stack trace of what's actually failing in with_pull
16:29tashafaok, so there isnt a way to add the xml declaration to an xml stream
16:31ChouserI'm surprised you need it. let me try some things..
16:32Chouserok, the xpp parser doesn't complain when given a correct xml document with no <?xml?> header.
16:35tashafacool
16:36tashafaaight let me see whats up
16:36tashafaIT keeps deleting my .emacs file
16:36tashafathey think its some sort of virus file
16:37hiredmanmakes sense to me
16:40shooverHooke: I'm happy for you and sad that the conquest merits such elation
16:40shoovertashafa: THAT is a new one
16:41shoover+1 for emacs, -1 for emacs. dead even yet again
16:41Hookeshoover: thanks, .. I guess :D
16:43Chousertashafa: I also get no error with the standard SAX parser. I think your problem must be somethine else?
16:44tashafaChouser: for real
16:44tashafashoover: if it doesnt look like a windows file and its sitting in root they delete it
16:45Chouser(clojure.contrib.lazy-xml/parse-trim (java.io.StringReader. "<foo/>"))
16:45shoovertashafa: that's understandable. can you put it in your user profile directory?
16:46tashafayeah thats what i need to do
16:49tashafachouser: if i give you the url to the xml could you try it on your end?
16:49Chousersure
16:50tashafapm'ed
16:56cemerickif-let has the same limitation of a single binding form as when-let. That probably makes more sense, though (especially since one wouldn't know what bindings are false in the else branch).
17:02ayrnieucemerick - 'none of them' is wise.
17:05cemerickayrnieu: what made me think of it is a situation where I needed to test whether any of a set of bindings were true, so I don't know about the friendliness/obviousness of that.
17:10Raynes(doc defonce)
17:10clojurebotdefs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated; arglists ([name expr])
17:10RaynesLot's of def's.
17:23replacatashafa: re: .emacs on Windows, you can set your HOME environment var and then put your .emacs file there instead of in c:\
17:25tashafaChouser: figured it out
17:25Chouserah, great, what was it?
17:26tashafathe respponse from the server is compressed
17:26tashafagzip
17:26Chouserah, ok.
17:26tashafanow to figure out how to umcompress
17:27Chouserthere's a java library for that! TM
17:27tashafaun*
17:28Chouserjava.util.zip.GZIPInputStream
17:29tashafathanks
17:39cmvkkit's not safe to use | as a symbol right?
17:40cmvkkor rather, it's possible/likely that it will be used for something in the future?
17:47tashafachouser: golden! thanks for all your help man!
17:47tashafaChouser: golden! thanks for all your help man!
17:49kotarakcmvkk: the allowed characters for a symbol are detailed on the clojure site: http://clojure.org/reader I would only rely on those.
17:51cmvkkkotarak, yeah, that's why I asked, actually. Just wondering if there was any updated information along those lines.
17:51cmvkkthanks though
18:01tashafaftw, add an item to the end of a list?
18:02jakewinsHi! I'm really wanting to try clojure out, but I am something of a newbie in Java-environments, and as such am having trouble getting my first clojure project to run.
18:02jakewinsCould someone point me to a hello-world example or something?
18:02tashafa,"hello world"
18:02clojurebot"hello world"
18:02jakewinslol
18:03jakewinsThanks. I need it to build together with a java application though,
18:03tashafajakewins: do you already know your way around the repl?
18:03jakewinsTashafa: I know my way around nothing, I am afraid
18:04tashafawhat exactly are you trying to build
18:05tashafaor from what programming language are you coming from
18:05tashafa?
18:05tashafaweb, desktop, etc..
18:05jakewinsPhp mostly, some c
18:06jakewinsAnd I know java as a language, ie, I can write pretty decent applications
18:06jakewinsSo I can get a normal java app to run without any trouble
18:06jakewinsWhat I want to do is go into "clojure-land" from my java class
18:07jakewinsOne sec
18:08tashafaftw, add an item to the end of a list? cons
18:08tashafagod, im losing it today
18:08jakewinsFrom my main()-method in java, I run something in the likes of
18:08jakewinsclojure.lang.RT.var("com.example.clotest.test", "main").invoke(args);
18:08jakewinsWhich indeed launches clojure
18:09jakewinsBut it launches it into the interactive-loop
18:09jakewinsor whatever it's referred to as
18:09jakewinsie. I don't think it even runs the clojure function "main"
18:10tashafanah...clojure doesnt work anything like java
18:10Hookejakewins, I'm new too, but I'd say that the first you have to decide is what IDE to use. if you want netbeans, there the "enclojure" plugin. if you like emacs, there's clojure-mode
18:11jakewinsTashafa: Which is what I'm after :) My companies clients demand stuff that runs on java-platforms, but I'm not a fan of java, which is why i'd like to try this out
18:11jakewinsHooke: I use eclipse
18:11jakewinsI found a clojure plugin for it, I haven't been able to figure out if it's any good though
18:12jakewins*company's, sorry bout the spelling
18:12tashafai tried the eclipse plugin for clojure a while back and it was a bit immature, dont know how well it fairs now
18:12Hookeah, yeah, I installed that one too. didnt try it much though
18:13tashafafares*
18:13jakewinsHooke, tashafa: I dunno, I haven't been able to really try it yet :)
18:14Hookenow I configured emacs according to http://riddell.us/clojure/
18:14Hookeif you do emacs, i think thats best
18:14tashafai'm also coming from eclipse... i would suggest emacs
18:14Hookeespecially the example, ants
18:14Hookeants.clj
18:14jakewinsHmm.. I'll definately looked into that
18:14Hookevery impressive
18:14tashafaits a step learning curve, but worth every minute once you are comfortable
18:15Hookeif you try emacs, try the paredit mode
18:15tashafaants.clj is pretty much on the advanced side
18:15jakewinsTashafa: I gave emacs a shot a while back, and I can see that once you've got the basic keyboard-shortcuts down it will rock your world
18:16tashafawhat is the paredit mode anyawas
18:16cp2ants.clj is my favorite :)
18:17Hooketashafa: it's for never having unballanced brackets
18:17jakewinsOh well, I'll dig deeper into this at work tomorrow, I've gotta get up in 7 hrs
18:17jakewinsThanks for your help guys
18:18tashafaim i just turn on the Paren Hihglight matching
18:18tashafajakewins: come back on tomorrow
18:18tashafawe'll be here
18:18Hookeall commands do things to sexprs, like splice, nest, and so on, without ever deleting a bracket on one side only
18:19tashafahmm i have to try it out
18:20Hookehttp://www.emacswiki.org/cgi-bin/wiki/ParEdit
18:20tashafaftw, add an item to the end of a list? cons -> false
18:22Hookehttp://mumble.net/~campbell/emacs/paredit.html
18:24Hooketashafa: sorry, I dont get what you mean
18:25tashafaHooke: sorry i was asking how you would add an item to the end of a list
18:26Hookeah, yeah, I understand that, but .. do you mean bringing an item from outside or writing it .. I mean, write it you always can
18:26tashafafrom outside
18:26Hookebringing it from after the list would be the command paredit-forward-slurp-sexp
18:26tashafai guess
18:27tashafanah not talking ide anymore
18:27HookeC-), C-<right>
18:28Hookeahm, sorry, what are you talking about now?
18:28tashafa,(cons '( 1 2 3) 4)
18:28clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
18:29tashafa,(conj '( 1 2 3) 4)
18:29clojurebot(4 1 2 3)
18:29schoppenhauer,blah
18:29clojurebotjava.lang.Exception: Unable to resolve symbol: blah in this context
18:29tashafa,(cons 4 '( 1 2 3))
18:29clojurebot(4 1 2 3)
18:29schoppenhauer,(lambda () ())
18:29clojurebotjava.lang.Exception: Unable to resolve symbol: lambda in this context
18:29schoppenhauer,(fn () ())
18:29clojurebotjava.lang.NullPointerException
18:29schoppenhauer,(fn [] )
18:29clojurebot#<sandbox$eval__7396$fn__7398 sandbox$eval__7396$fn__7398@3813c>
18:30schoppenhauer,(do (fn []) (fn []))
18:30clojurebot#<sandbox$eval__7402$fn__7407 sandbox$eval__7402$fn__7407@12421db>
18:30schoppenhauerscnr
18:31tashafais it even possible to add to the end of a list cause of lazy-seq?
18:32tashafa,(conj [1 2 3] 4)
18:32clojurebot[1 2 3 4]
18:32hiredman,(concat '(a b)
18:32clojurebotEOF while reading
18:32hiredman,(concat '(a b) '(c))
18:32clojurebot(a b c)
18:32hiredmanbut don't do that
18:32tashafaok...
18:32hiredmanlists are for fast adding to the head
18:32tashafachange to a vec and conj that
18:33hiredmanugh
18:33tashafavec the list and then add it to the end
18:34hiredmanI guess, but it would be to either always use a vector or always use a list
18:34tashafaturn the list into a vector and conjoin the item?
18:35hiredmanyou just said the same thing three times in a row
18:35hiredmanand I said "ugh" the first time
18:35tashafasorry i thought you didnt understand what i said
18:35hiredman,(time (vec (range 1000)))
18:35clojurebot[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 13
18:35clojurebot"Elapsed time: 0.999 msecs"
18:36Hooke,(+ 2 2)
18:36clojurebot4
18:36hiredman,(time (do (vec (range 100000)) nil))
18:36clojurebot"Elapsed time: 66.523 msecs"
18:36hiredmanI guess that could be acceptable
18:39tashafano p i was applying a list to a partial struct ...
18:39tashafaso i jest changed the structure of the list
18:39tashafaso i just changed the structure of the defstruct*
18:39tashafaif that makes any sense
18:40tashafai need to take a break...
18:40tashafamy typing is awful
18:40tashafagoodnight folks
18:40Hookegnite taggart
18:40Hookesorry
18:40Hookegnite tashafa
19:14stuhood,(class (vec (range 10)))
19:14clojurebotclojure.lang.LazilyPersistentVector
19:14stuhoodhiredman: i thought 66ms looked suspicious... heh
19:15stuhood,(class (doall (vec (range 10))))
19:15clojurebotclojure.lang.LazilyPersistentVector
19:16stuhood~source vec
19:17stuhood,(class (to-array (range 10)))
19:17clojurebot[Ljava.lang.Object;
19:18stuhoodnevermind... it wasn't actually being lazy. it's just that fast
19:48yonatan__newbie question: any way to get a stack trace on an exception?
19:49yonatan__i'm getting "java.lang.IndexOutOfBoundsException (bitmap.clj:0)"
19:49yonatan__how do you debug this?
19:52Chouseryonatan__: you're at a regular repl?
19:52yonatan__yeah
19:52Chouser(.printStackTrace *e)
19:52yonatan__thanks!
19:54Chousernp
19:55Drakesonis this: (import '(org.postgresql Driver)) supposed to work, when I have obtained http://jdbc.postgresql.org/download/postgresql-8.3-604.jdbc4.jar ?
19:57Chouseryes. That .jar must be in your classpath.
19:58Chouseror must be in a directory named by -Djava.ext.dirs=
20:02DrakesonChouser: thanks
20:02jhawk28related to Issue 34: is there any good way to access the value of a Var in the dynamic scope on the Java side?
20:07jhawk28I can look up the var using the find method, but it has the global value instead of the dynamic scope
20:09Chouserjhawk28: you'd have to be within dynamic scope, of course, but then you should be able to call the .get() method
20:33jhawk28chouser: I think my issue is the dynamic scope
20:42jhawk28Chouser: is there a reason why the eval reader does not have visibility of the *myVar* in: (binding [*myVar* false] #=(eval (def x 3)))
20:43Chouserforms are processed in several phases. string->data which is called "read", and that's when the #=() form is evaluated.
20:43Chouserthen compilation, then eval.
20:44jhawk28so, even though it is in the scope from a lexical perspective, it is not actually in the dynamic scope?
20:45ayrnieujhawk, #=() is also not in the form's lexical scopes.
20:46hiredmanthe answer is, don't use #=
20:47ayrnieujhawk - it's as if you were copying some text from one page to another by hand, and you resolved to always replace lowercase symbols with uppercase symbols, to always replace 'foo with (quote foo) , etc. So you do this -- and this is when #=() happens -- and *then* turn to what you've written and say: should I expand any macros, here?
20:47ayrnieuthe answer is: understand what you're doing.
20:49jhawk28hehe
20:50gnuvince_Anybody knows git here?
20:50ayrnieugnuvince - ask a question about it.
20:54gnuvince_I think I found it
20:55gnuvince_I had committed and pushed a file with a DB password
20:55gnuvince_I wanted to rewrite the history
20:55gnuvince_I think I found it
21:37yangsxwhat is the best way to get the numeric value of a char?
21:37ayrnieu,(int \a)
21:37clojurebot97
21:39yangsxayrnieu: thanks, I thought that's for numbers :)
22:02hiredman~translate to ru: they just chug half-and-half in the morning
22:02clojurebot??? ?????? chug ??????? ? ?????? ???????? ???
22:06drewr~translate to es: clojurebot is so crazy
22:06clojurebotclojurebot es tan loco
22:12jhawk28clojurebot: where are you?
22:12clojurebothttp://github.com/hiredman/clojurebot/tree/master
22:56felzixI find that if I define function A before function B then A cannot call B. Is there a way around this?
22:57hiredman,(doc declare)
22:57clojurebot"([& names]); defs the supplied var names with no bindings, useful for making forward declarations."
22:57felzixah, thank you :)
22:58cooldude127is there any difference between def and declare in that case except that declare accepts multiple names?
22:58cooldude127i.e. (def x) == (declare x) ?
22:59felzixcooldude127: no
22:59felzixit just maps over what you supply, def'ing it
23:00felzixbut you can do lots at once :)
23:00cooldude127felzix: so for the single case, it is the same?
23:00cooldude127that's what i was asking
23:00felzixyes
23:00cooldude127k, cuz i had been using def for that purpose
23:00cooldude127didn't even know declare existed
23:02felzixme either. I'm still fuzzy on how globals work in clojure so I wasn't sure I could def things like that
23:04cooldude127we don't call them globals :)
23:04cooldude127do we?
23:04hiredmandef once, run anywhere
23:05cooldude127lol
23:05felzixah
23:06Chouserthey do the same thing, but they imply different things to the human reader.
23:06Chouseruse 'declare' for forward declarations that will be re-def'ed.
23:06cooldude127yeah i figured that was the ideal way
23:07Chouseruse 'def' with no initial value for things that you will thread-local bind later.
23:27dreish~translate to ru: I can eat glas, it does not hurt me.
23:27clojurebot? ???? ?????? Glas, ??? ?? ?????? ???.
23:27cooldude127where did that sentence come from?
23:27dreishIf I'd spelled it correctly, it would have come from http://www.geocities.com/nodotus/hbglass.html
23:27dulanov~trabsltae to ru: It makes a lot more sense when we start adding multiple domains, users and aliases to our setup.
23:28clojurebotexcusez-moi
23:28dreishWhich is in turn devoted to a long-extinct page from I'll say 1995.
23:28dulanov~translate to ru: It makes a lot more sense when we start adding multiple domains, users and aliases to our setup.
23:28clojurebot??? ?????? ?????? ?????? ????????, ????? ?? ???????? ??????? ????????? ???????, ????????????? ? ?????????? ??? ????? ?????????.
23:50cooldude127can clojurebot translate to other languages?
23:51cooldude127~translate to es: your mother
23:51clojurebottu madre
23:51cooldude127that answers that
23:53slashus2su madre?
23:53cooldude127tu madre is the informal version
23:54cooldude127~translate to es: I'm on a boat mother fucker, don't you ever forget
23:54clojurebotEstoy en un barco de puta madre, �nunca se olvide
23:54cooldude127lol
23:56cooldude127~translate to es: I'm on a boat, mother fucker, don't you ever forget
23:56clojurebotEstoy en un barco, hijo de puta, no te olvides nunca
23:58cooldude127~translate to ro: I'm on a boat, mother fucker, don't you ever forget
23:58clojurebotSunt pe o barca, mama fraiere, nu te mai uita