#clojure logs

2008-11-03

07:38AWizzArdDo you also have this? When you are chatting with other programmers and want to talk about closures you accidently write "clojures"?
08:22duck1123is there a BNF grammar for Clojure anywhere?
08:34rhickeyduck1123: I don't have one - there might be something in the enclojure project
08:40duck1123ok, I was looking info what it would take for semantic to recognize parts of Clojure code in clojure-mode, and it looks like we would need a BNF
08:40stuthulhurhickey: did you get my email Friday with book & sample code?
08:41gnuvinceGood morning everyone.
09:12lisppaste8gnuvince pasted "Short Clojure history" at http://paste.lisp.org/display/69627
09:12gnuvincerhickey: can you look at that paste I just made and tell me if this is accurate?
09:14Chousergnuvince: s/where/were/
09:14solkisdeveloping has one "p" and you have "where" instead of were
09:14gnuvinceChouser: this is going to be in French anyway :)_
09:14Chouserheh, ok.
09:15gnuvinceWeirdly enough, I find it harder to write in French than in English.
09:57rhickeygnuvince: technically correct, although I would say writing and maintaining correct imperative programs, concurrent or not, is too difficult
09:59gnuvincerhickey: OK, I'll correct it.
10:02lisppaste8gnuvince annotated #69627 with "take #2" at http://paste.lisp.org/display/69627#1
10:07rhickeygnuvince: looks fine
10:07gnuvinceThanks.
10:50ChouserIf I've got a stack of java.io things (somethingStream, StreamReader, BufferedReader), do I need to close each of them, or just one? Which one?
10:52stuthulhuChouser: no easy answer
10:52stuthulhufor the JDK ones, you could review the code and see which ones close contained things
10:52stuthulhubut for the interfaces in general you may not be able to count on wrappers closing their innards
10:53stuthulhuI'd be happy to be proven wrong on that, but such was the case the last time I looked (years ago)
10:53Chouserbleh
10:53Chouserthanks. :-/
10:54Chouserthe javadocs don't seem to address the question at all
11:03drewrIf I have foo/foo.clj and foo/bar.clj, how do I reference foo.bar?
11:04drewrClojure wants foo/bar/bar.clj, which defeats the purpose of having the subdirectory.
11:04Chousernot entirely, but it does reduce the purposes.
11:05Chouserif you want something at namespace foo.bar, put it in foo/bar/bar.clj
11:05drewrYep. It just bugs me.
11:06Chouserthere are rumbling that might chagne with AOTC
11:06drewrAwesome. I wish we would just copy Python's module system.
11:11drewrWe're half-way there...
11:14duck1123personally, I'd like it to search foo/bar.clj then foo/bar/bar.clj
11:14danlarkindrewr: I'm with you, the java packaging directory requirements are annoying
11:14duck1123but the current way isn't that bad once you resign yourself to having a lot of directories
11:15wwmorganI believe the rationale is that there's a one-to-one correspondence between directories and namespaces
11:17cemerickChouser: Readers and Writers in the stdlib have been closing whatever they're wrapping for a long while now
11:18Chouserwwmorgan: I think that's right. And the reason that's desirable is that it's normal in Java.
11:18cemerickI think JDK 1.3 was the last revision where there was any issue regarding cascading flushing/closing.
11:18Chousercemerick: oh, ok. so close the top-level thing?
11:19cemerickChouser: Yeah. I never keep separate references to nested streams/writers/readers. Stuff like this is very idiomatic: Writer w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(blah), "UTF8")));
11:19Chouserok, great.
11:20ChouserI mean, it's not great I need a half-dozen objects to read a file, but you know what I mean... :-)
11:20cemerickSure. Yeah, it's verbose, but on the other hand, it's very transparent, easy to understand, and easy to compose.
11:21Chouserheh, I disagree with the first two, but it's not worth arguing over. It's what we've got. And I must say, I appreciate duck-streams.
11:22cemerickyeah, maybe I'm just used to it :-P
11:45lisppaste8Chouser pasted "get-source" at http://paste.lisp.org/display/69638
11:47ChouserI know the implementation is ugly, but does that work for you guys/
11:47Chouserthat was prompted by a recent post on the google group.
11:48duck1123looks good, need to try it
11:49sohailChouser, what is the ^(...) syntax
11:49Chousersohail: short for (meta (...))
11:49sohailoh yeah, duh
11:49sohailthanks :-)
11:49Chouser:-) np
11:50sohailso anyone know why blip.tv insists on saturating my connection
11:50AWizzArdChouser: what will happen when AOT is available? Will the source go into the .class files?
11:50duck1123Chouser: will this work if the source is in a non-standard location or entered via the repl?
11:51AWizzArdduck1123: you can paste the code into your repl and see if it works for repl code
11:51ChouserAWizzArd: I don't know. I would be surprised if the source will travel with the compiled code by default.
11:52cemerickAWizzArd: no, no clojure source will be filtering into the AOT-compiled classfiles (at least, based on what rhickey has said so far)
11:52duck1123NPE if I try to source code entered in the repl
11:52Chouserduck1123: nope, this is relying on meta-data currently provided by clojure, which does not include the full path to the file nor runtime access to the actual source of the def.
11:53Chouserhm, I guess I could handle error conditions better. :-)
11:59lisppaste8Chouser annotated #69638 with "get-source with better error handling" at http://paste.lisp.org/display/69638#1
12:00gnuvincesohail: saturating your connection?
12:01sohailgnuvince, whenever I try to watch a clojure video on blip.tv, I can't do anything else on the net
12:03sohailcemerick, is AOT still in someone's mind at the moment or is rich actually implementing it?
12:04gnuvincesohail: that's not a blip.tv thing
12:04gnuvincesohail: they just have a really good upload speed
12:04cemericksohail: I gather that it's in progress now.
12:04gnuvinceIt's your OS that takes all it can.
12:05sohailgnuvince, ah, so I have to limit on my side :-(
12:05sohailmy network meter is showing "100% network usage"!
12:06Drakesoncan I "compile" a project written in clojure?
12:06Drakeson(to bytecode, etc.)
12:07solkissohail: you could download the presentation and then launch it locally
12:07sohailsolkis, oh, didn't know I could do that
12:08Drakesonsohail: you can even download the original format (most of the are .mov), so you can read the text on the screen easily.
12:08solkissohail: Download Playing link at the bottom of the page
12:09sohailvery strange, I don't see this
12:09sohaildo I need internet exploder for that?
12:09Drakesonno
12:10jkantzis there a way to escape spaces in symbol names in the spirit of :foo\ bar ?
12:11Drakesonoh, that's ugly
12:11solkissohail: there is a grey bar under the comments area titled Quick Links
12:12sohailsolkis, I don't have a comments section.. Obviously there is a PEBKAC somewhere
12:12ReplRatsohail: you can subscribe to clojure.blip.tv in iTunes. There's an RSS feed. I'm on a mac, and it downloaded about 1.4G. Well worth it in my opinion. Rich is a good speaker. I've listened to Clojure for Java Programmers and for Lisp Programmers so far.
12:13wwmorganjkantz: you could do (symbol "foo bar") and (keyword "foo bar"). But such practices are not recommended
12:14jkantzis there a restriction on characters allowed in symbols?
12:15jkantz(with-in-str (with-out-str (pr (keyword "foo bar")))
12:15jkantz(read *in*))
12:15jkantzdoesn't play nice
12:15sohailsolkis, I'm obviously having a problem with computers today... I can't even figure out how to add the rss feed to google reader anymore!
12:16kotarakjkantz: obviously whitespace is not allowed in symbol names.
12:16solkissohail: try this link in firefox: http://blip.tv/?s=search;topic_name=clojure&skin=rss
12:17sohailsolkis, I think I fail today
12:18Drakesonsohail: wget -c 'http://blip.tv/file/get/Richhickey-ClojureSequences284.mov' ?
12:20kotarakjkantz: http://clojure.org/reader have a look at the reader forms
12:25lisppaste8Drakeson pasted "get clojure screencasts" at http://paste.lisp.org/display/69641
12:26Drakesonsohail: that was for you
12:31gnuvinceWhat do you guys think of this definition of integer exponentiation: (defn pow [n m] (reduce * (replicate m n)))
12:31Drakeson(pow 2 0.5)
12:31wwmorgan(pow 2 0)
12:32gnuvinceDrakeson: integer exponentiation
12:32wwmorganalthough replacing reduce with apply will fix that I think
12:33gnuvincewwmorgan: return 1; (reduce * []) is 1.
12:33Drakesongnuvince: is -1 integer?
12:33wwmorganah. You're right
12:33gnuvinceDrakeson: yes.
12:34gnuvinceAlthough I don't the think the result is.
12:34Drakeson(pow 1 -1)
12:34sohailDrakeson, thanks!
12:34gnuvinceDrakeson: yeah, that won't work.
12:34sohailI guess it isn't a handicap to be slightly retarded in #clojure
12:35gnuvinceDrakeson: actually, for this particular case, it will
12:35Drakesongnuvince: oops, yeah!
12:35gnuvinceBut (pow 2 -1) will return 1 and not 0.5
12:36wwmorgangnuvince: I'm seeing better performance with Math/pow (about 4x faster), but your approach does arbitrary precision
12:37gnuvincewwmorgan: I'm guessing Math/pow is optimized a lot more than my attempt here.
12:37gnuvinceAnd my concern was indeed bigints
12:37gnuvinceDoing the "sum all the 2^1000 digits" from Euler
12:53Chousukedon't java bigints have a .pow() method or anything similar?
12:54gnuvinceChousuke: I don't know, I never wrote any Java (except for one semester in school)
12:54Chousukewell you should check
12:55Chousukethough if it's 2^1000 you need you don't need a generic exponentiation function. just bit-shift 1 a thousand times.
12:55gnuvinceChousuke: yes, they do
12:55gnuvincehttp://java.sun.com/javase/6/docs/api/java/math/BigInteger.html#pow(int)
12:56gnuvinceyeah, much faster
12:57ivanis there a bare-bones clojure syntax highlighter for IDEA 7 or 8?
12:59gnuvinceThe difference:
12:59gnuvinceuser=> (time (dotimes n 10000 (pow 2 1000)))
12:59gnuvince"Elapsed time: 18820.92753 msecs"
12:59gnuvinceuser=> (time (dotimes n 10000 (.pow (BigInteger. "2") 1000)))
12:59gnuvince"Elapsed time: 158.838221 msecs"
13:14danlarkinbet it'd be faster if you tried (time (let [bi (BigInteger. "2")] (dotimes n 10000 (.pow bi 1000))))
13:14danlarkinso you don't construct a BigInteger for each iteration
13:16gnuvincedanlarkin: 129 ms
13:16danlarkinmy runs vary between 90ms and 140ms
13:20gnuvinceI was surprised that a there was no way to build a BigInteger from an Integer.
13:21gnuvinceAh
13:21gnuvince(BigInteger/valueOf 2)
13:41lau_Good evening gents
13:42Chouserhi, Lau_of_DK.
13:43kotarakhi lau
14:03Lau_of_DKIm on my new work PC, therefore this weird question: Anybody here got my .emacs? :)
14:04kotarakyepp.
14:07Lau_of_DKkotarak, saves the day! :) The Emacs master! :)
14:08kotarakhahaha! More Vim grokker. ;)
14:38kotarakSince there were some questions on the list concerning macros, I thought it might be a good idea to have a tutorial in the wiki. Feel free comment, modify, improve: http://tinyurl.com/6y8857
14:41kotarakso you have diner, eg? ;)
14:49Lau_of_DKkotarak, as far as I can see it looks very good, and its definately needed on the site. I wonder though if the text could be shortned a bit to ease the reading?
14:50kotarakpossibly, I'm not a good writer. It's also kind of chaotic, because I just started writing....
14:50kotarakfeel free to do any changes!
14:52kotarakI tried to point out some of the caveats and pitfalls...
14:52Lau_of_DKYea that cant be emphasized enough with Macros
14:52RadioApeShotQuestion - is there a clojure function which will return to me the current classpath?
14:52Lau_of_DKImagine the power of macros in the hands of a Chouser... its destined for catastophy
14:52Lau_of_DK(System/getProperty "java.class.path") I think
14:53Lau_of_DK@ RadioApeShot
14:53kib2kotarak: I've installed Chimp (on Windows with cygwin) but that does not seems to work.
14:54RadioApeShotLau_of_DK: Thanks
14:55Chouserkib2: people have reported success there -- what's failing?
14:56kib2Chouser : this http://clojurepastebin.appspot.com/6
14:56kotarakkib2: chimp.sh your-clojure-start-script.sh
14:58kotarakLau_of_DK: shhhh....
14:58kib2kotarak: but my clojure start script is already a .bat file. Do I have to install clojure on my cygwin drive directory or just make a new bash script ?
14:59kotarakI suppose: chimp.sh foo.bat should also work
15:00kib2ok, I try
15:02kib2...idem ~(
15:03ChouserI usually need: chimp.sh -- your-clojure-start-script.sh
15:03kotaraktry giving it the full path.
15:03Chouserdouble-dash
15:05kotaraksince we have a few vimmers here now, again the teaser for the Chimp successor: Gorilla - http://tinyurl.com/5ma9d8
15:07abrookskotarak: Is there a quick summary? I'm currently a Chimp user.
15:08kotarakabrooks: a summary for what?
15:08abrookskotarak: Summary of the Gorilla vs Chimp differences.
15:09kotarakabrooks: there functionality is mostly equivalent. However Gorilla has no dependency on screen.
15:09kotarakabrooks: so everything works from inside vim. eg. a Repl in a vim buffer
15:09abrookskotarak: Ah. Does it provide it's own repl wrapping?
15:10kotarakabrooks: it's still pre-pre-pre-alpha, but I hope to get out a first version soon
15:10abrookskotarak: Are the sources anywhere public yet? I'm interested. :)
15:10kotarakabrooks: yes. Via network. So it's also easy to do remote Repling.
15:10kotarakabrooks: no. the sources are not public, yet.
15:11kotarakabrooks: I hope to release a first version tomorrow or sometime this week.
15:11Lau_of_DKkotarak, what would you say inspired you the most to write Gorilla?
15:12abrookskotarak: Very cool. I'll keep an eye out.
15:12kotarakNow that we get info back into vim, there are things possible, like omni completion with arglist, dynamic docstring lookup, etc...
15:13kotarakLau_of_DK: the little green ghost from the Ghostbusters movie ;)
15:13Lau_of_DKHaha
15:13Lau_of_DKYou mean Slimy Emacs ? :) Thats his full name btw
15:13abrooksSlimer
15:14kotarakabrooks: there is a dependency on Ruby however, but I can leave with it for the advantages it brings over Chimp
15:14kotaraks/leave/live/
15:15abrookskotarak: Ruby for the Vim bindings or stand-alone Ruby?
15:15kotarakruby-enabled vim
15:16kotarakthat is +ruby in the :version output
15:16abrooksPerl Vim bindings are pobably the most common for portability sake.
15:17kotarakabrooks: but I don't Perl at my work, Ruby is available however.... (you see the point ;))
15:18kib2kotarak: sorry, I had my baby crying. Yes, I have ruby inside Vim.
15:19abrooksWe really just need Clojure bindings in Vim... :-p
15:20abrooksI don't think I'd suffer the JVM + compile + byteload overhead for each Vim startup.
15:20kib2oopps sorry : I don't have Ruby inside because I've compiled myself and forgot to do so.
15:20Lau_of_DKCan I ask a serious question abrooks? On one hand you have Vim, for which you basically need to write a small OS for it to have any function. On the other hand you have emacs, swift and powerfull, abounding in features. Why not just use emacs ?
15:20Chouserabrooks: but a clojure-client in vim would work nicely.
15:21abrooksChouser: True.
15:21kotarakkib2: no problem.... for now, but Gorilla, the Chimp successor, will need it.
15:21kib2kotarak: Chimp does not need Ruby at the moment right ?
15:21kotarakkib2: no
15:21kotarakkib2: only screen (and Cygwin for Windows...)
15:22kotarakI think Ruby is the more tolerable dependency compared to Cygwin...
15:22abrooksLau_of_DK: It really comes down to modal editing which doesn't require laying on CTRL/META, etc. and some amount of infrastructural inertial. I highly respect Emacs and semi-regularly consider switching.
15:22kib2kotarak: in cygwin I had to install getopt too
15:22kotarakkib2: yes, sorry, needed for chimp.sh
15:22kib2no problem
15:22Lau_of_DKabrooks, but have you heard of Vim-mode for Emacs? :)
15:22abrooksLau_of_DK: I've considered Viper/Vile/etc. and have even tried them out.
15:23abrooksVile wasn't really enough. Viper was better but wasn't being supported (having been superceeded by something else).
15:23kotarakLau_of_DK: you are quite in a missionary mood for someone who was willing to try vim a week ago.... ;)
15:24Lau_of_DKkotarak, Im just asking the question, because Im curious. If people have good arguments for prefering Vim I'd like to hear them. Personally Im quite happy no matter what people use :)
15:24kib2kotarak: when do Gorilla be released ?
15:24abrooksChouser and I keep joking about writing textjure, an Emacs implementation which has an included Vim binding base.
15:24abrooksLau_of_DK: --^
15:24kotarakkib2: sometime this week, it's still unstable
15:25kib2kotarak: ok, thanks
15:25kotarakabrooks: there are also plans for clomacs
15:25Lau_of_DKclomacs :)~~
15:26abrooksLau_of_DK: gnuvince wrote this interesting Vim/Emacs comparison: http://gnuvince.wordpress.com
15:26abrooks/2007/02/24/emacs-and-vim/
15:26abrooksArg.
15:26Lau_of_DKI think you pasted that out of Vim
15:26abrookshttp://gnuvince.wordpress.com/2007/02/24/emacs-and-vim/
15:26Lau_of_DKThanks :)
15:26gnuvinceAnother post of interest is my "5 things I hate about Emacs and Vim"
15:26kib2abrooks: every try to make a vim/emacs clone had poor success. There's even tries in Haskell and Python.
15:26abrooksLau_of_DK: Cheap shot... no. GNU screen sometimes wraps and sometimes splits. I haven't tracked down yet...
15:26gnuvincehttp://gnuvince.wordpress.com/2007/03/28/five-things-i-hate-about-emacs-and-vim/
15:27Lau_of_DKabrooks :) Alright, you dont need to explain, I understand
15:28abrooksgnuvince: BTW, I enjoyed both of those posts.
15:28gnuvinceabrooks: thanks.
15:29gnuvincekib2: I'll probably need your help later this week to proof read a French blog post about Clojure.
15:29kib2gnuvince : Emacs has line numbers :)
15:29abrooksgnuvince: This weekend I added you to my Google Reader list. :)
15:30gnuvincekib2: a good one or a lousy .el script with the problems I described?
15:30gnuvinceabrooks: thanks :)
15:30kib2gnuvince : no problem, I'll read it : same topic as before ?
15:30gnuvincekib2: It's a general introduction to Clojure, a bird's eye view.
15:30Chouserabrooks: ah! you gave away the name!
15:31gnuvinceIt will take longer than I expected, because apparently I suck at writing directly in French ;)
15:31kib2gnuvince : so for sure I'll read because I need this :)
15:32kib2gnuvince : I was refering to http://www.emacsblog.org/2007/03/29/quick-tip-line-numbering/
15:32kib2nice blog about EMacs indeed
15:32gnuvincekib2: yeah, that's the one I tried. Notice how the 54 is the wrong color?
15:33kib2yes, first time I see this : I must be blind !
16:46drewrI feel like I'm missing a built-in macro for this pattern:
16:46drewr(map foo (map bar (map baz quux)))
16:47drewrDoes one exist?
16:47rhickey(map (comp foo bar baz) quux)
16:48sh10151sorry to bungee-question here
16:48sh10151is there a pretty-printer for Clojure?
16:48drewrrhickey: Ah, composition. Thanks.
16:48rhickeysh10151: not yet
16:48Chousersh10151: nope, but there's an open request to add one. go for it!
16:48Chouser:-)
16:48sh10151awesome
16:48sh10151that was my project to learn clojure
16:48sh10151:)
17:01drewrericthor, rhickey: How you guys feeling about tomorrow?
17:02rhickeydrewr: busy
17:02rhickey:)
17:02drewrHope everything goes well!
17:03rhickeythanks
17:06Chouserrhickey: substantial amounts of clojure code involved, or not really?
17:07rhickeyChouser: I absolutely cannot discuss, sorry
17:07AWizzArdwhen I (defn foo [..] ...) can I then attach meta data to foo?
17:07Chouserrhickey: :-) ok, np.
17:08wwmorganAWizzard: you could do (.setMeta #'foo {:bar :baz})
17:09wwmorganalt. (.setMeta #'foo (assoc ^#'foo k v))
17:09AWizzArdwwmorgan: thanks
17:09AWizzArdwhy is it not possible to do something like (with-meta (var foo) my-data-here)?
17:10rhickeyAWizzArd: with-meta returns a new value, and vars aren't values, can't have same semantics
17:11AWizzArdSo, does with-meta do this at read time?
17:11rhickeyAWizzArd: no
17:11rhickeyit's a regular function
17:27danlarkinre: tomorrow, I hope everything goes well too... heh heh *nervous chuckle*
18:02lisppaste8AWizzArd annotated #69638 with "Keep the code even in presence of AOT" at http://paste.lisp.org/display/69638#2
18:04wwmorganAWizzArd: You don't need setMeta for that. Just have the macro emit a (defn ~name ~args {:code '~body} ~@body)
18:05AWizzArdyeah right, I am doing this right now, thanks
18:17rhickeyClojure group passes 800 members...
18:18AWizzArdyeah, that's great
18:18AWizzArdbut it's nothing compared to what we will have soon
18:18AWizzArdWhen the real break through comes then hundreds of new users will come daily
18:20sohailwhat's the real breakthrough then AWizzArd ?
18:20AWizzArdI remember what happened to lighttpd. My ex class mate programmed it, and it had just a few thousand user. But at some day there were like 5k new users every day. Today it's one of the most used webservers. I hope Clojure will also have a nice break through.
18:20sohailI see
18:21AWizzArdit was very chaotic and no obvious reason was there.. it simply happened and the users came
18:24AWizzArdJust let an IDE like Enclojure be in place.. some more bloggers (also non-english blogs), some first success stories...
18:24rhickeyThe group is just an indicator of size, certainly not all users sign up, as they don't need to to read the list (can read via browser or RSS). For instance there were 3000 downloads and 56000 SVN reads in the past 2 months
18:26AWizzArdrhickey: I think the group is a very nice indicator. I am looking at these numbers also daily, and also see how many hits google returns
18:28AWizzArdIt's also fortunate that you (rhickey) are such a good speaker, as we can see in the videos. Components like these really help.
18:29sohailis it planned to move to git or do you guys just use git svn?
18:33AWizzArdsohail: why do you think that it may be planned to move to git? (not meant critical, I am just curious if this was mentioned somewhere in irc or GG)
18:34sohailAWizzArd, oh just because its a PITA to use svn and patch clojure if necessary
18:34AWizzArdWhat about darcs?
18:35sohaildarcs is not very nice to me..
18:35sohailwell, neither is git really but it's the latest fad to use git (/me prefers bzr)
18:38AWizzArdrhickey: what are the fine differences between lazy-cat and concat? As in:
18:38AWizzArd(def fibs (lazy-cat [0 1] (map + fibs (drop 1 fibs))))
18:38AWizzArdwhich could also use concat instead... both do the same when we say (take 15 fibs)
18:40AWizzArdoh I see... it accepts concat only if the var was defined before with lazy-cat
18:41wwmorganlisppaste8: url
18:41lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
18:42lisppaste8wwmorgan pasted "lazy-cat vs concat" at http://paste.lisp.org/display/69663
18:43wwmorganyou can also think about in terms of their implementations: concat is a function and lazy-cat is a macro
18:44Chouserwwmorgan: fantastic. I'd been wondering that myself. great answer.
18:57AWizzArdwwmorgan: my repl gives me a different result
18:58AWizzArdyour version with lazy-cat prints foo and returns (1)
18:59AWizzArdIn my repl it looks different. It prints foo but then writes, splitted on two lines: (bar 1) where "(bar" is in the first line and "1)" in the second.
18:59wwmorganare you taking 1 from it?
18:59AWizzArdyes
19:00AWizzArdI copy-pasted your example
19:00wwmorgantry it in java -jar clojure.jar and see if you get the same result
19:00AWizzArdlet me see if I can post a picture online somewhere
19:02AWizzArdyes, I get this in pure clojure in the shell, I get it in emacs+slime and in Enclojure
19:03lisppaste8wwmorgan annotated #69663 with "lazy-cat as it's defined for me" at http://paste.lisp.org/display/69663#1
19:03AWizzArdhttp://img221.imageshack.us/img221/9004/zwischenablage02lr9.png
19:03AWizzArdThis is a picture from within Enclojure. But I get the same in Emacs and in the shell
19:04wwmorganoh I think I know what it is
19:04lisppaste8AWizzArd annotated #69663 with "And this is my lazy-cat" at http://paste.lisp.org/display/69663#2
19:05wwmorganit's your take, I bet
19:06lisppaste8wwmorgan annotated #69663 with "my take" at http://paste.lisp.org/display/69663#3
19:07wwmorganolder implementations of take computed (seq coll) eagerly
19:08lisppaste8AWizzArd annotated #69663 with "Yes, my take is different" at http://paste.lisp.org/display/69663#4
19:08wwmorganyou can update to svn head or just edit your boot.clj
19:09AWizzArdThis difference is good, because I had a hard time to understand how the result could contain the symbol bar as println does not return it's string argument to symbols
19:10wwmorganthe old implementation of take evaluates one more element than it appears to need to, for certain kinds of collections
19:10AWizzArdNow I realize that it is not me that bends, but it's the spoon.
19:14Hun(boundp spoon) => nil
19:16AWizzArd;-)
20:59bradbevwhen I try to run Clojure's inspector (or any Swing window) from Slime on Windows, I get the window up & then it won't respond to any input, and I have to kill the VM to unstick it. The same things work on OS X. Am I missing something?
22:05danlarkinOooo I got an exotic error, java.lang.reflect.InvocationTargetException
22:13sohaildanlarkin, you haven't been using clojure enough then ;-)
22:35bradbevI asked a question & had to dash, sorry. Here is the question again.when I try to run Clojure's inspector (or any Swing window) from Slime on Windows, I get the window up & then it won't respond to any input, and I have to kill the VM to unstick it. The same things work on OS X. Am I missing something?
22:50danlarkinI'm trying to find a more memory-efficient way to do clojure.contrib.str-utils/str-join
22:54danlarkinbecause (str-utils/str-join "," (range 10e6)) overflows the heap
22:55danlarkinso I need some way of lazily consuming it but still making a string with the same effect as str-join has
22:56danlarkinI believe it's that str-join uses apply that ruins the laziness of the list
22:58bradbevSurely it's having to convert to a string is the issue? I'd guess strings can't be lazy
23:04Chouseris that like an 80MB string?
23:05danlarkinSo perhaps I need to use a StringWriter instead of just java.lang.Strings
23:05Chouserdanlarkin: you want that as a string, or in a file?
23:05Chouser(apply str (interpose "," (range 10e6))) is cranking away here, no overflow yet.
23:06danlarkinChouser: it'll get there
23:07danlarkinI suppose I'd like a string
23:08bradbevChouser: 80Mb? (reduce + (map #(inc (count (str %))) (range 10e6))) How did you do it?
23:10danlarkinin python I can run >>> len(",".join((str(x) for x in range(10e6)))) in a few seconds
23:10danlarkin78888889 is the result
23:22Chouserbradbev: that produces 78888890 which is 80MB, right?
23:22bradbevyeah, just wondered if you'd done the calculation in the same way
23:23Chouseroh, no, I just guestimated
23:23bradbev:)
23:24Chouserlargest number is 8 digits, times 10000000 is about 80MB
23:26danlarkinI don't think str is the problem, it's that apply keeps a reference to the head of the list
23:26bradbevI can't even do it using a StringWriter: (let [w (StringWriter.)]
23:26bradbev (doall
23:26bradbev (doseq n (range 10e6)
23:26bradbev (.. w (write (str n)))))
23:26bradbev w)
23:30ChouserI can make an array of the right size almost instantly.
23:30Chouser(make-array Character/TYPE 78888889)
23:31Chousermaybe you could dump your digits directly into the array and then construct a String from that.
23:31Chouser...but I'm off to bed. good luck.
23:32danlarkinChouser: thanks, I will think about that