#clojure logs

2009-06-30

00:24sethsany chance that Chouser is online? Does the trailing underscore mean afk?
00:25slashus2seths: I think it means that he was disconnected, and reconnected to have his original name in the room.
00:26AnniepooI've got an idiot beginners question, no point in spamming the channel, anybody willing to help me get a file to compile as a java class?
00:28sethsslashus2: thx from an IRC newbie
00:29Anniepoodo I point classpath at the root of the package tree like Java?
00:37newbie_Hi all, what is ethic for asking questions do i just type in to the main channel chat?
00:43Anniepoonewbie, I think the channel is a lot deader than it appears from the number of people subscribed
00:44AnniepooI'm striking out about 50% of the time with newbie questions, and I don't think I'm being obnoxious or overusing the resource
00:45AnniepooI'd try to answer, but I'm a complete noob
00:47newbie_thanks, i have a function that reads tokens from a input stream and create map of it one input for key one input for value but it justs makes the repl lock up no error nothing it goes in to a infinite loop
00:47newbie_(defn process-map [ stream ]
00:47newbie_ (loop [ result {} ]
00:47newbie_ (let [c (char (.read stream) ) ]
00:47newbie_ (if (= c \e )
00:47newbie_ result
00:47Anniepoohang on
00:47newbie_ (recur (assoc result (get-next stream (int c) ) (get-next stream (int c) ) ) )
00:47newbie_))))
00:48Anniepoolisppaste8: url?
00:48lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
00:48Anniepoodo that instead
00:48newbie_kk
00:49lisppaste8newbie_ pasted "loop" at http://paste.lisp.org/display/82739
00:50replacanewbie_: how are you running? straight repl from shell?
00:51newbie_repl from within emacs, using C-x C-e
00:52replacammm, and is stream set to *in* or some other file
00:52newbie_btw, stream is an input-stream
00:52replaca?
00:52replacaoh. ok
00:53replacawhat do you think \e is?
00:53replacait isn't eof, you know...
00:53newbie_it marks the end of the token stream it is not eof
00:53replacait's the letter 'e'
00:53replacaok
00:54newbie_i want processing to stop when it sees e char
00:54replacathe code looks ok to me (hard to tell completely without sseeing the input stream and other funcs)
00:55replacaI'd put some prints in to see how it's going in the loop
00:56replacaI use the prlabel func in c.c.pprint.utilities for this: (prlabel place val1 val2 ...) prints place val1=(it's val) val2=...
00:56replacait's a macro, so it's pretty easy
00:57replacabut a simple print would work just fine too
00:57newbie_thx i'll look in to it.
00:58replacanewbie_: sorry i couldn't be more help
00:59newbie_np
01:00newbie_is there a possibility that both get-next functions are called at the same time causing the sequence in the input stream to mess up? because if i call get-next manually couple times i get my tokens just doesn't work in the loop?
01:05replacashouldn't be in that case
01:06replacaI'd say they'd be called in sequence
01:06replaca(although I'm not sure if left to right order is guaranteed)
01:08replacaI'd try (let [key-val (get-next) val-val (get-next)] (print key-val val-val) (recur (assoc result key-val val-val)))
01:08replacaand see what that tells you
01:09replaca(with some extra decoration on the prints to make them easier to read)
01:11newbie_kk thanks i was wondering how to reformat it like that.
01:11replacanewbie_: what's your language background?
01:12newbie_java,c++ mostly and a bit of elisp
01:13newbie_but since i tried lisp i figured i did not know anything about lisp. elisp clojure so much difference
01:13newbie_* clojure
01:13replacacool, then you'll want to use (println (format "%s: %s" key value))
01:13replacayeah, clojure is its own thing. A lot nicer than elisp, once you get the hang of it
01:15replacaoh, you know you're reading a char before you even start your loop, right?
01:15newbie_yeah to see if the token stream ends.
01:17replacaok, so that supports the 0 token case
01:18replacayou might try a file that begins with 'e' as a base test
01:18newbie_ok
01:21samwisemwould someone be able explain to me why it was decided to remove 'lazy-cons' from clojure?
01:24replacasamwisem: it's part of the "new" lazy seq architecture which makes laziness much more general and pervasive in Clojure. See http://clojure.org/lazy for some of Rich's notes
01:25replacasamwisem: you use the "lazy-seq" macro now
01:25samwisemok
01:25samwisemthanks i'll read that
01:26newbie_one more question replica, can i turn a vector or a list in to map? cause instead of creating the map directly i can read everthing in a vector or list and create if from that?
01:28kotarak,(apply hash-map [:a 1 :b 2 :c 3])
01:28replacanewbie_: yeah, create a vector v of tuples [[k1 v1] [k2 v2] ...] and then do (into {} v) and, voila, a map
01:28kotarakNo clojurebot -.-
01:28replacaor kotarak's way too :-)
01:28kotarakIt depends on how the list/vector looks like.
01:28replacayup
01:29kotarakor (zipmap [:a :b :c] [1 2 3])
01:31replacaa beautiful part of clojure is how easy arbitrary transformations are!
01:31kotarakreplaca: yeah! that's awesome. The ease of use of the appropriate data structure.
01:56newbie_i was testing the following in repl but it gives me classcastexception (into {} (partition 2 ["test" "mest" "test2" "mest2"] ) )
01:57cp2whats the full message of the exception
01:58newbie_java.lang.ClassCastException: java.lang.String (NO_SOURCE_FILE:0)
02:04replacahmm, the problem is that partition is making seqs which are behaving differently than vectors here
02:04replaca(into {} (for [ [k v ] (partition 2 ["test" "mest" "test2" "mest2"])] [k v ]))
02:04replacaworks, but is ugly
02:06replacathis seems like a bug to me, but who knows...
02:06replacahowever, kotarak's (apply hash-map ...) is a better sol'n here and works fine
02:08newbie_thanks for pointing that out i missied his message
05:56mauritslamersquestion: I seem to have a problem importing the right class. That is: I import the class, but when I want to use it, it returns no matching ctor found for class
05:56lisppaste8mauritslamers pasted "clojure-javax-sound" at http://paste.lisp.org/display/82749
05:57Chousukemauritslamers: you don't want the [] around the parameters
05:57mauritslamersah ok :)
05:57Chousukemauritslamers: also, the closing parens are typically on the same line, not on their own like in C
05:57mauritslamersI know :)
05:58mauritslamersBut it confuses me :)
05:58mauritslamersI have a small bit of Lisp experience
05:58Chousukebetter get used to it.
05:58mauritslamersBut I keep getting confused where something ends
05:58Chousukethat'll only last a while
05:58Chousukeas long as you indent properly
05:59Chousukeand have a decent editor )
05:59Chousuke:)
05:59mauritslamersusing eclipse at the moment, so the editor is reasonably decent :)
05:59Chousukehmm, I don't know about the eclipse plugin
06:00ChousukeI guess it does paren highlighting
06:00mauritslamersit does
06:00Chousukeanyway, most clojure code will use the lisp convention, so you'll need to get used to it in any case. It's better to go with the flow in this case
06:02mauritslamersChousuke: mmm normally I have an innate problem going with the flow :)
06:04mauritslamersChousuke: this is how code looks like in Eclipse: http://skitch.com/mauritslamers/bsyri/javasound.clj-eclipse-platform-users-maurits-development-eclipse-workspace3
06:04ChousukeUnderstandable. But in this case you'll just end up making things more difficult for yourself.
06:05mauritslamersThanks for the advice :)
06:06Chousukehttp://mumble.net/~campbell/scheme/style.txt here's a style guide for scheme. It can be applied to Clojure
06:07kotarakThere is also a "Why good style matters" or something similar. Also a funny read. :)
06:07mauritslamerssecond question: I want to write the following Java line as a clojure function: new DataLine.Info(SourceDataLine.class, DSP_AudioFormat);
06:07ChousukeInfo is an inner class?
06:08Chousuke(DataLine$Info. SourceDataLine DSP_AudioFormat) should work
06:08Chousukenote the .; it's shorthand for new
06:09kotarakah, there it is: http://www.cs.umd.edu/~nau/cmsc421/norvig-lisp-style.pdf
06:11mauritslamersI was calling (. SourceDataLine class) instead of just SourceDataLine
06:11mauritslamersthat 'll be the issue
06:11mauritslamersthanks!
06:12Chousukethe other shorthands are Math/PI (equivalent to (. Math PI) or (Math/min 5 4) (. Math (min 5 4)) for static fields/methods and (.toUpperCase "bar") which is (. "bar" toUpperCase) for instance fields/methods. Please use these instead of using . directly
06:12Chousukefor method chaining, the -> macro is good to learn
06:14Chousukefor example, you can mix clojure and java: (-> "foobar" .toUpperCase (subs 3 6) .intern); yields "BAR", interned :P
06:14kotarak... and doto for side-effects. (eg. configuring a fresh object)
06:17Chousukethe magic is that (-> foo (bar whatever)) becomes (bar foo whatever). ie. the previous expression is put as the first argument of the of the next expression, which repeats until there is no more to replace
06:18Chousukeso the previous example becomes (-> (.toUpperCase "foobar") (subs 3 6) .intern) --> (-> (subs (.toUpperCase "foobar") 3 6) .intern) --> (.intern (subs (.toUpperCase "foobar") 3 6))) -> "BAR"
06:36mauritslamersAnother question: how to cast a result of a function to an interface in clojure? the original java line is (SourceDataLine) AudioSystem.getLine(dataLineInfo);
06:36mauritslamersI want to be able to call the open method on the result, but I get "no matching method found"
06:37mauritslamerswhich is true, as the object is of the wrong type (MixerSourceLine instead of SourceDataLine)
06:40mauritslamersI tried (cast SourceDataLine (AudioSystem/getLine info)) but that did not result in having a SourceDataLine instead of a MixerSourceLine
06:41AWizzArd,(doc cast)
06:41kotarakIf MixerSourceLine implements the methods it should be found.
06:42AWizzArd([c x]) Throws a ClassCastException if x is not a c, else returns x.
06:42AWizzArdIt seems that the function cast does not do casting.
06:42kotarakAWizzArd: it doesn't need to.
06:43mauritslamersMixerSourceLine does not implement the methods ... otherwise the casting wouldn't be necessary :)
06:46AWizzArdMaybe you can give a type hint? Where do you introduce the var?
06:46AWizzArd(let [#^SourceDataLine sdl (AudioSystem/getLine info)] ...)
06:47mauritslamersI was looking into that indeed
06:47mauritslamerschecking...
06:52mauritslamerscompiling correctly now, no method problem anymore :)
06:52mauritslamerslet's write some sine function to create sound :)
06:55AWizzArdgrats
06:56AWizzArdAnd good to know that it works this way. We all can try to remember it :-)
06:58mauritslamerssadly it does not entirely
06:58mauritslamersI'll paste the function.. moment
06:59lisppaste8mauritslamers pasted "clojure casting" at http://paste.lisp.org/display/82750
07:00mauritslamersThe type hinting does seem to work
07:00mauritslamersbut does not seem to be able to return with the return value of the function
07:00mauritslamerstypehinting it again to be able to use the write function does not work: method not found
07:18hoeckmauritslamers: the get-sound-out function returns a MixerSoundLine here
07:18hoeckI mean a com.sun.media.sound.MixerSourceLine
07:28Chousukeyou shouldn't need to cast.
07:31mauritslamershoeck: it does here too
07:31mauritslamersit should be a SourceDataLine however
07:31mauritslamersmaybe the Java code I am trying to port is flawed in that manner
07:33mauritslamerssearching into the java stuff, it seems that there are other function to solve this issue
07:33mauritslamersgetSourceDataLine instead of getLine
07:35hoeckmauritslamers: it is a SourceDataLine (which is an interface according to my javadoc)
07:35mauritslamersmmm
07:36hoeckmauritslamers: try (supers (type (get-sound-out ...)))
07:36hoeckso it implements the two open method
07:37hoeckno matching metho found also happens if you call an existing method with the wrong parameters
07:37hoecklike (.toString (Object.) "a")
07:38mauritslamersyou're absolutely right, I must be sleeping over here :)
07:38mauritslamersdidn't think of that
07:38Chousukethe .open method call works just fine for me.
07:38ChousukeI get a mixersourceline out of get-sound-out with no errors
07:39mauritslamerssupers returns: #{javax.sound.sampled.Line java.lang.Object javax.sound.sampled.DataLine javax.sound.sampled.SourceDataLine com.sun.media.sound.AbstractLine com.sun.media.sound.AbstractDataLine}
07:39hoeckexactly
07:39ChousukeI wonder what use the cast operation is in Clojure :/
07:39Chousukeother than asserting that an object is of a certain class.
07:40mauritslamersChousuke: that also works for me, but then writing didn't work
07:40mauritslamersbut probably because I did not call the method correctly
07:40mauritslamersstupid me :)
07:41Chousukeheh
07:41hoeckmauritslamers: well, java api's are sometimes a bit weird, especially when driven from clojure :)
07:42mauritslamersthe error is completely understandable, because it is more or less the same as the java error message
07:43mauritslamersbut the clojure error is a little less verbose...
07:43mauritslamersand therefore a bit confusing :)
07:47hoeckmauritslamers: please continue the sound example, I'm interested in playing "hello sine" from the repl :)
07:48mauritslamershoeck: I most certainly will :)
07:49mauritslamersannotating code on paste.lisp.org to contain the latest version of the code
07:50lisppaste8mauritslamers annotated #82750 "clojure sound" at http://paste.lisp.org/display/82750#1
07:51achimhi all!
07:51hoeckhi!
07:51mauritslamerswhen doing (try (.write soundout (take 100 sine) 0 100)), I am getting a class cast exception
07:52hoeckmauritslamers: yes, write wants a byte array
07:52achimdoes anybody have some pointers on diff'ing trees/nested data structures?
07:53mauritslamersI was hoping clojure would to the conversion automatically :)
07:53hoeckyou have to convert the seq to an array, like (into-array Byte/TYPE .. seq of bytes
07:53mauritslamershoeck: great!
07:53achim(not a very clojure-specific question, i know ...)
07:54hoeckmauritslamers: and don't forget to (map byte (take 100 sine)), cause the literal clojure numbers are not Bytes
07:55mauritslamersexactly the issue I was running into :)
07:56mauritslamersworking!
07:57hoeckmauritslamers: so just feeding the bytes into the mixer works? no extra methodcalls like start?
07:58lisppaste8mauritslamers annotated #82750 "working clojure soundout" at http://paste.lisp.org/display/82750#2
07:58mauritslamersThat is already done in the get-sound-out function
08:00mauritslamersIt is easy now to create some function that just takes any seq of numbers and just output them...
08:00mauritslamersthat function could just allocate a source data line on the fly, play the data and next close the source data line again
08:03maacl_Is there a way to use amap on a 2-dimensional array (e.g. (make-array Integer 8 8))?
08:05hoeckmauritslamers: cool, but can't hear anything on my machine :(
08:05mauritslamers?
08:06mauritslamershoeck: mmm
08:06mauritslamershoeck: are you using the code as I just pasted it ?
08:06hoeckyes, but its probably my broken sound setup + linux
08:07mauritslamersthis setup should normally play to the standard output
08:11hoeckmauritslamers: it works! had to issue a (.start soundout) and then it played!
08:11mauritslamersgreat :)
08:11mauritslamerswas already trying to upload a small sample
08:12mauritslamersstrange that the (get-sound-out) function did not start the soundout then..
08:12hoeckmauritslamers: thanks for this sound example, way better to show off than hello-worlds or fib :)
08:12mauritslamersyw
08:12mauritslamersit is a kind of starters thing for me with clojure
08:12mauritslamersjust trying to get something to work
08:13mauritslamers:)
08:13mauritslamersnext task: write a lazy sine function
08:13mauritslamerswithout trying to iterate it....
08:13mauritslamers(which is the first thing that comes to my mind ... :[)
08:14mauritslamers:[
08:15mattreplhow about a recursive "echo"? =)
08:18mauritslamersmattrepl: always nice :) Reverb is a damped recursion anyway
08:19hoeckmauritslamers: you did write a lazy sine, with cycle, now you just need to generate the cycled seq from parameters
08:19mauritslamershoeck: I know... but I don't see how I can generate such a lazy sine as a function :)
08:20mauritslamershas to be my part-functional - part imperative mindset :)
08:21mauritslamersa sine has a few parameters in this case: frequency samplerate and length
08:21mauritslamersfrequency and samplerate can just be put into the formula
08:21mauritslamersbut the length is a different matter in my mind ...
08:22achimhmm ... frequency and sample-rate somehow translate to a step-width
08:23achimand then you have (lazy-seq value-for-step-1 (sine from-step-two one-step-less-than-before)) ;-)
08:24achimwell, that's cons, not lazy-seq. pseudocode! :)
08:24mauritslamersachim: afaik samplerate and frequency is not the stepwidth
08:25mauritslamerssamplerate on it's own is the stepwidth, and the duration tells us how many samples to generate
08:26mauritslamersbut you are right that they together determine what the minimum amount of samples is for one complete sine
08:26mauritslamerswhich can be cycled
08:26mauritslamersmost of the times this kind of generation is done by iteration
08:27mauritslamerscalculate the number of samples, have the frequency to generate, the volume and the samplerate in the formula and just generate the number of samples needed
08:28mauritslamersmmm I remember something from the videos.. repeat or something like that
08:35achimmauritslamers: hmm, are aou sure? suppose you're repeatedly stepping through a plain sin(x) from 0 to 2*pi to collect values for your seq. if you increase the frequency, you have to increase the step-width and if you increase the samplerate, you have to decrease the step-with
08:36mauritslamersachim: yep: formula is volume * sin( 2 * PI * (1/samplerate) * frequency)
08:36mauritslamersehhh.
08:36mauritslamersvolume * sin ( 2* PI * (1/samplerate) * frequency * counter)
08:37mauritslamersthat is better :)
08:37mauritslamersmost things can be precalculated except volume and counter
08:38mauritslamersso the calculation itself ends up with something like volume * sin(sine-factor * counter)
08:39achimi think we actually agree, i just put it confusingly. your sine-factor is my step-width
08:39mauritslamersah ok :)
09:11shooverdurka42: http://bitbucket.org/shoover/icfp it was fun but it doesn't work :(
09:14drewrI wish I had time to work on that this past weekend.
09:24shooverheh, the one open weekend all summer for me, it was like the perfect storm
09:43lpetitHi all
09:43lpetitWhat happened to clojurebot ?
09:43kotarakvacation?
09:43lpetitOr maybe moderated 'cause it was a Troll ;-)
09:44lpetitHi Meikel
09:44kotarakhehe
09:44kotarakHi Laurent
09:44kotarakWorking on the forms stuff.
09:45cgrandhi Laurent!
09:45lpetitHi !
09:45lpetitIf you folks are on #clojure in the middle of the work day, how come I'll do my work day anymore ! :-)
09:46kotaraklpetit: MTO here...
09:46Chouserkotarak: why's that?
09:47lpetitMTO ?
09:47kotarakeconomic situation, I'm not a programmer. I'm QA in electronic development of a big automotive supplier. (ABS, ESC, such things)
09:48kotaraklpetit: mandatory time off ("Kurzarbeit")
09:48rhickeylpetit: I have moderated a grand total of one person in 2100, with over 19000 emails
09:49lpetitrhickey : it really was a (not so fun joke), sorry if you thought I was trying to pass some hidden message
09:49rhickeyI just don't want people to get the wrong impression about moderation
09:50lpetitrhickey : I really appreciate the way you're able to maintain a respectful community , and I don't think you're abusing your power in any means
09:50rhickeyIt has been used extremely sparingly and with much regret
09:50drewrrhickey, BMFL
09:50lpetitI understand. Those certainly are hard decisions to take.
09:50kotarakM?
09:50ChouserWas it a difficult decision to make in this case?
09:51rhickeybecause I don't want people to think they can't criticize Clojure, then have, and do, and many good improvements have come about because of it
09:52rhickeyChouser: not difficult to make, but unfortunate. I value the integrity and tone of the group very much, this was the first real degradation
09:52ChouserOk. I thought the posts in question while definitely more emotionally provocative (via arrogance, unwillingness to take criticism, etc.) than necessary weren't entirely without content.
09:52drewrIs trolling the problem with c.l.l, or the attitude of the "upper crust" (supposedly non-trolls)?
09:53ChouserI'm not second-guessing your decision, just musing.
09:53lpetitrhickey : in the exact same time you decided to moderate, I had thought for myself "wow, what's happening with clojure ml, there's something wrong happening". Hopefully I think you made a good decision in the right timing
09:55rhickeyChouser: agreed, each time I tried to let it go hoping for a gentle conclusion, but 2000+ people on the list can't become subject to those kinds of diatribes and endless arguments. I am convinced c.l.l. is a serious detriment to Lisp and will not repeat that
09:55rhickeyin c.l.l., they let tolerate extremely abusive people who occasionally have some technical merit. That's not good enough
09:56Chouserrhickey: well, in this area as in so many others regarding Clojure, I'm glad you're the one that has to make the final decision, and I trust your judgement. Haven't been let down yet. :-)
09:57ChouserThough having said that, I've been inspired by some recent blogs to begin compiling a list of Clojure warts.
09:58lpetitmust go, bye
09:58ChouserThey're hard to find, but I have 3 so far.
09:58rhickeyI think the Clojure list is one of the best I've ever been a part of, due to everyone's mutual respect and helpfulness
09:59rhickeyChouser: should I wait for the blog? :)
10:01drewrPositive comments can get out of hand too. The "I got tingly thinking about Clojure at lunch today" and "I heart Rich" messages I can do without. (Not that I don't heart rhickey... who doesn't.)
10:01Chouserpart of the problem with the other lists I've seen is almost every item can be eliminated as incorrect, justifiable (IMO), or easily fixable (and likely to be fixed).
10:01Chouserdrewr: ha!
10:02Chousertingly is funny
10:03Chouserhm. one of my three is also very fixable. See, it's hard! That's use/require.
10:03Chouserwell, I guess what I want would be cause a breaking change, so maybe that's reason enough to include it.
10:04ChouserI think require should go away and use should not refer in all public vars (unless explicitly told to).
10:05Chouserthe other two have to do with string and character literals. :-P
10:08drewrMaybe the :use option for referring * should have profanity in it so people won't want to leave it in production code.
10:08drewr(:use [foo.bar :import-all-MY-MOMS-A-&%$@!])
10:08cemerickI've come to use require with a sensible :as name almost exclusively. Reminds me of my good ol' python days.
10:08Chousercemerick: good for you!
10:09Chouserunfortunately, 'require' won't let you bring in specific names, so you have to switch to 'use' which messes your indnentation and the order of the forms in your code
10:10Chouserdrewr: could just be insulting instead of profane
10:10Chouser(:use [foo.bar :import-I-am-a-careless-programmer-all])
10:11cemerickthe only consistent exception is one namespace we have with a metric ton of commonly-used spatial predicates
10:11drewrChouser: Nice :-)
10:13mauritslamersquestion: I am trying to create a lazy sine generating function, but I just seem to be unable to get my head around it... I keep thinking imperatively...
10:13cemerickthe most troublesome thing about use IMO is that its effects are point-in-time; e.g. A uses B, but if a new fn is added to B, it's not available in A until A re-uses B.
10:13opqdonutyep, we need some sort of automated reloading
10:13opqdonutimo
10:13mauritslamers(map #(Math/sin some-val) (range numberoftimes)) is not lazy, though it works of course :)
10:14opqdonutsome-val?
10:15mauritslamers(def some-val (* 2 Math/PI (/ 1 samplefrequency) * tone-frequency * samplenumber))
10:15mauritslamers:)
10:15mauritslamers(of course not defined in this way in my program :) )
10:15Chousersamplenumber -- that's an index into the resulting seq?
10:15mauritslamersyep
10:16Chousereverything else in there is a constant?
10:17mauritslamersit is the body of a function which returns the number of milliseconds in sound data
10:17Chouser(map #(Math/sin (* 2 Math/PI (/ 1 samplefrequency) tone-frequency %) (range numberofsamples))
10:17Chouserexcept I missed a )
10:17mauritslamersthat is more or less what i had indeed :)
10:18mauritslamersI was just wondering how a lazy version of that calculation would look like
10:18Chouserthat is lazy
10:18opqdonutrange generates a lazy sequence
10:18mauritslamersah, it is?
10:18opqdonutmap is lazy
10:18Chouser'map' returns a lazy seq
10:18mauritslamersah, that explains a lot!
10:18mauritslamersThanks!
10:23mauritslamersnext question: how could I rewrite that function in such a way that I can use (take numsamples (lazy-sine args)) on it?
10:25mauritslamersI can use the function the way it is now without problems of course, but I try to learn clojure this way :)
10:27opqdonutchange range to an infinite seq of consecutive integers
10:28Chouserthat is, (iterate inc 0)
10:28opqdonutimo (range) should do that
10:28opqdonutor (range 0)
10:28opqdonutand (range 0 n) being what (range n) does now
10:28ChouserIt already does: (range 0 Integer/MAX_VALUE)
10:28Chouser:-)
10:28opqdonut...
10:29Chouser(range 0 Long/MAX_VALUE)
10:29mauritslamers(take 10 (range 0)) => ()
10:30mauritslamerswould an infinite seq of integers run out of memory somewhere? I would guess that somewhere after 4 mil iterations it would break...
10:31mauritslamers*out of byte-space (so to say :) )
10:31opqdonutyeah
10:31opqdonutof course we could use bignums
10:31yangsxhi, what is the way to read an integer from a file in Clojure? I'm not so good at Java to find a way
10:32mauritslamersopqdonut: that would be a possibility, but I rather start at 0 every time... That works out better for the sound data too
10:33Chouseryangsx: (read-string (slurp "tmp.clj"))
10:33mauritslamersor a kind of intelligent round-robin, which calculates the max value as being the minimum of samples needed for one complete phase
10:34yangsxChouser: what if the file is binary?
10:36Chouseryangsx: hm, perhaps you can find what you need in java.nio.ByteBuffer?
10:37shoover(let [file (-> "blah.bin" (FileInputReader.) (DataInputReader.))]
10:38shoover(.readInt file))
10:40shooverexcept use with-open instead of let
10:41cemerickI nominate zip-filter for inclusion in core, FWIW.
10:44yangsxshoover: JDK6 does not have DataInputReader, but a DataInputStream
10:44shooverer, yeah, that. and probably FileInputStream
10:45Chousercemerick: I'm using enlive in my latest project where I could have used zip-filter.
10:46cemerickChouser: Noted. But then, I'm not using zip-filter for XML :-)
10:46Chouserooh, really?
10:48cemerickYeah. Still querying into a DOM, but it's not XML.
10:48cemerickit's funny how people equate DOM with XML, actually
10:48cemerickXML/HTML, that is
10:48Chouserso you're not using zip-filter.xml?
10:51cemerickno. I'm in the process of making a corollary for this particular DOM.
10:51Chousercool.
10:52cemerickof particular interest to you may be the fact that there are multiple relationship axes...e.g. there's containment, but also spatial, semantic, and logical relationships that one may want to query on
10:53cemerickwe've only worked out the containment and spatial ones so far, but the latter two will be coming soon (hopefully).
10:54Chouserinteresting. So are you having to deal with zip-filter's 'auto' concept?
10:55Chouserthat's the one bit of zip-filter I'm most easily embarrased by.
11:03cemerickChouser: no, Just started using it this morning, so I'm still internalizing it. I've just been using children (and not children-auto), and all's been well so far.
11:03yangsxjava.nio.ByteBuffer seems to me requiring more time reading the java API, with DataInputStream I cannot use .readInt directly, because the binary data is unsigned and Java Integer is always signed. I thus use .readByte, reorder the bytes and calculate the integer myself.
11:04opqdonutjava.nio is a horrible mess
11:04opqdonutimo
11:05yangsxI'm wondering wether there is a better way (given my lack of knowledge in Java).
11:09Chouseryangsx: google protobuf also has some raw byte-reading functions -- not sure if it would turn out any better for you though.
11:11rhickeytoo tricky? (ref-min-history aref) gets, and (ref-min-history aref n) sets
11:12Chousernope. Is good.
11:14yangsxChouser: thanks, I'll have a look at it.
11:15Chouseryangsx: http://code.google.com/apis/protocolbuffers/docs/reference/java/com/google/protobuf/CodedInputStream.html
11:17shoover`Chouser: is the irc log working part time for the summer? it seems to be 9 hours behind
11:20Chousershoover`: yeah, it's written inefficiently, and is syncing only once a day to spare my ancient hardware
11:20yangsxthat's libprotobuf-java in Debian
11:20shoover`Chouser: fair enough
11:21Chousershoover`: I've got an improved version 80% done (my inotify work is meant to support this) which when complete should sync pretty much instantly.
11:49AWizzArdChouser: do you think that Ants performs better on a, say, hexadeca-core machine?
11:49cemerickrhickey: this is deep mojo that I'm not really clear on, but shouldn't history and such be transaction-local arguments to sync, rather than being persistently tied to refs?
11:50ChouserAWizzArd: I'm stumped.
11:50AWizzArdwhy?
11:50shoover`AWizzArd: I heard it ran pretty well on 700+
11:51rhickeycemerick: no, history is about the ref itself, seen by all transaction using it
11:51AWizzArdWhere did you hear that shoover`? rhickey himself was talking about 600 I think
11:53rhickeycemerick: a single transaction might span a mix of highly and non-contended refs, each with a different history count
11:53shoover`AWizzArd: from him, but 700 was the number in my head
11:56cemerickrhickey: I guess what I was thinking is that a ref is not necessarily contended equally among all transactions it participates in, so you'd end up always setting max history to accommodate the highest count you need for all possible transactions, rather than the ones that the ref is participating in in that moment?
11:58rhickeycemerick: contention is inherently about multiple transactions
11:59rhickeya ref only used in one transaction at a time will never grow history
11:59rhickeyunless now you've asked for some with :min-history
12:01rhickeymore explanation: http://groups.google.com/group/clojure/msg/bd50b598e7aa07ea
12:03rhickeyshoover`: there are 2 different 'ant' demos, one is the graphical ants, the other is a traveling salesman solver that uses ant colony optimization. It is the latter that was run on a 600 core box.
12:05rhickeycemerick: it's also not necessary to accommodate the highest count, you can leave it low and get retries - a perfectly acceptable tradeoff between memory use and concurrency, there's nothing wrong with: try again a few ms later when less busy
12:05shoover`I see
12:05rysA box with 600 cores, or a cluster of them with 600 total?
12:06rhickeyrys: an Azul box
12:06cp2'clojure is so slow the ants demo needs to be ran on a 600 core machine!1!11!'
12:11rysOh, those Vega chips are optimised for Java
12:11rysVery cool
12:17Anniepoourl?
12:18ATLienurl?
12:18Anniepootrying to get the lisppaste bot to give me a new paste
12:19ATLienah
12:20achimlisppaste8: url?
12:20lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:21Anniepoothanks
12:25lisppaste8Anniepoo pasted "classpath problem" at http://paste.lisp.org/display/82771
12:25AnniepooI can't get compilation to work within IntelliJ
12:26Chousukeyour classpath urls look malformed.
12:27Anniepooin what way? (Short of this being a winders machine, which I'm kinda stuck with)
12:27Chousuke"file:///C:/Documents.../.../src/"
12:27Chousukeyou can use / on windows too
12:27Chousukealso you don't need to add the pragatischool dir to the classpath
12:28Anniepooyah, was trying things.
12:28Chousukebut add-classpath is "wrong" anyway.
12:28Anniepoowell, it doesn't appear there's a way to set it anywhere else
12:28Chousukecheck if IntelliJ allows you to configure the java classpath
12:29Chousukewhich it should :P
12:29Chousukealso remember to add the classes dir (the compilation results) to the classpath
12:30Anniepoothe slashes after the protocol don't help, same error
12:31Chousukeadd the classes dir too (make sure it exists)
12:32Anniepoothat might be it
12:32Chousukeit'll be src/classes/
12:32Chousukeand I think you need to add the ending slashes to the directory names too
12:34JomyootDoes clojure compiles to Java first or straigth to byte code?
12:35Anniepoothanks
12:35AnniepooI'll try all this stuff
12:35ChouserJomyoot: straight to bytecode
12:37ChouserJomyoot: the bytecode produced doesn't always have Java source-code equivalent.
12:37Jomyootok
12:37JomyootIn the long run.
12:37Jomyootwill codes written with Clojure or Scala run faster?
12:40Chouserin a lot of cases you can write code in each (or in Java) that will compile to essentially the same bytecode, in which case they'll run the same speed.
12:41Jomyootwhy is clojure not in great programming language shootout
12:43maaclIs there a way to use amap on a 2-dimensional array like (make-array a 8 8)?
12:44maaclSorry - should have been (make-array Integer 8 8)
12:48ChousukeJomyoot: no-one has bothered to submit anything, I suppose.
12:49Chousukehm
12:50ChousukeI'm thinking of writing a simple build system in clojure.
12:51maaclanyone?
12:52Chousukethere are some, but they have dependencies on maven and ant and whatnot. I just want something that sets up the classpath easily :/
12:54Chousukemaacl: use two amaps?
12:55ATLienChousuke: I believe the book "Programming Clojure" leads you through building a simple build system
12:55Chousukeyeah, lancet.
12:56ChousukeOr maybe I'll just work on corkscrew. hmm.
13:08Lau_of_DKGood evening gents
13:08eyerisHi :)
13:30Chouseroh my. assembla attachments can be changed.
13:31Chouserwithout any indication on the ticket page itself?
13:32Chouseryou can click on "details" next to the attchment to find older versions.
13:38rhickeyChouser: yikes
13:40ChouserSo on #137 I may have loaded the page before Steve's 1:23 comment was there, but when I clicked the patch link I got the new patch.
13:40ChouserOr maybe I just overlooked his comment.
13:46rhickeyyeah, I don't like the updating with same name - better to say -rev2 or something, but patch ok'ed and moved to next release
13:51rhickeyfun: http://sdk.org.nz/2009/02/25/why-unit-testing-is-a-waste-of-time/
13:52AnniepooIf you see (compile 'org.pragatischool.JustOut) where would you expect to find JustOut.clj?
13:53Chousuke<classpath>/org/pragatischool/JustOut.clj
13:53Anniepoothanks
13:56AnniepooError: Error compiling lib '/Documents and Settings/Annie/My Documents/bizwithmike/boring/src/org/pragatischool/JustOut'
13:56Anniepoolisppaste8:url?
13:56lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
14:07Lau_of_DKGuys - I spent an exceptional amount of time today, bughunting in Clojure - The reason was that SLIME seemingly forces evalutation in a lot of places where Clojure wouldn't normally - Anybody have any insight into this ?
14:11AnniepooI can't believe this is this complex. I'm now on my 6th hour trying to get clojure to compile a java class
14:13cemerickone of these days that ant plugin will see the light of day...
14:13Chousukeheh.
14:13ChousukeAnniepoo: the java classpath system is complex. :P
14:14Chousukebut once it clicks, it's only a moderate nuisance.
14:14Anniepoono it's not. It's IntelliJ's "now you get to guess what I really mean here" system that is complex
14:14cemerickAnniepoo: FWIW, I've never messed around with add-classpath. using clojure.lang.Compile from the command line or an ant task is the most straightforward compilation method, IMO.
14:15AnniepooI don't care HOW I do it, I just need to be able to compile
14:15Lau_of_DKI thought Lancet was the weapon of choice ?
14:16shoover`Lau_of_DK: Do you have an example of such a place where slime forces evaluation?
14:16Lau_of_DKshoover`: Sure, hang on
14:17AnniepooI'm reluctant to abandon using an IDE.
14:17kotarakWhen we are about laziness issues: (count a-seq) should realise a-seq, no?
14:17cemerickLau_of_DK: I've not used lancet yet at all. I hear it has some ant interop. Build tools will always lag everything else (once stuff works, one generally doesn't want to touch it).
14:17Lau_of_DKTrue
14:17cemerickAnniepoo: AOT compilation and using an IDE are orthogonal issues/choices, FWIW
14:18Anniepooyes, but if it's not actually possible to compile from the IDE it loses a lot of it's value.
14:19kotarakWell, if the IDE is that inflexible...
14:19AnniepooI've been using IntelliJ for years, It's normally not inflexible. It's always been a pain to set up the classpath with it
14:19Anniepoobut never quite this bad
14:20cemerickAnniepoo: Compiling from an IDE is sort of a misnomer w.r.t. clojure. *loading* is the important thing -- compiling is something you only really need to do when you're ready to produce a distributable.
14:20Chousukeyou could ask rhickey :P
14:20Anniepoocemerick, in this case I am trying to write a GUI. I've got an extension to JPanel
14:21Chousukeare you sure you need gen-class anyway?
14:21Lau_of_DKshoover`: Actually, the code is in the vault at work, and Im not on the VPN right now, but it was a for loop with alot of nested maps and when we tested the code in the repl, everything worked fine, when we ran it from command-line, the for loop broke down, and the database backend got handed lazyseq@124821948 instead of the values as it had done when we had a repl going
14:21Chousukeuse proxy?
14:21Anniepoomany of the callbacks need some corresponding clojure form
14:21Chousukeat least for JPanel a proxy will do just fine.
14:22cemerickAnniepoo: I'd agree with Anniepoo, chances are you're using genclass unnecessarily.
14:22Anniepoohow do I attach the new member variable so I can hang onto the state?
14:22justin`hey guys I'm new at this and struggling wit recursion. can anyone tell me how to construct a 52 card deck out of a list of 4 suits and a list of 13 ranks?
14:22AnniepooI probably am
14:22cemerickAnniepoo: (defn make-new-panel [member-variable] (proxy [JPanel] [] ...))
14:22Chousukejustin`: you could use for
14:23Anniepooyah, hang on, I'll paste the thing I've been working on
14:23cemerickmember-variable could just as easily be a ref, so you can have overrides in the JPanel proxy manipulate it as necessary.
14:23Chousukejustin`: (for [s suits, r ranks] (card s r))
14:24Chousukejustin`: produces a lazy seq of 52 cards
14:24justin`Oh sweet
14:24lisppaste8Anniepoo pasted "proxy?" at http://paste.lisp.org/display/82783
14:24Chouser(for [suit '[H S D C], rank (concat '[a] (range 1 10) '[j q k])] (str rank suit))
14:24shoover`Lau_of_DK: it's really hard to think of why slime would affect that, since it's just passing entire forms to clojure for evaluation. It's sounds like something wasn't reloaded when you thought it was
14:24Anniepooso, this cose is 'so far so good', but I need to start keeping a model. Got stuck trying to compile cause I needed :state
14:25Chousukeare you sure you need :state? :)
14:25Lau_of_DKshoover`: Like I said - We tested for hours, reloading the repl, putting in printlns and what not, and the end result was, that with SLIME everything got called Okay - Without slime, alot of the underlying maps and such didnt get evaluated despite the fact that the main for was wrapped in doall.
14:25AnniepooI need a model.
14:25Chousukea global or a closed over ref ought to work just fine.
14:26shoover`Lau_of_DK: Sorry about your luck, sounds like a doozy
14:26AnniepooI need one global for every one of these things
14:26Lau_of_DKIt was
14:26AnniepooI'm making a little browser that displays clojure as a nested set of colored panels
14:26Lau_of_DKAnd the solution was, that every single map had to be wrapped in doall....
14:26shoover`I'm guessing your db isn't too excited about lazyseqs
14:26Anniepooit's mostly just a toy to learn clojure
14:27cemerickAnniepoo: presumably not -- as I msged before, a make-panel fn that closes over whatever refs you need and returns a JPanel proxy should be fine
14:27Anniepoobut I'm thinking some day it'll be an editor
14:27Chousuke(defn new-jpanel-instance [] (let [my-model (ref nil)] (proxy [...] (someOverride [] (manipulate my-model))))))
14:27Lau_of_DKshoover`: That was the least of our problems (since I wrote it myself), the main problem was that code simply wasnt being called
14:28Chousukethat way, every jpanel proxy returned by new-jpanel-instance will have its own ref it can access from the methods.
14:28AnniepoomakeAtomLabel is the fn, but I'm having trouble parsing "that closes over whatever refs you need"
14:28Anniepoowhich is probably my base problem
14:29ChousukeAnniepoo: (let [x 4] (fn [y] (+ y x))) <- that anonymous fn closes over x in this case
14:29Anniepoohmm
14:29Chousukeit captures its lexical environment
14:30shoover`Lau_of_DK: I'm intrigued. Send an example tomorrow if you want some extra testing
14:30Chousukeit's a basic functional programming technique, and very useful. Worth meditating until you get it :)
14:30cemerickpretty critical, yeah.
14:31Lau_of_DKshoover`: I think I need to try and recreate some similar code, since this is commercial code - that might take a little time since Im pursuaded to toss SLIME out the window and stick with inferior-lisp
14:31shoover`sure
14:31cemerickAnniepoo: do you have the Programming in Clojure book?
14:31Anniepooyes
14:31Anniepoook, I see the trick
14:32cemerickAnniepoo: in that case, I'd keep to something a little simpler than UI stuff for a little while. Swing is not the simplest things to work with in and of itself.
14:33Anniepoowell, I'm well familiar with swing. I'm a java programmer. But the last functional programming I did was college in the 80's
14:33cemerickAnniepoo: my apologies :-) Hard to know who knows what.
14:34Anniepooyah, np - that's where I am. 8cX All engineers are perpetual students.
14:35Anniepoook, if you look at my paste, and search for cnt, why isn't that working? it's always 1
14:35AnniepooI thought I was 'closing over an atom'
14:35cemerickAnniepoo: the Little Schemer is another fantastic book, and would go along with PiC nicely
14:35Anniepookk
14:36Anniepoo'captures' and 'closes over'... hmmmm
14:37Anniepooso, at the top of my makeAtomLabel I'm doing
14:37Anniepoo(let [cnt (atom 0)]
14:37ChousukeAnniepoo: makeAtomLabel looks like it should work.
14:38Anniepooyes, it works
14:38Anniepoobut look at cnt
14:38AnniepooI'm trying to just count the number of times it's clicked. I'm always getting 1
14:38Chousukehm.
14:40cemerickseems like the only way that'd happen is if each click was being registered on a new label produced by makeAtomLabel
14:41Anniepoono, I don't think that's it
14:41Anniepoo8cD and of course now I've messed up my project file and it won't run that either
14:43Anniepoofixed it
14:44Chousukeit works for me.
14:44Anniepoook, I'm an idiot.
14:44Anniepooyah, it works for me.
14:45Anniepoook, so you see what I'm doing.
14:46AnniepooI want to eventually have you able to alt mousedown in one of the panels and tug and have it
14:46Anniepoochange from horizontal to vertical
14:46Anniepoobut to do that I need to hang onto state - whether it's vertical or horiz
14:47Chousukeyou should be able to do that with an atom too, shouldn't you?
14:47Anniepooyah, guess so
14:47cemerickAnniepoo: that becomes another atom (alongside cnt)
14:48AnniepooI was trying to make some MVC pattern
14:48Chousukewell, you could close over a bunch of controller functions instead...
14:48Anniepoook
14:48Chousukebut that gets somewhat more complex.
14:48Chousuke:)
14:49Chousukeanyway, any reason you're not using the ns macro?
14:49AnniepooI didn't know about it when I wrote this
14:49Anniepoonow I do
14:50Anniepoous noobies are good for testing stuff nobody else actually uses 8cD
14:51Anniepooso, any way I can add another function and have it visible from outside?
14:51Anniepoolike, my long range plan, if you pull on an atom and it's already vertical, eventually it'll tell it's parent to become vertical
14:52cemerickin-ns is widely used, but only in REPLs
14:52ChousukeAnniepoo: what do you mean "from outside?"
14:53Chousukeyou can always return a function as a value from another function.
14:53Chousukeusually a closure :)
14:53AnniepooI want to, say, be able to add some makeMeRed method to the proxy returned by makeAtomPanel
14:54Anniepooso I can say (.makeMeRed somePanel) and it turns read
14:54Anniepoored
14:54Anniepoo<-- too many years of OO
14:54Chousukehmm, I don't think you can do that.
14:54Chousukenot with proxy.
14:54AnniepooI don't care if it's a 'real' Java method
14:55Anniepoobut need some way of doing the same thing
14:55Chousukedoes makeMeRed need access to the panel's privates? :P
14:55Anniepoonow you've made ME red! LOL
14:56Anniepoono, but lets say I want to know the value of cnt from outside
14:56Chousukehmm
14:56ChousukeI'll gist something
14:57Anniepoo(cnt-of somepanel) => 6
14:59Anniepooif I defn cnt-of within the let, then how do I specify which panel I'm talking to?
14:59AnniepooAll of this abandoning of OO is making me deeply uneasy. I remember how sloooow programming was before then
15:00Chousukehttp://gist.github.com/138339
15:00ChousukeAnniepoo: I find functional programming techniques much faster than OO :)
15:01Anniepoook
15:01Chousukethat closure approach is very OO-like
15:01AnniepooI'll believe you
15:02Chousukeit might not be the best approach, but it's a possibility
15:03cemerickAnniepoo: objects *are* closures, and vice versa.
15:03Anniepoook, so you define and return a map with the proxy and the accessor methods
15:03Chousukeyeah.
15:03Anniepoothat's not far from what I was struggling to do
15:04shoover`One of my favorite parts of using clojure is ripping out imperative for loops, but sometimes you do need the counter that was always there for free. Any tips for cleaning this up? The requirement is to remove duplicates while preserving the index. I wonder if I'm missing something since I have to build up a vector and then tear it apart.
15:04shoover`(remove (fn [[i a b]] (= a b))
15:04shoover` (map #(vector %1 %2 %3) (iterate inc 0) [:a :b :c] [:a :a :a]))
15:05Chouserpart of what's hard going from OOP to Clojure is that you have so many more options here -- often dozens of designs with only slight differences between some of them, any of which may work fine.
15:05Anniepooyah, my create code could even string the maps
15:05Lau_of_DKshoover`: For your inspiration: http://clj-me.blogspot.com/2009/04/counting-occurences.html
15:05Chouser...but have trade offs that I'm not yet able to spot very early in the process.
15:06Chouserso I write something, get it to to work, find some use case is a bit clumsy, am struck by a new design option, write it, repeat...
15:07ChouserHopefully I'm learning in the process how to make better decisions earlier in the design process next time. :-/
15:07Chousukedynamic typing helps a lot with that.
15:07Chousukeyou don't need to rewrite your class hierarchy :P
15:08Chouseryep. I had some of the same feeling when writing JavaScript code, but in Clojure there are even more powerful tools, and even more options (most of which are better than most of the JS options...)
15:08Anniepooyes
15:08Anniepooprototype based class systems beat static classes hands down
15:09AnniepooI was writing ActionScript 3 for a while
15:09Anniepooand took a side detour through Groovy
15:10AnniepooSomething I'd really like my toy to eventually do is eval whatever's inside a panel. So you could ctrl-alt-meta middle double click and have it show the eval instead of the form
15:11Chousukethat shouldn't be too difficult as long as you keep the form somewhere. :P
15:11Anniepooyes
15:13AnniepooI'm going to use your 'make a map' method, and have a var back to that piece of the original form for each panel
15:14shoover`Lau_of_DK: inspiring yes, but it looks like I still need the map phase in order to deal with the three seqs in parallel
15:15Anniepoochosuke and others, thanks for the help. I'm back on track.
15:16Lau_of_DKshoover`: Sorry, I didnt read from your msg that you wanted the map gone
15:17shoover`
15:17shoover`Lau_of_DK: map supports 3 colls, where reduce only takes one, so I have to run through map to get a seq I can pass to remove
15:17Lau_of_DKhmm... I fairly sure that reduce and apply takes at least 2 seqs?
15:19shoover`clojure.core/reduce ([f coll] [f val coll])
15:20shoover`this is better, no vectors + destructuring:
15:20shoover`(remove nil?
15:20shoover` (map #(when-not (= %2 %3) [%1 %2 %3]) (iterate inc 0) [:a :b :c] [:a :a :a]))
15:20cemerickChouser: am I right in thinking that I shouldn't ever have to flatten the value returned by zip-filter/descendants?
15:21djkthxif i'm working with a java library that expects: List<SomeClassName>
15:21djkthxand i have a clojure seq of SomeClassName's
15:21djkthxhow would i call the java library properly from clojure?
15:21cemerickdjkthx: (.someMethod someLibraryObj your-clojure-seq)
15:22cemerickThat List<Classname> is just a List at runtime.
15:22djkthxi'm getting a "No message" error
15:22Lau_of_DKhehe - I love that one
15:23djkthxand a rather unhelpful backtrace
15:23djkthxoh yeah
15:23djkthxit's a good one
15:23Chousercemerick: not if you're passing it to the next stage of a chain
15:23Lau_of_DKdjkthx: Consider it Richs little Easter Egg :)
15:24djkthxhttp://www.brics.dk/automaton/doc/ is the library in question
15:29djkthxthis doesn't make sense
15:29djkthxhmm
15:32cemerickdjkthx: try pasting the stacktrace
15:32djkthxweird, i think i got it working
15:32djkthxthe lib had a static method that seems to work
15:56cemerickclojure.zip has some odd rough edges when one is consuming an existing tree. e.g. naive zippers (like vector-zip) end up not working with zip/children, etc.
15:58cemerick(that is, unless I'm missing something dreadfully obvious)
16:11Chousercemerick: like this? http://www.assembla.com/spaces/clojure/tickets/135
16:13cemerickChouser: that's a separate issue. (tree-seq zip/branch? zip/children (zip/vector-zip [[1 2] [3 4] 5])) => NPE
16:13Chouseroh, so what are you referring to?
16:15cemerickwell, there's some imbalance in the api -- zip/down et al. return nodes, but zip/children doesn't return a seq of nodes, so certain things don't work out as one would expect (e.g. using tree-seq in conjunction with a zipper)
16:19Chousera quick glance at the code suggests that both vector-zip and xml-zip have a 'children' that returns a seq of nodes (not locs), compared to 'down' for which both return a loc
16:19ChouserIs that what you mean -- returning different types from different fns?
16:26cemerickreturning different types isn't a problem (you need to get at your nodes eventually, of course). I guess I'm just missing a loc-children (or whatever) fn that takes care of the loc bookkeeping. Certainly easy to impl, I'm just surprised I'm the first one that felt the need for it.
16:26cemerick(Perhaps that means I'm using the thing wrong. :-) )
16:27ChouserI think the problem (which I didn't realize until I was well into zip-filter) is that you'd get a seq of *different trees*
16:27Chouserthis doesn't matter if you're only reading -- you can descend into each, look around, whatever. This is exactly what zip-filter automates.
16:28cemerickwell, that's what I figured children would get me (before I looked at the code) -- a seq of subtrees
16:29Chouserbut if you make a change in one of them, you can no longer use the others -- they're old versions of the tree.
16:29Chouserif you want to make two changes, one in each sub-tree, how will you merge the results?
16:29cemerickoh, I see what you're getting at.
16:29cemerickSee, the trees I'm working with are already formed, never-gonna-change
16:29Chouserwell, that's good -- it took me a long time to see this problem.
16:29cemerickso, I didn't think of the modification issue
16:30Chouserso zip-filter is fine in such cases, and provides a function like you're asking for.
16:30Chouserand it's called "children" :-)
16:31Chouserit's also the problem that caused cgrand to give up on zip-filter and do his own thing for enlive, since that's specifically about making modifications.
16:31Chouserhe can still use clojure.zip, just not zip-filter.
16:31Chousergotta run.
17:20rhickeyhrm, does take-subs still need pad?
17:26Chouserwhy would it?
17:27Chousermost of the times I've wanted take-subs it's been then fed into destructuring, where I wanted short subseqs or nils
17:27Chouserusing 'concat' for the less common cases seems sufficient.
17:29prospero_so if I want to forward arguments to another function, I can do something like (defmacro p [& args] `(print ~@args))
17:30Chousukeyou don't need a macro for that.
17:30maaclWhy would I get "No matching method found: aclone" when trying to use amap?
17:30prospero_is the macro necessary in this situation?
17:30prospero_hey, beat me to it
17:30Chousuke(defn p [& args] (apply print args))
17:30prospero_oh, apply
17:33prospero_I can't do something like (apply (. "hello" substring) 1 2), though, apparently
17:34Chousukeyou can with reflection.
17:34Chousukebut it's a bit complicated
17:34prospero_I figured
17:34prospero_do you have to get the method object?
17:35Chousukehttp://paste.lisp.org/display/67182
17:36prospero_is there a performance overhead associated with that, or is that roughly what goes on under the covers anyways
17:36rhickeyChouser: pad with nils, e.g. becomes tedious because you can't just concat (repeat nil)
17:37rhickeymaybe padding is for partition, but still never yielding partials?
17:38rhickey(back to yield up to partition containing last, vs all offsets contained)
17:43hircushttp://github.com/richhickey/clojure-contrib/commit/82cf0409d0fcb71be477ebfc4da18ee2128a2ad1#comment_24628
17:43hircusis something wrong with the last commit to clojure-contrib?
17:44durka42it removes stacktrace?
17:44kotarakhircus: at least the move of stacktrace is announced.
17:44kotarakit's now in core.
17:44hircuscondt, stacktrace, template, test-clojure, and walk
17:44hircusall of these are still mentioned in load_all.clj
17:44kotarakcondt is removed, I think, stacktrace, template, walk and tests are in core
17:45hircushow about condt and template?
17:45kotarakload_all.clj was probably not correctly modified
17:46hircusI'll submit a patch, thanks
17:46hircusso people using Clojure 1.0 should stick to an older revision of contrib, to use test-is ?
19:45djkthxis there a way to have a string not have \ as an escape character?
19:46djkthxso i don't have to do "\\" when i want a literal \?
19:51ChousukeNot that I know.
20:25achimi remember there was a discussion of a [x & xs] binding form with 'rest' semantics (instead of next). has something like this been introduced?
20:46rhickeyachim: not yet, right now & in destructuring matches & in fn arglists - eager, and much code relies on nil from &, so it would have to be some other form (&rest?)
20:47eyerisI have a map of the form {:a {:x 1} :b {:y 1}}, to update :y I currently do (assoc my-map :b (assoc (:b my-map) :y 2)). Is there a common function for making these types of tiered associations?
20:53Chousukeeyeris: assoc-in and update-in
20:55eyerisVery good!
20:55eyerisThanks!
21:08gstampNo loop/recur in a catch? :-( http://pastebin.com/m642e2c1d
21:24eyerisgstamp I think you can have either inside the other
21:25eyerisyou just can't have a recur inside a catch where the loop is inside the try?
21:26gstampgot disconnected before... wans't sure if my paste made it. Basically had to move the loop.recur into a new method. Seems like a strange restriction but it's something I can live with.
21:27eyerisgstamp I think it has to do with garunteeing that (recur) is in the tail position.
21:28eyerisgstamp if there was tail call optimization, you'd like just place the call in a non-tail position and erroneously think that it was being optimized away
21:29gstampok.
21:43Chouserdjkthx: If you really want to avoid "\\" your best choice may be to use some other char and search/replace later.
21:44Chouserdjkthx: I assume your string literal is known at compile-time, in which case you can use a macro to do the replace also at compile time.
21:45Chouser(defmacro backslash [s] (.replace s "/" "\\"))
21:45Chouser(backslash "one/two/three") ==> "one\\two\\three"
21:51arohnergrrr. Slime is not happy with unicode in variable names
22:19sethsI'm looking at (drop) and (rest) and can't find the difference
22:20sethsexcept that (drop) is defined in core.clj and (rest) I am still looking for its defn
22:20sethseven tried macroexpand
22:20seths(drop 1 '(1 2 3)) => (2 3)
22:20seths(rest '(1 2 3)) => same
22:21sethsis rest just a simple helper based on drop?
22:26gstampdrop seems to use rest as part of its implementation.
22:27jackdempseyyou can say drop 5
22:27jackdempseycan't say rest 5
22:37sethsapparently I need to spend more time on http://clojure.org/lazy
23:13Jomyootwhat is ide of choice for clojure?
23:21durka42Jomyoot: a lot of people use emacs
23:21durka42I use vim
23:22durka42some people use eclipse
23:22durka42IntelliJ
23:22durka42that was not an answer to your question :)
23:23Jomyootไำสส
23:23Jomyootwell intellij plugin is not complete?
23:23Jomyootits version 0.01?
23:23Jomyoot:(
23:23Jomyooti use intellij
23:24grrrtI grew up with vi, but switched to (Aquamacs) emacs for clojure
23:24ChouserCommon lisp was not a sufficient lisp. Clojure is.
23:25ChouserEmacs is not a sufficient emacs. ... :-(
23:25durka42i learned emacs for common lisp, and vim for clojure...
23:25durka42FSVO "learned"
23:26grrrtI find myself missing ParEdit when I'm not in emacs... paredit works really well for me
23:27grrrtI don't like the clojure/jdb emacs stuff though - I'd rather use the eclipse debugger
23:27grrrtbut that doesn't let me set breakpoints
23:28grrrton the other hand, I don't need to singlestep nearly as often with clojure as I do with java
23:57durka42is evaluation order of function arguments deterministic?
23:59slashus2Is it from left to right?