#clojure logs

2009-04-21

00:21eeeanyone know how to scramble a vector in clojure?
00:22eeethat is
00:22eeereturn a new vector
00:22eeewhere all the cells are mixed up
00:22eeefrom orig
00:24eeeoh shuffle
00:24eeewould be better to search on
00:25eeefound discussion
00:33eeesilly question but I can't figure out how to get the length/size of a vector in clj
00:50Cark(count [1 2 3])
00:52cmvkki'
00:52cmvkkve always thought that wasn't as clear as 'length'
00:52Carkfeels like a little soldier will start counting the items one by one
00:53cmvkkor...a puppet vampire?
00:53Carka kind and helpfull puppet vampire maybe
00:55Carkactually i use count most of the time when designing components in c# or delphi
00:58PuzzlerI can't get gen-class to work. I get the error "java.lang.Exception: Unable to resolve symbol: Compile in this context"
00:59PuzzlerNope, that's not the error...
00:59PuzzlerWrong copy and paste.
00:59Puzzlerjava.io.IOException: The system cannot find the path specified
00:59PuzzlerI assume that it has something to do with it not being able to write out the class to the proper directory.
00:59PuzzlerI've tried explicitly creating subdirectories called "classes" and such, but to no avail.
00:59PuzzlerAny suggestions?
01:18eeehi again
01:18eeeaccidentally lost my mibbit window
01:19eeei'm trying to use (count), but it won't count past 10000 on my collection
01:19eeeis that typical?
01:20Jedi_Stanniswhat happens after 10000?
01:20eeei may have found something that works
01:20eeei think it was 100000
01:20eeejust always shows that
01:21eeetrying again
01:21Jedi_Stannisseems to be working for me
01:21Jedi_Stannis(count (take 10000000 (repeat 1)))
01:21eeereally forcing it now: (println "shuffling " (count (seq orig)) " ints")
01:21eeetry to count one more just for fun
01:22Jedi_Stannisdoes seem to b O(n)
01:22eeededuping 20,000,000 ints shuffling 100000 ints
01:22eeesee what it said?
01:22eeewhat are the odds that there are always exacly 100000 after deduping?
01:22Jedi_Stannispossible that theirs a bug in deduping?
01:22eeenow if I do a smaller initial number
01:23eeededuping 200,000 ints shuffling 86492 ints
01:23eeesee?
01:24eeei'm just putting stuff in a sorted-set
01:24eeeand trying to count the items after
01:25Carkcount just plain works, there's no question about it
01:25eee(def orig (loop [ret (sorted-set) i 0] (if (< i 200000) (recur (conj ret (rand-int 100000)) (+ i 1)) ret)))
01:25eeehmmmmm
01:25eeecoincidence that the rand ints go up to 100000
01:25eeethat's it!
01:25eeeprobability
01:26eeeduh
01:26eeeused the ints up
01:26eeethanks!
01:26eeeneed a higher max int
01:26eeein the rand
01:28eeesilly question
01:30Jedi_Stannisgeneral question: when writing code, and you notice some repeated code that should be factored out, but you don't have a good name for it - its just some repeated logic - how do you come up with a good name for it?
01:34replacaJedi_Stannis: that's always a tough one. I've never come up with too good a way. Sometimes you can use "helper" kinds of names, but that feels like kind of a cop-out
01:37PuzzlerHas anyone here gotten gen-class to work?
01:38Jedi_Stannisreplaca: yeah, I use that sometimes, but its sometimes spread out enough that there's not even a good thing to call it a helper to
01:52replacaPuzzler: yeah, I got it to work
01:52replacathe pretty print stuff depends on it
01:52PuzzlerI keep getting classpath errors. How do you set it up so that it works?
01:53PuzzlerWhere do I put the "classes" directory?
01:53replacayou can see what I did @ github.com/tomfaulhaber/cl-format
01:54replacawhat I have is cl-format/ then under that cl-format/classes and cl-format/com/infolace/utilities/PrettyWriter.clj
01:54replacafor instance
01:55replacaand my compile creates cl-format/classes/com/infolace/utilities/PrettyWriter*.class
01:55replacaYou can go look at my build.xml and all the files on github
01:55replaca(That version is out of date, but easier to see what I did)
01:55Puzzlerhmmm, I tried doing something like that.
01:56replacaMaybe just dowload my project, run ant there to be sure it works, and then compare
01:56PuzzlerSo what does your classpath line look like when you invoke the REPL where you call the compile command?
01:56PuzzlerOr you do everything with ant?
01:56replacaI do everything with ant, but you don't really have to
01:56replacaI just find it easier
01:57replacahang on, I'll go look at the file
01:58replacaI have .:classes:../clojure/clojure.jar
01:59replacaat least I think that's what ant is making out of the classpath info
02:33replacaIt is sweltering in SF tonight!
02:47lisppaste8hiredman pasted "meta charsequence" at http://paste.lisp.org/display/78942
04:21lisppaste8hiredman annotated #78942 "add hashCode and equals" at http://paste.lisp.org/display/78942#1
05:18dysinger"I for one welcome our new Oracle overlords"
06:27somethingis there a way to restart emacs without closing and opening? I updated my clj-server file, I think there's a way to refresh it, but I can't remember.
06:43hoecksomething: you can just restart slime, reload any given definition, restart a single mode, but i don't know of a global reset switch
06:44somethingok, thanks.
07:06djpowellPuzzler: have you sorted gen-class yet? Add the source and classes folder to your classpath. And bind *compile-path* to your classes folder, then it should work
07:43AWizzArdsomething: I just close the *inferior-lisp* buffer and then do "M-x clojure" again. This way I can keep my repl history.
07:46jdzmy slime keeps repl history even if i do ,quit
07:46jdzand even between emacs restart
11:53unlinkIs there a j2me port of clojure / is such a port expected to be difficult?
11:55replacaunlink: I believe that there are some features missing in j2me that make full clojure difficult
11:55replacaiirc, it's possible to do an interesting thing but would probably require some reorganization in core
11:56unlinkoh I see
11:56replaca(but I am not the authoritative word here)
11:59rhickeysvn 1354 adds *clojure-version* - feedback welcome
12:03replacarhickey: could you take a look at http://code.google.com/p/clojure-contrib/wiki/OverviewOfContrib
12:03replacarhickey: ?
12:04danlarkina welcome addition
12:04unlinkHmm, I was looking for something just like that, though noting the svn revision would be nice when appropriate
12:04replacarhickey: This is the "home page" of the auto generated doc for contrib and it has some boilerplate on who and what contrib is about that I'd like your input on
12:05rhickeyunlink: svn rev is not in the cards at present
12:05unlink...in the cards?
12:05danlarkinunlink: it's been discussed, but deemed impractical IIRC
12:06unlinkoh
12:06unlinkTechnically difficult?
12:06replacaunlink: the problem is that an svn rev is hard to do "portably"
12:06replacasince different floks get at the source differently (e.g., through git mirrors and the like)
12:07replaca*folks
12:07unlinkOh, well you can always say nil if you can't find it, I guess.
12:07rhickeyreplaca: looks like a good start - brief descriptions would be nice, I think you might want to use heading rather than bold on the names, also some subdirs are included, cluttering things up if they're not truly public entry points
12:08replacarhickey: thanks, yeah there is still a lot of formatting work
12:08replacato do
12:09replacarhickey: the short descriptions are going to be the responsiibility of the various contributors
12:09replacarhickey: you can scroll down to pprint and see the idea
12:10rhickeyreplaca: makes sense, also just gen semantic markup - maybe someone will contrib some CSS
12:11replacaI'm also going to suppport an exception tag on the namespace to say "don't document" and I think I'll just fold the sub-namespaces in under the primary namespaces for "cleanliness"
12:11replacarhickey: I'm also going to add a table of func names with direct links on the overview page for quick perusal
12:12replacaand an index page
12:12rhickeyreplaca: you should note that projects get added at my discretion - the talk on the group has largely ignored that. contrib is not a free-for-all. But your suggestion to release independently, talk about on group, offer to contrib is still correct.
12:12rhickeyreplaca: but these docs and nav pages much appreciated - thanks!
12:13replacathe problem with google wiki is that it's pretty restricted - I'm figuring I'll generate a second product which is pure semantic HTML in a zip file for consumption by others
12:13replacabut, one thing at a time :-)
12:14replacarhickey: OK, I'll tweak the wording appropriately
12:14replacathanks!
12:22stuhoodrhickey: that 'RC1' status isn't in effect until you roll another release, correct? perhaps versions checked out of SVN shouldn't be labeled that way
12:26rhickeystuhood: are you suggesting toggling that for a build that never gets checked in? Normally it will be SNAPSHOT between releases
12:26rhickeybut prior to a release?
12:28stuhoodrhickey: ahh... as long as it would normally be 'snapshot'. i figured the version would change as the last commit before a release
12:39replacarhickey: oh, could you put a link to that overview page in the project description on google code? Do you want me to write up some words and send them to you?
12:41technomancyare there any examples of enlive that use snippets?
12:41technomancythe bundled examples are rather... terse.
12:42replacatechnomancy: I think that dnolen is working on some more examples
12:42noidican you recommend any tutorials for someone coming to clojure from OO?
12:43noidior recommend any clojure _application_ code to read
12:44noidisomething that deals with domain-specific entities, and not just basic clojure data structures
12:44noidii've spent the last 3 days just thinking about this thing and it's driving me nuts :)
12:45technomancynoidi: Mire is a small complete application that might be good: http://github.com/technomancy/mire
12:45noiditechnomancy, thanks!
12:45technomancynoidi: I built it up step-by-step with each step in a separate git branch, so you can follow along with the development
12:45technomancyeach step builds on the last and adds a few key concepts
12:47noidia "gitorial", cool :)
12:47noidibtw, is On Lisp? worth reading?
12:49Raynesnoidi: Yes.
12:50replacanoidi: many of us love it. It does give you some flavor of the power of Lisp
12:50noidiI tried to take a look at the final chapters of Practical Common Lisp, which solve "real-world" problems, but they all seem to use CLOS :/
12:51replacanoidi: You can almost think of it as the equivalent to OO's patterns for Lisp
12:51noidiokay, then it's probably just what I need
12:55noidiwhile OO is not the right answer for every problem, it's become my default approach to programming (i.e. maybe 80% of my code is OO)
12:56noidiand now when learning Clojure, which seems very cool, I'm completely at loss when "everything I know about sw architecture is wrong" and I have no idea of the alternatives :)
12:57noidibut I'll read On Lisp, maybe it has the answers I need
12:59replacanoidi: When what you have is OO tools, you might as well take an OO approach. But it is limiting in some ways.
13:01replacanoidi: In clojure you can think about taking fragments of the OO system and treating them functionally by doing attributes with maps, alternative functions with multi-methods, and visibility directly with namespaces
13:02replacanoidi: The advantage here is that you only use what you need and you can take advantage of commonality elsewhere
13:02hiredman~ping
13:02clojurebotPONG!
13:02noidireplaca, my problem isn't technical, it's philosophical :)
13:03noidiI know that I can simulate aspects of OO that I need
13:03noidibut first I have to unlearn using OO "by default", i.e. writing mostly OO code
13:06noidibecause if I write Clojure that looks like Python with a different syntax, I might as well stick with Python
13:06replacanoidi: yeah, that's a big thing. I still struggle with that and I learned Lisp before OO!
13:07replacabut there's been *a lot* of OO in the middle
13:08replacanoidi: But don't worry too much - let it seep in.
13:08technomancyclojurebot: welcome back!
13:08clojurebotPardon?
13:08noidireplaca, heh, thanks :)
13:08replacaYour first program doesn't have to be a functional masterpiece
13:23Chousukenoidi: I think the important thing is to try to stop thinking of programs as a series of actions to execute. instead, it helps to try to visualise your problem as a series of transformations.
13:32replacahiredman: is it possible to make clojurebot ignore the autodoc robot updating the contrib wiki? That might get annoying.
14:14maaclHow would I add all jars in a given dir to the classpath using add-classpath?
14:14AWizzArdwrite a shell script
14:15maaclYeah, but if I really wanted to do it with add-classpath :-)
14:15AWizzArdOh, oki, inside Clojure
14:16AWizzArdin each .clj file the variable *file* is bound to the string which contains the path+filename of the respective file
14:16maaclyeah
14:16AWizzArdvia (.getParentFile (java.io.File. *file*)) you have the current directory
14:17AWizzArdtry (vec (.listFiles (.getParentFile (java.io.File. *file*))))
14:17AWizzArdThat should get you started
14:17maaclAWizzArd: thanks
14:19AWizzArdrhickey: thanks for *clojure-version*
14:20rhickeyAWizzArd: not sure I'm using it right yet, but you're welcome!
14:21AWizzArdI am glad that the infrastructure for it showed up. Good direction
14:22technomancymaacl: one trick I'm experimenting with is unpacking jars into a dependencies/ directory, then adding that to the classpath. that way you can add new dependencies without changing the classpath.
14:22clojurebotclasspath is (System/getProperty "java.class.path")
14:22technomancymaacl: since add-classpath is Fraught with Peril.
14:24Cark~add-classpath ?
14:24clojurebotclasspath is (System/getProperty "java.class.path")
14:25Carkif i add tehcnomancy's "Fraught with Peril", will it overwrite this ?
14:26noidiis it possible to shadow core names in a namespace?
14:27durka42Cark, i don't think so
14:27kotarakclojurebot: add-classpath is also Fraught with Peril!
14:27clojurebot'Sea, mhuise.
14:27noidithere are a few generic names that I don't need, but which conflict with the ones I'd like to use in my ns
14:27technomancynoidi: you need to use refer-clojure to exclude the core names; see enlive for an example. but it means people won't be able to refer to your namespace as a whole
14:27durka42~add-classpath
14:27clojurebotadd-classpath is bad, avoid it. I mean it!
14:27durka42~classpath
14:27clojurebotclasspath is (System/getProperty "java.class.path")
14:27Carknice
14:29noiditechnomancy, thanks!
14:29lazy1Is there a way to find all java object methods and attributes? (something like Python's "dir")
14:30durka42,(.getMethods String)
14:30clojurebot#<Method[] [Ljava.lang.reflect.Method;@1c4ff2c>
14:30hiredman,(map #(.getName %) (.getMethods String))
14:30clojurebot("hashCode" "compareTo" "compareTo" "indexOf" "indexOf" "indexOf" "indexOf" "equals" "toString" "length" "isEmpty" "charAt" "codePointAt" "codePointBefore" "codePointCount" "offsetByCodePoints" "getChars" "getBytes" "getBytes" "getBytes" "getBytes" "contentEquals" "contentEquals" "equalsIgnoreCase" "compareToIgnoreCase" "regionMatches" "regionMatches" "startsWith" "startsWith" "endsWith" "lastIndexOf" "lastIndexOf" "lastI
14:30lazy1Thanks
14:31noidiif I override the names, people can't :use my namespace and have to :require it, and call everything like foobar/baz
14:31noidibut if I don't override them, I have to add prefixes everywhere to avoid clashes, so foobar/baz becomes foobar-baz
14:31noidiat least with overriding I can drop the prefixes inside the namespace :)
14:32hiredmanyes
14:32hiredmanrequire is best anyway
14:32hiredmanrequire :as
14:33AWizzArdrhickey: *print-dup* is a fine thing and I am happy that it sits there, waiting for me. Great :) Just one request though: could you maybe add print-dup methods for Atoms, Refs, Agents and Futures?
14:34cadsIs there a way to search and document functions that specifically take a certain type of argument?
14:35cadssay I'd like to find the functions that work specifically on sets
14:36hiredmancads: clojure.set
14:36rhickeyAWizzArd: nope
14:36AWizzArdIs it better to add those in user code?
14:37rhickeynope
14:37AWizzArdHmm, is there technical problem for doing so?
14:37rhickeyyup
14:37rhickey17 questions left
14:37AWizzArdglobal locking issue?
14:38rhickey16
14:38AWizzArd;-)
14:38rhickeyif you print the same ref 3 times and read them in, what will you get?
14:38RaynesWhy do people have to think that without object orientation, code is a monolithic mess :\
14:39kotarakRaynes: because they don't know better?
14:40RaynesThis one instance, this guy is smart, and he has experience with functional programming, but still hates it. x_x
14:40cp2thats because languages without oo are heathen!
14:40kotarakRaynes: Well. You can't argue about taste, I guess.
14:41AWizzArdrhickey: okay, I will think about this issue, thanks for the pointer
14:46cadshiredman, how do I look in clojure.set?
14:47kotarakcads: http://clojure.org/api#toc649
14:47hiredmancads: it is a namespace, it is documented on the api page
14:48hiredmanyou can also look at clojure/set.clj
14:48hiredman(the source)
14:48noidiRaynes, people coming from most other languages have only seen well-design OO codebases, but not well-designed functional ones
14:50noidiokay, i'm generalizing out of one data point, me, here :) but this is one reason why a person might hold on to OO
14:52RaynesIt's true if you don't factor in the neat things most functional languages provide to encapsulate code, like Clojure's namespaces.
14:52noidiand with any paradigm it takes practice to understand which parts of it are dogma, and which parts are beneficial (and why)
14:53noidifor me it takes real effort to ignore the religious fervor of paul graham's writings about lisp
14:54drewcnoidi: graham can be safely ignored all-together ;)
14:55hiredman~Paul Graham
14:55clojurebotPaul Graham is the creator of the other new lisp
14:55Carkdrewc : except maybe for reading on-lisp
14:56noidihmm, that sentence came out kind of weird, I had a point but lost my train of thought while writing a follow-up sentence :)
14:57drewcCark: _maybe_ .. i read on lisp years ago, and have never needed it for reference. PAIP or PCL, OTOH, are sitting next to me right now.
14:58cemerick"other new lisp"? That's sort of generous, no?
14:58drewcCark: if On Lisp really taught me anything, it's that graham doesn't quite know what he's talking about :)
14:58noidiI guess the point was, that OO has been diluted from a religious silver-bullet thing into something that's "just the way it's done"
14:59noidiso compared to that, claims that OO is rubbish and functional programming is the one true way seem a bit loony and silver-bulletish
14:59drewcis this an OO vs Functional conversation?
14:59drewcbecause i'm a CLOS programmer ... ehem... and don't see the issue ;)
14:59noidis/conversation/monologue/
14:59noidi;)
14:59AWizzArdrhickey: I would love to use my remaining 16 questions *g*. What is the problem with printing refs or atoms in a dup way? For example (defmethod clojure.core/print-dup clojure.lang.Ref [o, #^java.io.Writer w] (.write w (str "(ref " @o ")"))) seems to work for a simple case such as (pr-str (ref {:a 10, :b 20, :c (ref {})})). When I (read-str) the result of that I get: (ref {:c (ref {}), :b 20, :a 10})
15:00drewcin fact, if one accounts for dynamic slot values ala ContextL, CLOS can be pretty close to 'pure', in the lack of side effects sense.
15:01drewcbut this is the wrong channel for CLOS discussions, so i'll slink back to my hole :)
15:01noidiI was just responding to [21:38] < Raynes> Why do people have to think that without object orientation, code is a monolithic mess :\
15:01Carkdrewc : oh come on, very good book for beginners
15:01Carkit helped me quite a bit with understanding macros
15:01noidibefore turning to rambling :)
15:02rhickeyAWizzArd: you didn't answer my question
15:03AWizzArdI would say that if I print a ref several times in a row then they should all yield the same result as long there was no state change during these prints.
15:04leafwany setLookAndFeel wizzard could explain me why setting the look and feel in a static { } block of a class has no effect at all? Would appreciate very much.
15:04drewcCark: what it doesn't help with is to know when not to use macros. I've seen enough graham-ified codebases in the real world to have some serious issue with that book and the authors claims and style. this is opinion, YMMV.
15:04leafwthat class is loaded. Methods are being called from it.
15:05AWizzArdOne potential problem I see is if there is no global lock: when we have refs of hashmaps in which the values are refs again, then there may be state changes during the printing which the MVCC can not prevent from creating inconsistent data
15:05rhickeyAWizzArd: print-dup [aref aref aref], then read it in, probably not what you want (3 different refs)
15:07rhickeyi.e. if a reference type appears more than once in an object graph, it will become multiple independent refs in the read result. For values this is slightly wasteful of space, but harmless. The only reason it works for vars is becasue they are interned
15:07rhickeybecause
15:08AWizzArdok, I begin to get your point
15:10durka42could they be printed with the hashCode() attached somehow, and then the reader could string them back together
15:11hiredman...
15:11durka42^ that means i said something stupid
15:12AWizzArdWell, maybe it is not that stupid
15:13Rayneshiredman: You're an arrogant stubborn bastard. But you're still my hero :> <3
15:14AWizzArdrhickey needs to care about a solution that works in general. But perhaps for some use cases the simple approach from above may work out, so some users could think about having this in their own code.
15:15hiredmanif you print-dup things on different jvms and then both on one jvm, there is a potential for collisions
15:15hiredman(using hashcodes)
15:16durka42true
15:17cemerickhashcodes are absolutely not meant to be "portable". You would definitely have rely upon object equality.
15:17AWizzArdAlthough this does not have to be a problem. Whatever the hashcode may be, it would just have to be unique, so that one can identify the same ref.
15:17clojurebotthis is not a bug
15:43hoeck should select-keys return a map of the same type as the given map?
15:43hoeckI'm just wondering wether the current behaviour is a feature or a bug
15:43hoeckafter selecting keys from a lazy-map
15:45kotarakhoeck: maybe a bug in lazy-map. Can you describe me how to reproduce?
15:46hoeckkotarak: no, select-keys always returns a PersistentArrayMap, it uses the {} literal instead of (empty..)
15:46kotarakAh. Ok.
15:47hoeckit took me a while to figure this out, as I was expecting select-keys to return a map of the same type
15:48kotarakI would think so too after reading the docstring.
15:48hoeckbut it doesn't explicitly mention it
15:49kotarakWhich I would expect, that it is a generic function not limited to hash-maps.
15:49hoeckright
16:29grosourshi
16:30hoeckgrosours: hi
17:53technomancyso I'm using proxy to wrap a Java class for testing purposes. the class's constructor takes an argument, but for testing this argument is irrelevant. Can I get my proxied object without calling the superclass constructor, or would I need to use gen-interface for that?
19:13duck1123has anyone tried updating swank-clojure recently
19:14duck1123I'm getting some errors after the most recent update
19:14dnolenwhat's the error?
19:15duck1123Could not locate swank/clj_contrib/pprint__init.class or swank/clj_contrib/pprint.clj
19:16duck1123I'm not sure if it's my version that's messed up, or if it's a result of the most recent merge
19:18dnolenyeah swank-clojure added pprint support recently
19:18dnolendo you have the latest version of clojure and clojure-contrib?
19:20duck1123yeah, I just pulled them as well
19:24dnolenyou need to compile clojure-contrib like so:
19:25dnolenant -Dclojure.jar path/to/clojure.jar
19:25dnolenthis will compile pprint
19:25technomancyit'd be nice if ant could look for clojure.jar somewhere by default and only need you to specify it if it wasn't found there
19:26technomancylike ../clojure/clojure.jar would be a great default
19:26dnolenI agree, it's a bit a annoying to have to specify it.
19:26technomancybut I don't know how easy that would be to express in ant's executable xml language
19:27technomancydon't want to get sucked into the turing tar pit
19:27dnolenone day clojure package manager and this will all be a bad dream. baby steps...
19:28duck1123so do you guys know of anything in clojure-mode that'll allow me to quickly jump to a function's test?
19:28technomancydnolen: =)
19:29technomancyduck1123: how would you calculate that?
19:29technomancyyou'd need some sort of convention mapping functions to their tests; none exists for Clojure code that I know of.
19:30technomancyunless you mean using the :test metadatap?
19:30duck1123I would adopt whatever convention allowed me to have that
19:35technomancywhy don't you ask on the mailing list what convention most folks are using?
19:36technomancywe're using a top-level test/ directory with tests all in the same namespaces as they're testing.
19:36technomancyload-foo would be tested in the test-load-foo deftest
19:36technomancybut I don't know if this is common.
19:37technomancysome projects just put tests in src/ and just keep them in different namespaces from what they're testing; contrib does this.
19:46duck1123that's pretty much how I have mine. the test for net.mycyclopedia.model.statement/select is in net.mycyclopedia.model.statementTest/test-select in the test/ folder
19:46RaynesDucky!
19:50dysingerI suspect that you have to do it like that (duck1123) because you cannot have 2 java classes with the same name in the classpath or one will shadow the other.
19:51technomancydysinger: I realized there actually is a good reason to AOT your tests: you can't use gen-interface without AOT
19:51dysingerah
19:51technomancyso if you do need that, then test/ mirroring src/ might not work.
19:52dysingeryeah gen-class and gen-interface would both require some AOT
19:53technomancythe main use for gen-class is so you can get -main functions to work correctly, right?
19:53technomancyISTR hearing that using gen-class directly (outside of the ns declaration) was deprecated
20:19emacsenI know I'm not the brightest, but does anyone have an example of using lazy-seqs on, say another list, or a file buffer or something where it's not a value you need to calculate?
20:20hiredmanah
20:23dnolenemacsen: check out duck_streams.clj in clojure-contrib for a file reading example.
20:23emacsenk, hold on
20:24lisppaste8hiredman pasted "lazy-seq example" at http://paste.lisp.org/display/78988
20:29emacsenhiredman, thanks. dnolen yeah I think the duck-streams is just what I needed to see thx
20:39arohnercmvkk: my guess as to why it's called length is that it doesn't imply a one dimensional view
20:45cmvkkI suppose, although in some sense it does imply a one dimensional view
20:46cmvkkoh wait i see what you mean. and I agree.
20:49arohneroh right, I should have said count
20:49arohnerwhat I meant to say is that length sort of implies a one dimensional view, and count does not
20:50cmvkkhmm, but in some sense, whatever you're counting is one dimensional anyway.
20:50cmvkklike if you have a list of lists, count won't give you a count of every item, just the items in the outer list.
20:52cmvkkin that way though, i think count makes sense. in other words, count implies one-dimensionality (which is correct) whereas length doesn't. ...or something.
20:52cmvkkanyway, whatever.
22:01Jedi_Stannisdoes anybody have any good pattern for doing before-methods with clojures current multimethods?
22:05dnolenJedi_Stannis: there's not an existing pattern, you could probably accomplish something like it with macros, do you need the full before/after behavior of CLOS?
22:06dnolenif not you could write some simple macros, Rich recently added support for getting specific methods by dispatch type.
22:06Jedi_Stannisnot really, just basically have some code I want to share between methods really
22:06Jedi_Stannisa helper function is somewhat un attractive code
22:06Jedi_Stanniso really? where are the details on that?
22:07dnolennot documented yet, get-method does the trick
22:08dnolentakes multifn plus the dispatch value, returns the matching method.
22:08Jedi_Stannishmm, that might be worth looking in to
22:08joha1having problems with " (use 'clojure.zip)" in the Repl. I get a "java.lang.IllegalStateException: next already refers to: #'clojure.core/next". what to do?
22:09dnolenyeah, it at least allows you share code between specific methods.
22:09dnolen(get-method your-multifn :before)
22:10arohnerjoha1: use "require" rather than "use"
22:10hiredmanjoha1: use require :as
22:10hiredman(require '[clojure.zip :as zip])
22:10hiredmanthen access via zip/next
22:11joha1thanks all, that worked. Have to check the doc for require
22:29tjkirchHi folks. Has anyone had trouble with vimclojure lately? I did some updates and something broke. The keybindings for gorilla just don't do anything now.
22:30Jedi_Stannistjkirch: just ain the process of updating, will let you know how it goes
22:31tjkirchJedi_Stannis: thanks. I'm not sure what happened, but I've been troubleshooting for days.
22:34tjkirchI've tried deleting and rebuilding everything, starting with a fresh vim config, manually binding the gorilla functions, but it just beeps. =/
22:36Jedi_Stannisnow your giving me second thoughts on if I should go ahead with the upgrade...
22:36durka42tjkirch: is the filetype clojure?
22:37tjkirchdurka42: Yes, filetype is clojure, clj_want_gorilla = 1, nailgun is running, etc.
22:38durka42hmm
22:39tjkirchAll of the non-interactive vimclojure features seem to work fine.
22:41durka42is vimclojure#NailgunClient right
22:42tjkirchI think so - ng is in my path, but I've tried with that set and unset
22:43Jedi_Stannishmm well I can't get vimclojure to build
22:43Jedi_Stannisjava.lang.ClassNotFoundException: clojure.contrib.pprint.PrettyWriter (pprint.clj:23)
22:44tjkirchI had that problem as well - it cleared up when I did an "ant clean" before building
22:45tjkirch(I cleaned and rebuilt clojure, clojure-contrib, and vimclojure just to be safe)
22:45Jedi_Stannisyeah I think it's a problem with my contrib
22:53hiredmanyou need to compile contrib
22:53hiredmanpprint doesn't work without gen-class'ing a class
22:53hiredmanand you need to compile to do that
22:55dnolenfrom the clojure-contrib directory
22:55dnolenant -Dclojure.jar ../clojure/clojure.jar
22:55dnolenoops
22:55dnolenant -Dclojure.jar path/to/clojure.jar
22:55dnoleni mean
23:02arohnerthis is sort of off topic, but there are a lot of smart people on here. I *think* I remember seeing a reference once to Prolog style inferences being NP-hard, and that the same limitation applied to generating optimal SQL plans. Is that true? If so, do you have references?
23:03hiredman~botsnack
23:03clojurebotthanks; that was delicious. (nom nom nom)
23:06replacahiredman: how does clojurebot know when there's an svn change?
23:06hiredmanpolls the svn log
23:08hiredmansvn helpfully outputs xml if you ask it to, easy on the parsing
23:08replacaahh, ok
23:09replacayou just do an "svn log" periodically? How often?
23:09hiredmanfive minutes I think
23:10replacaAhh, ok. That's pretty often. I was too shy to think about doing it that often for the autodoc robot
23:10replacait seems like autodoc and clojurebot are beginning to chat a little bit now :-)
23:11hiredmanyeah, well, clojurebot is racing rhickey's announcements
23:11replaca:-) and we know rhickey is fast!
23:12hiredmangoogle should broadcast svn changes over xmpp somehow
23:13lazy1Is there a way to get the numerator and from a clojure.lang.Ratio?
23:13replacahiredman: that would be nice
23:14hiredmanlazy1: (find-doc "denom")
23:14hiredmanor not
23:14hiredmanthat isn't actually useful
23:14lazy1:)
23:15hiredman,(map #(.getName %) (.getMethods clojure.lang.Ratio))
23:15clojurebot("decimalValue" "decimalValue" "hashCode" "compareTo" "equals" "toString" "intValue" "longValue" "floatValue" "doubleValue" "byteValue" "shortValue" "wait" "wait" "wait" "getClass" "notify" "notifyAll")
23:15lazy1Did that, what am I missing?
23:16lazy1I can do it ugly with toString and split, but looking for a better way
23:20replaca,(.denominator 1/2)
23:20clojurebot2
23:21replaca,(.numerator 1/2)
23:21clojurebot1
23:21replacalazy1: that what you want? :-)
23:22lazy1Yup, where did you find them?
23:22lazy1(and thanks)
23:24dreishThey're member variables, not methods.
23:24lazy1Ah
23:25lazy1s/.getMethods/.getFields/ in hiredman's map
23:25hiredmanugh
23:25hiredmanexposed fields
23:27replacayup
23:27replacawe need some more helper funcs for exploring Java classes
23:28replaca(unless they're already in contrib somewhere)
23:28hiredmanshow is in contrib
23:28replacaahh
23:28hiredmanuh
23:28hiredmanif it is called show
23:28hiredmanI forget
23:28replacaThat's why I'm writing the autodoc tool!
23:29replacabut I'm not to the index yet :-)
23:29dreishNeed a function that figures out what function I'm trying to think of.
23:29hiredmanoh man
23:29hiredmandid you see that one on the google group?
23:30dreishNot yet.
23:30hiredmanyou give it input and output, and it trys every function it can find looking for a match
23:30replacatime to write some AI
23:30dreishThis was actual code?
23:30replaca:-)
23:30hiredmandreish: yeah, dunno if it worked I didn't try running it
23:31hiredmanthis was a month or more back
23:31dreishNot sure how I feel about that.
23:31hiredmanI feel hilarious about it
23:31dreishIs every function safe to call with some random input?
23:31dreishSeems wrong somehow.
23:31hiredmanuh, depends what functions you have loaded
23:32arohnerdreish: yeah, you could call unsafeFireTheMissles, as the haskell guys call it
23:32arohnerbut if you had a whitelist of fns to call, you'd be fine
23:32dreisharohner: Is that in clojure.contrib.missile-utils?
23:33arohnerI saw a pretty funny blog post of a guy who searched through #haskell for unsafe*
23:36arohnerunsafeFireTheMissle, unsafeIO, unsafeAtAnySpeed
23:36arohneretc
23:36arohnerhttp://chrisdone.com/haskell/unsafe.txt
23:38Jedi_Stannishey, I posted the find a function to the google group
23:38Jedi_Stannisit set *in*, *out* to nil and caught all errors and discarded them
23:38dreishunsafeNoReallyWeMeanItThisTimeAndToProveItWeAreGoingToMakeThisFunctionNameUnreasonablyLongToPersuadeYouNotToUseItTooFrequently
23:39dreishJedi_Stannis: But did you remember to disable my function that formats the drive containing the given directory, or failing to find it, /?
23:40Jedi_Stannisguess not
23:41Jedi_StannisI think its safe enough if you know what functions are currently loaded up
23:41hiredmanJedi_Stannis: that was cute
23:42Jedi_Stannisjust got tired of trying to figure out what the function I was thinking of was called
23:42hiredmanbrilliantly functional
23:42Jedi_StannisI have the code if anyones interested
23:44dreishHow am I supposed to remember what your function is called?
23:44lazy1FWIW there's a "show" in clojure-contrib
23:45Jedi_Stannisdreish: lol, ill make you an anonymous recursive version of it, so you don't have to remember
23:45dreishJedi_Stannis: Makes sense. I could just remember how it works, and then re-derive it as needed.
23:46dreishI wrote an anonymous Y combinator in Arc.
23:46dreish[let f 0 (= f (_ [f _])) f]
23:47Jedi_Stannislol
23:47Jedi_Stannisim not even gonna try to figure that out
23:47dreishWhy not? It's lots of fun.
23:47Jedi_StannisI know, I lied, im already trying
23:48dreishArc [_] == Clojure #(%)
23:48Jedi_Stannisyeah, I followed arc for lil bit when it came out
23:48Jedi_Stannisthen I found clojure
23:48dreishClojure's a little more useful.
23:48arohnera little?
23:48Jedi_Stannisyeah, but I think pg likes it that way
23:48dreishA smidge.
23:49dreishJava has some libraries.
23:49Jedi_Stannishow's arcs let work? is their same crazy laziness going on in the = form?
23:50dreish= is assignment. (let x y @rest) is just (let [x y] @rest)
23:52dreishf is closed over, so changing the value affects what happens when the [f _] part gets called later.
23:54Jedi_Stannisok, I was thinking it was (let [w x y z])
23:54Jedi_Stanniswhich doesn't actually make any sense
23:54Jedi_Stannisnested [ ] work as _ from the closest scope?
23:54dreishYes.
23:55Jedi_Stannishmm
23:55Jedi_Stannis#( ) not nesting always bothers me