#clojure logs

2009-09-21

01:56tomojso say you want to read n bytes from an InputStream. is (take n (repeatedly #(.read input-stream)) safe?
01:58tomojI guess repeatedly isn't chunked, huh
02:06mudphone`Hey folks was wondering if anyone could help me with a question about this anonymous function syntax: (fn []> (+ 1 2))
02:06mudphone`I'm wondering what the ">" is for.
02:06hiredmandoes nothin
02:06hiredmantypo or a mispaste
02:07mudphone`ah, must be a typo, since I got it from a book
02:08mudphone`So, i guess the follow-up is, why isn't it cause an error?
02:08mudphone`doesn't it
02:09hiredman> is a valid value
02:09hiredman,>
02:09clojurebot#<core$_GT___4136 clojure.core$_GT___4136@1d281f1>
02:09hiredmanand fns have an implicit do
02:10hiredman,(do > (+ 1 2))
02:10clojurebot3
02:10hiredman,(do :foo 5 9 'c (+ 1 2))
02:10clojurebot3
02:10Makoryu, ((fn [] 'foo 'bar 'baz 'quux :IWouldLikeToOrderALargePizza 5))
02:10clojurebot5
02:11mudphone`Does that work with other foods?
02:11mudphone`:)
02:11mudphone`hiredman: thanks
02:11Makoryumudphone`: Basically, you can put anything you want in between the [] and the 5, and it will be evaluated. If it doesn't have any side effects, it might as well not be there
02:11mudphone`Makoryu: thanks
02:12MakoryuAnd yeah, you can use other foods ;)
02:12mudphone`Interesting, so a function like > without arguments just returns true, in this case.
02:14hiredmaneh?
02:14hiredmanno
02:14hiredmannot at all
02:14mudphone`ah, so it's not evaluating, it's a valid value, like you said
02:14hiredmanit is evaluating, it's evaluating to the function object
02:15hiredman() is needed for calling the function
02:15mudphone`ah, ok
02:15Makoryumudphone`: The function evaluates to itself. You have to call a function (eg. (>)) for it to be applied to any arguments (or zero arguments)
02:15Makoryu, >
02:15clojurebot#<core$_GT___4136 clojure.core$_GT___4136@1d281f1>
02:15Makoryu, 'pizza
02:15clojurebotpizza
02:16Makoryu, (>)
02:16clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$-GT-
02:16Makoryu,(> 5)
02:16clojurebottrue
02:16mudphone`So, with the implicit do, the > is evaluated to itself, and then not used.
02:16MakoryuYep
02:16MakoryuIt's simply discarded.
02:17mudphone`ah ok
02:17mudphone`dare I ask why functions have the implicit do?
02:17Chousukemudphone`: so that you can have more than one expression in them
02:18Makoryumudphone`: Partly for the side effects, of course.
02:18Makoryu, (do (println "Sup") 5)
02:18clojurebot5
02:18clojurebotSup
02:18Chousukeif they didn't have a do, you wouldn't be able to write (defn foo [] (print "debug") "result")
02:19mudphone`oh, so, hiredman meant the anonymous function's implicit do
02:19mudphone`I was thinking of the ">"
02:19Chousukeoh, and the > is not evaluated to itself! remember, it's a symbol :)
02:19mudphone`Chousuke: so > is evaluated to the function
02:20Makoryumudphone`: People accustomed to certain other programming languages (which I will not name) would frown on this implicit do. However, Lisp has always had it even when it was called PROGN, and Clojure still has it now.
02:20Chousukemudphone`: yeah. when evaluated, symbols are looked up to see if they name a var, then the var is dereferenced to get the actual value
02:20Makoryu(It used to serve the double purpose of allowing docstrings, but now we have the defn macro (and metadata) for that)
02:21Makoryu, pizza
02:21clojurebotjava.lang.Exception: Unable to resolve symbol: pizza in this context
02:21mudphone`Chousuke: thanks, got it
02:21mudphone`Makoryu: is there a down-side to this implicit do?
02:22Chousukemudphone`: not with functions :/
02:22mudphone`I'm assuming perhaps, the side effects?
02:22hiredmanthe implicit do doesn't make side effects, it only allows them if you put them there
02:23mudphone`hiredman: right, so is that why the implicit do is fowned upon? is my question
02:23hiredmanuh
02:23mudphone`frowned upon
02:24hiredmanwhat gave you that impression?
02:24Makoryumudphone`: Not by Clojure programmers :p Ignore what I said earlier.
02:24mudphone`ah, ok
02:25mudphone`Chousuke: I didn't get your last comment.
02:26ChousukeWell, Clojure has fewer uses of implicit do/progn than common lisp. for example, cond expressions in CL have an implicit do
02:26Chousukeas a result, it needs an extra pair of parens for each expression :)
02:27mudphone`oh, ok, I see... I thought you were talking about vars
02:27mudphone`(and symbols)
02:33MakoryuImplicit do/PROGN is generally a good thing in Lisps like Common Lisp, which is much more procedural than functional
02:33MakoryuIn Clojure, they're just redundant
02:49tomojwhy is there no byte-array function?
02:52Chousukethere's into-array
03:33mudphone`Anyone know how to get something like (read-line) working from the Emacs Slime-REPL Clojure?
03:33mudphone`(read-line) as in getting user input?
03:36Fossihi
03:48meganein gen-class, can i someway declare an array return type? when i try this: (ns testa (:gen-class :methods [[getA [int] int[]]])) , i get an inconvertible types error when i try to use that class from java. javac thinks getA's return type is int.
03:48meganeusing clojure 1.0
03:51Chousukemegane: of course, int[] is just the symbol int followed by an empty vector :)
03:51Chousukemegane: I think you want Integer/TYPE
03:51Chousukewait, no... hmm
03:51Chousuke"[I" or something? :/
03:54megane:methods [[getA [int] "[I"]] ?
03:55AWizzArd~ max people
03:55clojurebotmax people is 164
04:00LauJensenGood morning guys
04:00arbschtmorning lau
04:01licoressehello
04:02Chousukemegane: try it. I don't really know much about gen-class :/
04:03meganejava.lang.ClassNotFoundException: java/lang/[I
04:04Chousukehmmh
04:04Chousuke,(class (int-array))
04:04clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$int-array
04:04Chousuke,(class (int-array 1))
04:04clojurebot[I
04:04meganeInteger[] gives similar results as int[]
04:04Chousukeyeah, the Integer[] is not the right syntax.
04:05Chousukeas I said, it's just a symbol followed by a vector :)
04:05Chousuketry "ints"?
04:07meganejava.lang.ClassNotFoundException: java.lang.ints
04:07Chousukehmm. maybe #=(Class/forName "[I")
04:08Chousuke(#= is read-time eval and that should return the class object for an integer array)
04:08Chousukethis really needs better syntax :/
04:09meganejava.lang.ClassNotFoundException: Class
04:09megane:methods [[getA [int] #=(Class/forName "[I")]]
04:10Chousuke:(
04:23meganei got around it by using :methods [[getA [int] Object]] , returning (int-array ...) in getA, and at java side i casted the return value to int[]
04:41pixelman_mudphone`: use jline to get arrow up etc in the repl, here's my launch script http://followthedata.wordpress.com/2009/09/03/setting-up-clojure/
04:54licoresse.
04:59vyIs there a reader macro for writing bits? (E.g. As #b100101 in CL.)
05:05Chousukehmm
05:05Chousuke,0b01010
05:05clojurebotInvalid number: 0b01010
05:05Chousukethere was some way to get an arbitrary radix...
05:05Chousuke,2r01010
05:05clojurebot10
05:13lisppaste8vy pasted "filter-by-bitmap" at http://paste.lisp.org/display/87426
05:13vyChousuke: Thanks.
05:14vyChousuke: Is that some Java reader notation?
05:14vyCan anybody help me to figure out why does filter-by-bitmap in http://paste.lisp.org/display/87426 returns ()?
05:18vy(Integer/reverse 2r110)
05:24Chousukevy: what do you want it to do?
05:24vyReturn items in coll by filtering agains turned on bits in the given number.
05:25Chousukeso 2r1010 would select items 0 and 2?
05:25vyChousuke: Yup.
05:25tomojI don't get it..
05:25Chousukethe bit-and with i is redundant
05:26lisppaste8vy annotated #87426 "filter-by-bitmap (via loop)" at http://paste.lisp.org/display/87426#1
05:26Chousuke:when (= 1 (bit-and 1 (bit-shift-right bits (- n i 1)))) works for me
05:27vyOops! Silly me.
05:27vyWhat does "recur arg for primitive local: bits must be matching primitive" error mean?
05:28vyHrm... It has some mapping problem too.
05:29lisppaste8vy annotated #87426 "filter-by-bitmap (via loop, fixed bit filtering)" at http://paste.lisp.org/display/87426#2
05:29Chousukethis sounds like an awfully compicated way of selecting items from a vector
05:30vyChousuke: You mean "loop/recur" derivative instead of "for"?
05:30Chousukeboth :P
05:30vySo what's your suggestion?
05:31Chousukewell, what are you doing this for? :/
05:32vyI'll filter the elements in a coll by looking at the turned on bits in a number.
05:33Chousukeit might be easier if you make a bit-pattern->lazy-seq function
05:36lisppaste8vy annotated #87426 "subsets" at http://paste.lisp.org/display/87426#3
05:41Chousukehmm
05:49vyChousuke: And guess what? It performs orders of magnitude better than existing clojure.contrib.combinatorics/subsets.
05:50Chousukeit depends on the count though :/
05:50Chousuke~def subsets
05:50Chousukeapparently so does that implementation. hm
05:51tomojwhy are the elements wrapped in a vector?
05:55tomojhuh
05:56tomojevery once in a while c.c.combinatorics/subsets takes 10 times longer than usual
05:56Chousukedo you have escape analysis enabled?
05:56tomojI don't even know what that means
05:57ChousukeI guess you don't then :P
05:57Chousukeit's a new JVM feature that IME seems to cause somewhat uneven performance behavious
05:57Chousukebehaviour*
05:58lisppaste8vy annotated #87426 "combinations" at http://paste.lisp.org/display/87426#4
06:01vyChousuke: Moreover, while (clojure.contrib.combinatorics/subsets 21) throws some "GC foo bar limit exceeded error" (count (subsets (range 21))) returns in 799msecs.
06:03tomojI don't think it's orders of magnitude better
07:13somniumis there any way to prevent the reader from choking on % outside of a string literal? :100% '100% ?
07:18Fossiwhat's the best way to join (take 2 "foo) back together?
07:18Fossi"foo"
07:26xdphello
07:26AWizzArdHi xdp
07:27noidi_,(apply str (take 2 "foo"))
07:27clojurebot"fo"
07:27xdpwhere is parallel.clj?
07:28xdpi want it to improve performance of my application
07:28xdpi'm using 1.1.0
07:29xdpok, i found it in clj dir
07:30xdpwhat's diffs between clojure.core/pmap and parallel?
07:31xdpi'm now using pmap, i don't know if i should use parallel lib
07:32xdpany ideas?
07:35cgrandxdp: parallel.clj builds on the fork/join api, it should be smarter in how the load is distributed amongst cores
07:39Fossiyeah, we arrived at apply str as well, but deemed it unnecessary, so now we check the length
07:46gerry_parallel need jsr166y.jar support,right?
07:47cgrandgerry_: use the jsr166y.jar in the file section of the clojure group
07:47rhickeygerry_: yes, for clojure.parallel you can use the jar in the downloads section of the google group
07:48rhickeynew work is going on in the par branch on github, in which case you should use the jar in the downloads section there
07:48gerry_oops, i have downloaded it from gee.cs.oswego.edu, but it seems not work
07:49rhickeythat's a moving target
07:49gerry_ok,thx
07:49rhickeythus the downloads
07:49rhickeyalso the version on the google group will be the last to support JDK 1.5, they've stopped supporting it for ForkJoin
07:50rhickeyso par moving forward will be Java 6+
07:50gerry_so, i have to wait?
07:51rhickeygerry_: wait for what?
07:51gerry_how about performance of clojure.core/pmap to parallel stuff?
07:51gerry_wait jsr166y.jar
07:51rhickeygerry_: pmap is unique in not needing the entire collection. OTOH, it is limited if your work-per-unit is small.
07:52eevar2speaking of the zip on google; where do I end up clicking 'download' on clojure.org, and then 'source'
07:52rhickeygerry_: you don't have to wait, just be aware that Java 5 is a dead end for jsr166y stuff
07:52gerry_ok
07:53rhickeyand the libs are built on specific versions, since they are still changing the api
07:53rhickeyi.e. the things that parallel are built on are not going to be in Java 7
07:53gerry_i have one gui application writen by swing, drawString in swing is too slow, i want to test parallel lib
07:53rhickeythus the par branch based directly on ForkJoin
07:54gerry_ok, i'll check it out
07:57gerry_i'm not sure whether swt is better for me
07:57eevar2gerry_: sure your performance issue isn't because of reflection?
07:58eevar2gerry_: i'd stay with swing
07:58gerry_no, mainly due to drawString methon
07:58eevar2gerry_: http://www.javaworld.com/javaworld/jw-05-2009/jw-05-clojure.html?page=5
07:58gerry_this method maybe slowest in swing lib :)
07:59eevar2add some type hints if you haven't already
08:00eevar2gerry_: more articles: http://www.google.no/search?hl=en&amp;q=clojure%20type%20hints%20reflection%20-site:www.experts-exchange.com
08:00gerry_eevar2: i have done type hints
08:00gerry_thx for your link
08:12gerry_jsr166y.jar in google group works
08:12eevar2gerry_: what are you painting to?
08:13eevar2more likely to improve performance doing that, than paralellizing calls to drawString
08:13gerry_gogame board
08:13gerry_yes
08:13eevar2s/doing/switching to some other drawing surface
08:13gerry_i have to draw coords in board
08:14gerry_i haven't found any alternative methods to do that
08:15gerry_so i have to parallel them
08:31gerry_eevar2: just like this: http://imagebin.ca/view/oIsKZUe6.html
08:33eevar2how many times do you call drawString?
08:34gerry_about 40times
08:35eevar2and that's a bottleneck, you think?
08:35gerry_and 360 time repaint
08:35gerry_s/time/times
08:36gerry_dont' much slow, really a bit slow, but i want perfect :)
08:39gerry_enable drawSting, i got about 1 second stalling compare with disable drawsting
08:39gerry_s/drawSting/drawString
08:42gerry_i'm using agent to repaint
08:43gerry_i don't know whether this is thread safe
08:50gerry_(map f (par cloll)) just work?
08:50gerry_or (pmap f (par coll))?
08:52ChouserI'm not sure, but I would guess 'par' is a linear (single-threaded) process
08:53Chouserso it might be better to do (par coll) earlier and then keep the result around and reuse it.
08:55gerry_(par coll :map f)?
08:55ChouserI think that would also be a non-parallel process.
08:55gerry_Chouser: (let [pcoll (par coll)] (map f pcoll)) like this?
08:55Chouserpmap, but yes.
08:56gerry_ok
08:56Chouserwell, assuming you do other things in that 'let' as well.
08:57Chouserif all you do in the 'let' is run 'pmap' once, you might as well use your original statement.
08:57gerry_s/map/pmap will be better?
08:58Chouserwait, this is wrong. hand ong.
08:58gerry_oh?
08:58Chousersorry, 'pmap' doesn't require the use of clojure.parallel at all
08:58Chouser(doc pmap)
08:58clojurebot"([f coll] [f coll & colls]); Like map, except f is applied in parallel. Semi-lazy in that the parallel computation stays ahead of the consumption, but doesn't realize the entire result unless required. Only useful for computationally intensive functions where the time of f dominates the coordination overhead."
08:59Chouserpmap works on regular sequences, you don't need a "parallel array" first.
08:59gerry_but if i use it with par?
09:00gerry_what will happen?
09:00ChouserI should probably stop talking about clojure.parallel, because I just don't know it that well.
09:00Chouseranyone else have some advice?
09:01gerry_ok, let me try it
09:02eevar2gerry_: i'd say your rendering code/approach is broken somewhere. try running a profiler or something. or reading the swing docs
09:05gerry_eevar2: i have figured it out by disable drawString and enable it
09:05gerry_problem is there,i'm sure
09:06eevar2okies. i have nothing further to contribute. good luck
09:07gerry_thx anyways
09:07gerry_Chouser, map seems better than pmap in this case
09:08Chouserwait, you're running swing drawing methods in multiple threads? I don't think this is supported.
09:09Chouserswing wants pretty much all drawing to happen from its event thread.
09:10gerry_Chouser, i just repaint in agent thread, and it works
09:10gerry_but not in event thread
09:12gerry_and sound play also in agent thread
09:15gerry_oh,yes, repaint still call back to original thread
09:25gerry_maybe problem due to videocard support in opensolaris? i'll try it on windows or linux
09:26gerry_ati support in opensolaris sucks
09:31gerry_ok, time to go
09:31gerry_thx, bye
09:35JomyootCan Java.util.HashMap readily be converted into Clojure Hash?
09:35Jomyootlike { :a 1 :b 2 :c 3 }
09:35Chouser(into {} my-hash-map)
09:35Jomyoothmm
09:35Chouser,(into {} (java.util.HashMap. {:a 1, :b 2, :c 3}))
09:35clojurebot{:a 1, :b 2, :c 3}
09:36Jomyootso from Java :a is actually "a" right?
09:36ChouserThat's a Clojure PersistentHashMap to java HashMap and back.
09:36AWizzArdno
09:36ChouserJava HashMap can store Clojure keywords
09:37AWizzArdthey are ordinary objects, like you and me
09:37Chousuke,({:a 1 "key" 2} "key")
09:37clojurebot2
09:37eevar2,(:a (java.util.HashMap. {:a 1 :b 2 :c 3}))
09:37clojurebot1
09:37Chouserif you have a Java HashMap with string keys and you want a clojure PHM with keyword keys, I'd look at zipmap
09:38Jomyoothmm
09:38Chouser,(let [jhm (java.util.HashMap. {"a" 1, "b" 2, "c" 3})] (zipmap (map keyword (keys jhm)) (vals jhm)))
09:38clojurebot{:a 1, :c 3, :b 2}
09:40Jomyootis that a natural way to do it?
09:40Jomyootor is that considered a hack?
09:40JomyootIf I like to pass Clojure hash back and forth with Java program
09:40Chousukewhy would you change the keys at all?
09:40Chousukejust let them be as they are
09:40ChouserJomyoot: any reason not to leave the keys as strings?
09:40eevar2just use string keys
09:41Jomyootok then
09:41Chouser:-)
09:41AWizzArdmaybe you don't even need to convert it into a persistent map at all?
09:41Chouserslightly less pretty in the Clojure code, but less mucking around too.
09:41AWizzArdclojures function (get ...) works on j.u.Map's as well
09:44avitalhi. is there any way to use for to collect more than one element on each iteration? something like (for [x [1 2 3]] x (+ x 10)) that would return '(1 11 2 12 3 13)
09:45AWizzArdyou could collect [x (+ x 10)] and get ([1 11] [2 12] [3 14])
09:46avitalyes i could also do (union (for [x [1 2 3]] [x (+ x 1)]))
09:46avitalbut that seems weird
09:46avital,(union (for [x [1 2 3]] [x (+ x 1)]))
09:46clojurebotjava.lang.Exception: Unable to resolve symbol: union in this context
09:46avital,(set/union (for [x [1 2 3]] [x (+ x 1)]))
09:46clojurebotjava.lang.Exception: No such namespace: set
09:46avital,(clojure.set/union (for [x [1 2 3]] [x (+ x 1)]))
09:46clojurebot([1 2] [2 3] [3 4])
09:46avital,(clojure.set/union (for [x [1 2 3]] [x (+ x 10)]))
09:46clojurebot([1 11] [2 12] [3 13])
09:47AWizzArd,(apply concat (for [x [1 2 3]] [x (+ x 10)]))
09:47clojurebot(1 11 2 12 3 13)
09:47AWizzArdotherwise, there is always (loop ...)
09:47avitalok nice that works but it's too hacky, shouldn't for support multiple values added per iteration or something of the sort?
09:48Chouser,(let [v [1 2 3]] (interleave v (map #(+ 10 %) v)))
09:48clojurebot(1 11 2 12 3 13)
09:48AWizzArdavital: could be useful. In functional programming it is a design pattern to write your own map/filter/etc functions that can do what you need in one go
09:48AWizzArdif you want to traverse the list only once then loop is a good start to implement such a function
09:48avitalChouser chouser chouser chouser the apply suggestion also works and is much more readable. I am asking why this would not be part of for
09:49avitalAWizzArd: ok we'll implement our for that supports this
09:49Chouseravital: :-) beauty is in the eye of the beholder
09:50AWizzArdavital: the most typical use case is what for currently supports. I agree that it would not be bad to have something in place that works for inserting multiple values, but I guess it is a bit too special.
09:50Chouseravital: I've used (apply concat (for ...)) a few times. Many of those times I eventually found that there was a better way in the large.
09:50Chouseravital: why do you want interleaved values like that? I mean, what consumes that seq?
09:50avitalthe specific example
09:50avitalwe are writing a google wave robot
09:50AWizzArdoh good
09:50avitalwe need to send operations to be done on several waves
09:51avitaleach operation is actually two operations in one - a delete and an append operation (instead of one replace operation)
09:51avitalso we collect all the wave ids that we need to act on in a list
09:51avitaland then create the json response containing the delete and append operations
09:51avitaleach wave id needs to generate _two_ operations
09:51avitalin a nice interleaved way
09:51Chouseravital: it's important that they happen interleaved, and not all appends followed by all deletes?
09:52AWizzArdavital: which lib do you use to parse/compose json?
09:52avitalChouser: Maybe not but even so such a case might happen, it should be a solvable problem even if in this case it's not necessary
09:52Chouser,(mapcat #(list % (+ 10 %)) [1 2 3 4])
09:52clojurebot(1 11 2 12 3 13 4 14)
09:53avitalAWizzArd: clojure.contrib.json
09:53AWizzArdoki good, i also want to begin to use it right now
09:53avitalAWizzArd: For wave?
09:54Chouseravital: of course it's solvable. The question is whether adding more complexity to 'for' is worth the benefit. If the use cases are largely theoretical, one may being to doubt the value.
09:54avitalChouser: What?! As far as I see the world, if you lose nothing and gain something it's always a good idea. No?
09:54Chouseradding complexity to 'for' is losing some simplicity
09:54avitalSorry for the What?! I meant What?
09:55Chousernot that there's much simplicity left in 'for' to lose! :-)
09:55avitalChouser: No loss of simplicity. If someone doesn't want to know about the posibility of putting several values they don't need to even know that exists
09:56Chousukeavital: what if someone wants a side-effect in for... for debugging? :)
09:57avitalChousuke: not sure what you mean...
09:57Chousuke(for [x someseq] (println "X: " x) x)
09:58avitalChousuke: So you're saying that you think what I'm suggesting is a good idea? again not sure...
09:58Chousukewith your multi-expression extension, you'd get a seq of (nil a nil b nil c...) :/
09:58avitalNo
09:58avitalIf you want to do that you'd do
09:58avital,(for [x [1 2 3] (do (println "X: " x) x))
09:58clojurebotUnmatched delimiter: )
09:58avital,(for [x [1 2 3] (do (println "X: " x) x)
09:58clojurebotEOF while reading
09:58avital,(for [x [1 2 3]] (do (println "X: " x) x)
09:58clojurebotEOF while reading
09:58avital,(for [x [1 2 3]] (do (println "X: " x) x))
09:58Chouser'for' doesn't support more than one body expression now anyway. no implicit 'do'
09:58clojurebot(1 2 3)
09:59Chousukeoh, hmm :/
09:59Chouser,(for [x [1 2 3]] x (+ x 10))
09:59clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$for
09:59avitalChousuke: I'm suggesting to allow for multiple values in the body expression in a for. If you want to do your thing, just use (do ...)
09:59Chousernot sure how chunking should work with multiple values.
10:00Chouserjust generate bigger chunks I suppose?
10:00avitalwhat is chunking sorry?
10:00Chousukeavital: hm. that might be fine
10:00Chousukeavital: but I'll leave the implementation to you
10:00Chousuke~def for
10:00Chouseravital: welcome to the complexity that is 'for'
10:00Chousukegood luck :P
10:00avitalSure, ayal is implementing for1 as we speak
10:00avitalforx
10:01rhickeyif 'for' did that, wouldn't people want the same from map (somehow?), it's a general problem of expansive mapping
10:02avitalI'm relatively new to Clojure and FP but in the meanwhile I've gotten to the point that I almost always prefer to use for than map/filter/etc unless I have a pre-existing function or predicate that just perfectly works.
10:02Chouserthey would certainly want the same from 'doseq', but 'doseq' already provides the analogue
10:02rhickeycertainly putting multiple values after one another like that is a mismatch with blocks elsewhere
10:02ChousukeI guess internally multi-value-for would have to be quite similar to (apply concat (for ...)) anyway :/
10:02rhickeyforcat a la mapcat?
10:02avitalrhickey: Sorry, not sure what you mean...
10:02Chouserfor is already a bit like mapcat
10:02AWizzArdavital: not for wave, for some other server side app i want json
10:03jdzwhen do we have a lolcat?
10:03AWizzArdwhat was this again?
10:03Chousuke"applies a funny operation to the input. produces a list, if input is cheezburger"
10:04avitalIt's not easy to add this to map since map takes a function anyways
10:04avitalBut it seems natural to add it to for
10:04jdz*produces a very lazy list :)
10:06avitalAs far as I understand, for is the generic wrapper for a bunch of stuff that could've been done with combinations of map filter and much more
10:06avitalbut in general at some point of complexity (like where we are) the solutions with map/filter are too crazy and for renders a natural and simple implementation
10:07avitalso since for anyways is a huge machine that eases use of map/filter/etc why not give it as much functionality as possible?
10:07AWizzArdavital: well, reduce is the generalization of map/filter
10:07Chouseravital: because that way lies madness (a.k.a. Common Lisp's LOOP)
10:08avitalAWizzArd: no, reduce map and filter work together and they are orthogonal in functionality
10:08Chousukeavital: except you can implement both map and filter with reduce :/
10:08AWizzArdwhat can map/filter do what reduce can't?
10:08Chousukeavital: albeit not lazily :)
10:08manic12does anybody else have a problem with swing crashing the netbeans repl?
10:09avitalChousuke: Ah, yes I see now; but I see that as a hack. In my view the most important aspect of code is its readability. map/filter are more readable than the equivalent weird reduce that would implement them
10:09AWizzArdyes
10:09avitalIt's all about keeping the code as similar as possible to a human language as possible
10:09avitalfor looks like a human language
10:09AWizzArdsure
10:10avitalAnd in a human language I'd like to be able to say "go over all these elements and for each one collect two elements"
10:10AWizzArdbut for example a composition of filter and map may better be expressed with one reduce, which can do the work in one go
10:10avitalinstead of collecting lists and then apply concat'ing them
10:10AWizzArdavital: write a useful collect macro and open source it :p
10:11jdzwhat's the for incantation to go over a sequence with a counter?
10:11avitalAWizzArd: My colleage Ayal is writing it as we speak.
10:12ChousukeI'm not really opposed to the idea itself but I think for supporting multiple expressions is somewhat... unexpected :/
10:14jdzi'd like to see CL's iterate in clojure, but...
10:14jdznot enough to go and start writing one, apparently
10:14ChousukeI think it would be conceptually simpler to have for be a "simple" list comprehension.
10:15AWizzArdjdz: want it for compatibility / code reuse?
10:15clojurebotfor is not a loop
10:16hiredman~suddenly
10:16clojurebotCLABANGO!
10:16AWizzArdcemerick: new record!
10:16AWizzArd~ max people
10:16clojurebotmax people is 165
10:16jdzAWizzArd: not really. just for not writing complicated loop/recurs
10:17AWizzArdthesnowdog_: grats, you made the new record
10:17cemerickAWizzArd: man, no one even knows what you're talking about! ;-)
10:17AWizzArdcemerick: the max people thingy
10:17AWizzArdit was set in February I guess
10:17cemerickoh, *I* know what you're talking about
10:17AWizzArdgreat :)
10:18lisppaste8Chouser pasted "support multiple values in 'for' body" at http://paste.lisp.org/display/87441
10:19Chousernot so hard to do, which concentrates us on the question: is it good to have?
10:19hiredmanit's 7am, I don't need to see that
10:19Chousernote that doesn't do each value lazily, which could be desirable.
10:21AWizzArdhi ayal
10:22lisppaste8ayal pasted "forex macro" at http://paste.lisp.org/display/87442
10:22ayalAWizzArd: hi!
10:24cgrandstupid question: why for isn't implemented in terms of mapcat/map/filter? for perf reasons (easier on allocations)?
10:24Chouserhm. ayal's is simpler. :-)
10:24ayalChouser: Thank you.
10:25Chousercgrand: I actually looked into doing that at some point. I forget why I gave up...
10:25Chousermaybe just that some features are very hard to implement that way too. Such as :while.
10:26AWizzArd~seen kotarak
10:26Chouserthough thinking about it again now, I don't know why a take-while with a special value wouldn't work.
10:26clojurebotno, I have not seen kotarak
10:26cgrandisn't :while a take-while?
10:27ChouserI looked at it when adding chunk support, because it would have been much nicer to just build on the chunk support already in map/filter
10:28Chousermaybe it was just performance. should have made some notes. :-/
10:54ben_mHi there :) This line: `javax.swing
10:54ben_mgah.
10:54ben_mCopy-paste fail.
10:55ben_m (for [x (range 10)] (.add (. (new JLabel) (setPreferredSize 10 10))))
10:55ben_mI get an error: "Wrong number of args passed to: core$for (grid.clj:5)
10:56ben_m(I'm aware that the code might have more errors except the for one, I'm new to both Java and Clojure :)
10:56ChouserI get: No matching method found: setPreferredSize for class javax.swing.JLabel
10:57Chousernote you're mixing method call style there.
10:57ben_mI'm in a (doto frame ...)
10:58ben_mIf that helps at all :)
10:58Chouseroh!!
10:58Chouseryeah
10:58Chouserthat changes everything. :-)
10:58ben_mI'm tring to create 10 Labels inside the frame
10:58Chouserthe doto will be inserting something after the first word of the list
10:58ben_mThere's probably a better way instead of using for and range, but I don't know it :)
10:58Chouser(for <thing here> [x (range 10)] ...)
10:58ben_mAh!
10:59Chouseryou've outgrown that particular 'doto'. Time to put the object in a local (using 'let') and then try your loop again.
10:59Chouserthis time use 'doseq' instead of 'for' because you're looping for side effects.
11:00hiredmanI think the reason I don't use for often (almost never) is it's lack of composability
11:01lisppaste8gluckspilz pasted "untitled" at http://paste.lisp.org/display/87445
11:01hiredmanhow do you use for inside a ->
11:01Chousukeyou overuse -> anyway :P
11:02Chouserwait, how do you use 'map' inside a -> ?
11:02hiredman((partial map fn))
11:03Chousukethat automatically looks ugly to me because of the double parens ;/
11:03hiredmanyou get used to it
11:04Chousukemore likely I will just write it some other way
11:17tmountainanybody know if clojure has a builtin to test if a number falls within a given range ?
11:17Chouser,(< 2 5 10)
11:17clojurebottrue
11:18tmountainwhoa, wasn't aware of the three argument version
11:18tmountainthanks
11:19Chousersure. don't know of any that is like a <= b < c, which I've wanted once or twice.
11:20ben_m,paste
11:20clojurebotjava.lang.Exception: Unable to resolve symbol: paste in this context
11:20ben_m!paste
11:20ben_mHm.
11:20Chouser~paste
11:20clojurebotlisppaste8, url
11:20lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
11:20ben_mOh ;)
11:23lisppaste8ben_m pasted "Clojure & Swing problem" at http://paste.lisp.org/display/87447
11:23ben_mIf anyone could take a look at that ... error etc. is at the bottom of the paste
11:23ambientbtw, does clojure have clear distinction between mutation and immutable? http://blog.plt-scheme.org/2009/09/set-vs-set-box-and-unbox.html
11:24ambienti wonder how syntax highlighting would work for that
11:25Chouserben_m: I get Unable to resolve symbol: x in this context, because the doseq is closed after the println
11:25Chouserambient: there's no perfectly reliable visual indicator, if that's what you mean.
11:26ben_mChouser: Oh sorry. I added that println for debugging purposes, it's not usually.
11:26Jomyootis there a way to concat results of doseq like mapcat?
11:26Chouserambient: functions that mutate tend to end with !, access to mutable things use either . interop or @, generally.
11:26ambientChouser only truly mutable thing in clojure i've found is arrays :p
11:26ChouserJomyoot: doseq has not results
11:27Chouserambient: all the reference types are mutable: atom, ref, var, etc.
11:27Jomyooti guess i use mapcat then
11:27ambientChouser as far as i've understood them, they're all atomic
11:27Chouserwell, protected yes, but still mutable
11:27ambienttrue
11:28ambientperhaps i should've formulated my question better
11:29Chouserben_m: .. returns the final thing, in your case the return value of setPreferredSize. Adding that value to 'frame' is what's failing.
11:29ben_mI feared it was something like that
11:30Chouserben_m: using 'doto' in there, or storing the fram in a local will clear that up.
11:31ben_mHow would I use doto?
11:32Chouser(.add frame (doto (new JLabel (str x)) (.setPreferredSize (new Dimension 10 10))))
11:34ben_mAwesome :)
11:34ben_mThank you.
11:37tmountainis there an easy way to see if a sequence contains a given set of values?
11:38Chousera set? like in order, or all of them in any order, or ?
11:38tmountainbasically just want to see if a sequence contains all values provided
11:39tmountainso if the sequence contained 1, 2, 3, 4, 5 and I provided 2 and 4, it would be true. 2 and 6 would be false
11:40tmountainI could do it with some loop logic, but I'm guessing there's probably a better way
11:40Chousertmountain: it's best to use a set instead of a seq if you're mainly going to be doing contains tests.
11:40Chousereither way, you might like 'every?'
11:41Chousuke,(every? boolean (map (set [1 2 3 4 5 6]) [2 4]))
11:41clojurebottrue
11:41Chouser,(every? #(.contains '(1 2 3 4 5) %) [2 6])
11:41clojurebotfalse
11:41tmountainoh, that's great
11:41tmountainthanks for all the help this morning
11:41tmountainplaying around with a yahtzee implementation in clojure ;-)
12:04Jomyoothow would I iterate over a [vector] with index i and concat all results?
12:04clojurebotwith style and grace
12:05Jomyootwell yeah
12:06stuartsierra,(map (fn [x i] (prn x i)) [:a :b :c] (iterate inc 0))
12:06clojurebot(nil nil nil)
12:07stuartsierra,(map (fn [x i] [x i]) [:a :b :c] (iterate inc 0))
12:07clojurebot([:a 0] [:b 1] [:c 2])
12:08Chouserwhich is what seq-utils/indexed does, I believe
12:12stuartsierrayep
12:41technomancyI'm thinking of adding more elements to the warning-face in clojure-mode. seems like set! should be in there; any other suggestions?
12:42technomancyio! is already there
12:44hiredmanaset*
12:44hiredman?
12:45technomancysounds good
12:58cgrandtechnomancy: symbols starting with &
12:58technomancycgrand: I don't even know what those mean. =)
12:58technomancycare to explain?
13:01cgrandI repeatedly saw newcomers to forget the space between & and the symbol in destructuring forms
13:01hiredman[a & b] vs [a &b]
13:02technomancyoh, to catch mistakes; I see
13:02technomancyor people forgetting clojure is not CL. =)
13:03hiredmanclojurebot: is this allegro?
13:03clojurebotthis is not allegro
13:37lisppaste8ben_m pasted "Problem & Question of style" at http://paste.lisp.org/display/87454
13:38ben_m^-- If anyone could tell me if some things are not idiomatic or some things are better done in another way
13:38ben_mAlso, at the commented two lines, some of the JLabels are supposed to have a blue background, but they don't :D
13:39manic12if I create a swing JFrame in clojure started from a command prompt, it works. if I create a JFrame in enclojure repl it gives a stack buffer overrun as it crashes
13:41manic12seeing as how I have to start and stop the enclojure repl just to recompile a gen-class, I think this may be a good reason to switch to something else besides netbeans
13:42manic12is emacs/slime/clojure the most supported setup?
13:57Licenser__you will like to hear that but I hate threads and locking *grrrr*
13:58ben_mAre you using Clojure?
13:59Chouserre-compiling and then using a genclass always requires restarting a JVM.
13:59samhugheshey there. calling (def #^{:private true} myname "samuel") keeps the variable only accessible to its namespace, but that's not the for refs, e.g., (def #^{:private true} myname (ref "samuel")). is there a reason for that?
14:00Licenser__ben_m: no that is the problem :P
14:00Licenser__I just wanted to use my frustration to cheer you people up
14:01ben_mLicenser__: Thank you kindly.
14:01Licenser__you are welcome ben_m, at lest someone can have a gain from this $§*!&*! code
14:05hiredmanI was just using some ruby xmpp bot library to monitor and control builds, that was a nightmare with regards to threading
14:06hiredmanI really should just throw it all out and do it in clojure
14:07samhughesspeaking of nightmare, (def #^{:private true} myname (ref "samuel")) not actually making myname private is a nightmare.
14:08hiredmansamhughes: does here
14:08Licenser__hiredman: I know ...
14:08hiredmansamhughes: what version of clojure is this?
14:08Licenser__but I've a ruby library that does not exist in clojure
14:08hiredmando you have a test case?
14:09hiredman~paste
14:09clojurebotlisppaste8, url
14:09lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
14:09samhughesi think it's 1.0.0
14:11samhughessure, one sec (on the paste)
14:14lisppaste8samhughes pasted "private refs" at http://paste.lisp.org/display/87456
14:18Chouserboth give an exception for me, in both 1.0.0 and latest master
14:19hiredmansame here
14:19hiredmanI just grabbed the 1.0 zip and this works as expected
14:20samhughesyou're right, with that test, it did. one sec. i'm going to retrace the sceneario and paste it.
14:21hiredmanI would suspect some sort of pollution, i.e. repl that has been running for a while and you having imports and uses and requires all over the place
14:23lisppaste8samhughes pasted "second try at refs" at http://paste.lisp.org/display/87457
14:24Chouserheh. don't do that.
14:25samhugheswhich part? i wouldnt normally have both namespaces in one file if thats what you mean.
14:25Chouserno, don't call 'def' from somewhere other than top level.
14:26hiredmandef is a global scope thing
14:26hiredmanand beyond that, def gets it's namespace stuff setup at compile time
14:26hiredmanso the namespace a thing is def'ed in is what namespace the form is in at compile time
14:27samhughesyeah. i just wanted a way to define it from another namespace but still keep it private. but i could use ref-set within the function, and define outside, i assume?
14:27hiredmanin summary, don't do that
14:27samhughesreferring to the last thing i just said?
14:27Chousukeyou can do ref-set in the setup-ref function
14:27hiredmanno
14:27Chousukethat's the proper way
14:28hiredmanare you sure you need the ref?
14:29samhughesnot necessarily. i'm creating api for memcached, and want to keep my sockets alive. but it doesn't necessarily need to be a ref.
14:29hiredman:(
14:29Chouseron the other hand, what the heck is actually happening there?
14:30hiredmanit shouldn't be a ref
14:30hiredmandefinitely
14:30hiredmanrefs/atoms/agents are for holding immutable objects
14:30Chouser(meta #'my-ref) => {:ns #<Namespace names>, :name my-ref, :file "NO_SOURCE_PATH", :line 4, :private true}
14:30hiredman(that apear to change)
14:30Chouserthat all looks right, so why is the privacy check failing?
14:31samhughesbut my thinking was that additional sockets might be appended by multiple threads, so i'd want that happening in sync.
14:31Chousukemaybe because it's the same compilation unit? :/
14:31Chousukesamhughes: so you still want to have a global socket pool?
14:32Chousukein that case, a ref is fine.
14:32hiredmanChousuke: it doesn't fail here
14:33samhughesChousuke: yeah, i think so. i'm guessing that i'll have multiple servers handling the pool.
14:34hiredmansamhughes: is there a reason to have the api keep track of the sockets, instead of having the user call an api method to create a socket, then pass it around, either via binding or explicitly
14:34hiredmanugh
14:34hiredmanChouser: the privacy check doesn;t fail here
14:35hiredman(use 'names) in the example does fail
14:35Chouserwell, it really does here.
14:35Chouseryeah, I used (refer 'names)
14:35hiredmanhoho
14:35hiredmaninteresting
14:35Chouserbefore calling setup-ref: (meta #'names/my-ref) => {:ns #<Namespace names>, :name my-ref}
14:36hiredmanjava.lang.Exception: Unable to resolve symbol: my-ref in this context
14:36Chouserthe var is there with some metadata, but unbound.
14:36hiredman(after refer 'names)
14:36Chouserright
14:36Chouseroh
14:36hiredmannice
14:36Chouserwhich is all what I would expect
14:37Chouserthen after calling setup-ref, names/my-ref has the private flag and is bound. This surprised me -- I expected it to create a var in the testcase namespace
14:37samhugheshiredman: i'm still debating on the best route. but you're right, it may be better to keep them on the client side, adn have them passed in.
14:39samhughesyeah, because each server will have its own set of sockets.
15:36drewris there a version of future with a timeout?
15:38Chouserdrewr: it's been asked for
15:38drewrah, ok
15:38Chouserdrewr: actually, I have a unhappy implementation I'm using right now
15:39Chouseryou call the promise rather than deref'ing it, so you can provide the timeout as an arg. :-/
15:41hiredmantime out on the deref, or time out on what the future is doing?
15:42Chouseroh, mine is promise/deliver, not future. sorry.
15:42tomojI thought I remembered hearing something about how derefs automatically call functions.. seems they don't. is there something like that somewhere that I'm confusing this with?
15:42Chousertomoj: calling a var calls its value
15:42hiredman.get on the future object takes a timeout unit
15:43tomojChouser: sure, like (@foo) ?
15:43tomojbut I thought there was some special thing somewhere (maybe not with deref) where a function would automatically be called
15:43sfuentesso i'm new to clojure and i'm trying to learn the language by implementing a few data structures. i understand that clojure may already have sufficient data structures but this is again more of a learning exercise. anyway, i'm trying to implement a basic queue. the create-queue and dequeue functions are simple enough. however i'm stuck on writing an enqueue function.
15:44Chousertomoj: well, (#'foo) is like (@#'foo) or (foo) -- maybe that's not what you were thinking of though.
15:44sfuentesnow i don't want to traverse the whole queue to simply enqueue an item
15:44tomojChouser: exactly!
15:44hiredmansfuentes: see pop and peek
15:46tomoj(foo) == (@foo), that's what I was thinking of
15:47sfuenteshiredman: well i guess i'm trying to implement peek/last
15:47sfuentesbut in O(1)
15:48sfuentesi think last is O(n)
15:48tomojwhat's your underlying data structure?
15:48tomoja list?
15:48Chousertomoj: that's not true for all reference types
15:48sfuentesyes
15:48Chousertomoj: appears to work for vars and refs
15:48tomojso.. just store the queue in reverse order, like peek/pop/conj
15:49tomojthen enqueue/dequeue is O(1)
15:49Chouseryou can't do O(1) queue and deque on a list
15:49tomojsure you can..
15:50Chousernot a persistent list
15:50tomojoh
15:50tomojI'm thinking cons cells I suppose
15:50tomojpop isn't linear, though, is it?
15:50tomoj(nor conj?)
15:50sfuentesitems in a list can be referenced by index, no?
15:51Chousersfuentes: sure, O(n) though
15:51sfuenteswhat? indexing is O(n)?
15:51Chouserclojure.lang.PersistentQueue is built on a clever combination of a vector and a list.
15:52Chousersfuentes: yes! a list is essentially a linked list. traversal is O(n)
15:52tomojis the reason pop isn't O(1) similar to the reason hash access isn't O(1)?
15:52Chousersfuentes: vectors are indexed
15:52tomojI haven't looked into the implementation of persistentlist
15:53Chouserlist and vector both provide O(1) (or nearly) push and pop for stack-like access.
15:53sfuentesok so i guess i should be implementing my queue using vectors
15:53sfuenteswhat's the downside of that i wonder
15:54Chouserif vectors or lists could provide effiecient queue-like behaviour, they would already.
15:55tomojooh, *slaps self*
15:55tomojI was thinking of a stack, not a queue
15:55Chouserah. yes, both list and vector can do fast push (called conj) and pop.
15:56Chouserfor a list it's essentially the same as conj/rest. for a vector, pop is special.
15:58Chouserfinger trees provide fast consLeft/rest on the left and fast conjRight/pop on the rigth, so can be used as stack or queue going either direction.
15:59sfuentesI'm sorry, I was rudely disconnected so I might have missed a few things. Anyway, so if I want to implement a queue I should be using a vector, right? if so, are there any downsides?
15:59Chousersfuentes: if vectors or lists could provide effiecient queue-like behaviour, they would already.
16:00sfuentesit seems like state would help here
16:00sfuentesbut i'd hate to be accused of heresy.
16:00hiredmanhow would it help?
16:01Chouseryou can conj onto the right end of a vector fast, and traverse from the left fast (using first/next), but 'next' would return a seq not a vector, so conj on the right would no longer be fast.
16:01Chouseryou could build a mutable queue out of a doubly-linked list of 3-element arrays or something. :-(
16:02tomojPersistentQueue is not a finger tree, is it?
16:02sfuentesi retract my comment. is there such a thing as pointers or pointer-like things in clojure?
16:02Chousertomoj: no, it's a clever combination of a vector and a seq
16:02hiredmanI think the pqueue constructor takes a seq a vector and a map
16:03Chousersfuentes: building fast persistent data structures is hard, with the exception of the singly-linked list.
16:04tomojbut worth it :)
16:05Chouserbut PersistentQueue isn't *too* complicated, I guess. Might be interesting to try writing it in Clojure.
16:05Chouserwill have to be done eventually. :-)
16:07hamzahey guys, i am trying to create xml, been playing ith prxml, can i use to create a string instead of printing to out?
16:07hiredman,(doc with-out-str)
16:07clojurebot"([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."
16:08sfuentesChouser: so implementing an efficient queue in clojure is more difficult/complex than in a language like C?
16:09Chouserno
16:09hamzathx is this the recommended way of doing this or is there a lib that i am not aware of?
16:09Chouserimplementing an efficient persistent queue is more difficult/complex than a mutable queue
16:10sfuentespersistant is efficient in this context, correct?
16:11ChouserYeah, I guess I should have said efficient immutable.
16:11Chouserso pick a goal -- immutable queue or mutable queue.
16:11vyIs anybody able to succeed running (count (clojure.contrib.combinatorics/subsets (range 20))) without getting an OOM exception?
16:12Chouserif you want to try doing an immutable one, I'd recommend learning about an efficient data structure that someone else has already figured out -- Clojure's PersistentQueue, 2-3 finger trees, or something else.
16:14Chouseractually, creating and using a persistent collection would be much more difficult in C because of no GC.
16:15sfuentescouple questions here
16:15sfuenteswhy would i want an immutable vs a mutable queue?
16:18Chouserimmutable collections are much easier to use safely -- no iterator errors when they change while iterating, no chance some fn you call will delete data you need, no concurrency issues at all.
16:18hiredmanequal immutable things are always equal
16:18Chouserthey're very nice, and having good immutable collection and a standard API that supports using them comfortably is a huge part of what makes Clojure good.
16:20sfuentesi see. but mutable queues are more efficient, correct?
16:21Chouserthey can probably be made slightly faster, yes, though the computational complexity can be essentially the same (O(1) push and pop)
16:23sfuentesok so how can i have this O(1) for both push and pop in a queue?
16:23vysfuentes: If you're sharing those queues among many other concurrent tasks, then you'll need to copy them for each thread instance, which will significantly decrease the performance. OTOH, if there will be a single thread fiddling with the queue it'll much more efficient to have a mutable queue implementation. To summarize, that all depends on the specific problem domain.
16:24sfuentesi know you mentioned PersistentQueue, but I'm trying to write this
16:24sfuentesimplement this
16:24Chouservy: even in single-threaded contexts, immutable collections are frequently worth while
16:24vyChouser: +1
16:25Chousersfuentes: you could look at what PersistentQueue does (it's written in Java) and do something similar in Clojure code.
16:25sfuentesChouser: will do. thanks for the help
16:26Chousersfuentes: sure, good luck!
16:47manic12I got clojure going with slime, and I realized something very important...
16:47manic12all my frustrations were because of netbeans.
16:48manic12maybe not all of them, but at least most of them
16:50Chousukeheh
16:50Chousukenow you can find new frustrations with emacs.
16:51manic12i have been using emacs for over ten years
16:51Chousukehmm. I suppose you've found most of them then.
16:52manic12actually emacs is quite big, ten years isn't enough time to find all the frustrations
16:52vyWord.
16:53Chousukewell, yeah.
16:53Chousuketen years isn't enough to find all the *features*
16:54Chousukebut that's okay. I have used emacs only for a couple months and I've found enough for a while
16:55ben_mMy .emacs is so messy, I hate that :/
16:55Chousukeheh.
16:55ben_mMy .vimrc is only 10 lines or something.
16:55ChousukeI have an emacs.d instead, based on emacs-starter-kit
16:56hiredmanmy vimrc is just over 200
16:56Chousukeit provides a good base for keeping things organised :)
16:56ben_mChousuke: I should try that.
17:11manic12somebody should have warned me about netbeans
17:12ben_mWhat language do you come from? Before Clojure.
17:12manic12common lisp
17:12ben_moh
17:12ben_mThey should've warned you then.
17:12ben_mFrom my experience, only Java programmers actually like NetBeans.
17:19sfuentesi'm sorry, what's wrong with netbeans?
17:21ben_mI'm just not a fan of IDEs so I wouldn't know.
17:21manic12for clojure, it's like programming java with parens, but a little more frustrating
17:23sfuentesmanic12: how so? i'm not a java programmer, but i'm learning clojure with netbeans.
17:24manic12when the repl doesn't stop by itself for a stack overflow or some other reason, you have to restart it yourself constantly
17:24sfuentesoh i see. so its a repl thing
17:24sfuentesis that all?
17:25manic12it's not a dynamic language without a fluid repl, as far as i am concerned
17:27manic12sfuentes: that's not all, I just don't want to revisit the pain
17:31manic12except of course to cut and paste the code I left there into an emacs buffer
17:34ben_mI still think it is the best IDE out there.
17:34ben_mJust because of jVi
17:34Chouserben_m: have you used jVi with enclojure?
17:34ben_mI don't even know what Enclojure is.
17:35Chouserit's the clojure plugin for netbeans
17:35ben_mOh :)
17:35ben_mI don't really use IDEs, but when I have to (school), then I use NetBeans.
17:37jensliQ: Im reading clojure.contrib.def.
17:37jensliIn defnk theres a form: (-> arg name symbol)
17:37jensliIs because of a namespace thing, to make sure the sym gets interned in the right namespace?
17:39hiredman,(doc defnk)
17:39clojurebot"clojure.contrib.def/defnk;[[fn-name & fn-tail]]; Define a function accepting keyword arguments. Symbols up to the first keyword in the parameter list are taken as positional arguments. Then an alternating sequence of keywords and defaults values is expected. The values of the keyword arguments are available in the function body by virtue of the symbol corresponding to the keyword (cf. :keys destructuring). defnk accepts
17:40hiredmanjensli: that is to turn the keyword into a symbol
17:40hiredman,(-> :foo name)
17:40clojurebot"foo"
17:40hiredman,(-> :foo name symbol)
17:40clojurebotfoo
17:41jensliRight, so that they are avalible as syms in the func body. I see, cheers.
18:17manic12mystery solved: to call a native library, the function which loads the dlls must be AOT compiled
20:59Chouserrhickey: do you have any performance goals for finger trees?
21:00rhickeyas fast as possible?
21:00Chouseryeah.
21:00rhickeyI don't have any expectations really
21:01rhickeyclear + fast is ideal
21:01rhickeywhat are the issues?
21:01rhickeyor tradeoffs
21:02Chouserjust diminishing returns on time I spend on it vs. performance improvements
21:02rhickeyare you unhappy with where it's at?
21:02Chousera bit
21:03rhickeydo you know where the bottlenecks are?
21:03ChouserI've removed several, finding the next bottleneck takes more time than removing in usually.
21:04ChouserI haven't looked at it for several days, but I'm not relishing picking it up again.
21:04rhickeywhat kinds of things, and what kinds of speedups?
21:04sproingieis there any good introduction to finger trees that isn't in haskell?
21:05ChouserI was hopeful that when used as a queue (so no measurements involvements) that it would compete with PersistentQueues
21:05Chouserbut it's really not. Still 6 to 8 times slower.
21:07ChouserI've removed most of the apply calls, which gave 15% to 30% improvement for many tasks.
21:08ChouserI moved all measure calculations into delays, which also meant some are cached which weren't before, and that gave another 7-15% boost for split operations.
21:16rhickeyI imagine that the split/concat functionality would dominate the decision to use a finger tree
21:16rhickeyfor that there is no other game in town (at least in clojure)
21:20Chouserok. well, there's probably some useful work I can still do there. measure still does more seq and map work than it probably has to.
21:36rhickeyChouser: yeah, one of the problems is that you have to avoid some of the high-level constructs when building low-level things
21:37Chousersure, and I've removed those for a lot -- getting rid of (apply foo (concat ...)) constructs and similar has helped.
21:39Chouserbut I haven't done that for the measure/reducer stuff yet.
22:17rhickeyhttp://www.artima.com/articles/hickey_on_time.html
23:32arohneris there a way to clear the repl history?
23:48dnolenarohner: in slime?
23:51arbschtif you're using jline, it will be in a jline history file, probably ~/.jline-clojure.*.history