#clojure logs

2009-10-16

00:27hiredmandamn
00:27hiredman:(
00:40durka42hiredman: now might be a good time to rotate passwords?
00:40hiredmanalready done
01:44kylesmithDoes anyone know if there are any bugs w.r.t. structs? I browsed through assembla, but didn't see anything. I have some code that works fine with maps, but if I use structs, everything goes straight to hell.
02:38gilbertleunghi
02:39gilbertleungi'm using clojure.jar and clojure-contrib.jar from the book "Programming Clojure"
02:39gilbertleungwhen i try to view source using the (source ...) macro
02:39gilbertleungin clojure.contrib.repl-utils/source
02:39gilbertleungall i get is a bunch of copyright statements
02:39gilbertleungwhat am i doing wrong?
03:09shantanuhi, i am looking for some information on how to encode characters in function comments
03:10shantanufor example, (defn foo "comment here with \" quote marks" [] (bar))
03:11shantanuis there a better way to express the double-quote marks in a comment?
03:12shantanui want to include code examples in the comment, so i need a simpler way
03:27cgrandshantanu: docstrings are strings and thus obey to string escaping rules :-(
03:29shantanu@cgrand: hmm, i wish docstrings had Python-like syntax :-)
03:30shantanuwell, is it then possible to create a macro? """comment begins here and can have "doube quotes" as well"""
03:30cgrandthere's a recent thread on the group about adding """ delimited strings to clojure
03:30shantanuokay
03:36cgrandshantanu: (defmacro add-example [sym example] `(alter-meta! (var ~sym) update-in [:doc] str \newline ~(pr-str example)))
03:36cgrand(defn foo "docstring" [] nil)
03:36cgrand(add-example foo (= (foo) nil))
03:37shantanu*wow*
03:37cgrandwon't work in all cases
03:37shantanuokay, the macro makes me dizzy though :-)
03:38cgrand(won't work = you won't get exactly what you typed in the docstring)
03:44AWizzArdcgrand: no, I saw 2 hours after I posted about the count/hashmap issue that it was fixed 3 days after I compiled a checked out Clojure ;)
03:48cgrand:-) still mea maxima culpa
03:58AWizzArdtechnomancy: good morning. Please look into your priv :)
03:59AndiXnghi
03:59AndiXnglittle GUI problem:
03:59AndiXng(defn -post-init [this]
03:59AndiXng (let [btn (JButton. "OK")]
03:59AndiXng (.addActionListener btn
03:59AndiXng (proxy [ActionListener] []
03:59AndiXng (actionPerformed [evt]
03:59AndiXng (JOptionPane/showMessageDialog this "blabla")
03:59AndiXng ...
04:00AndiXng"this" does not refer to the GUI component (JPanel), but to the ActionListener
04:00AndiXngis there a kind of "super" in Clojure, or how can I fix that?
04:01AndiXngor is "this" even reserved in Clojure?
04:01cgrandonly in proxy
04:02hiredmanAndiXng: just change the paramter name of the function
04:02AWizzArdAndiXng: you could also try nil instead of this.
04:02AndiXngaaah, I see, "this" is reserved
04:02AndiXngthanks!
04:02AndiXnghm, but with nil the dialog has no parent
04:02AWizzArdyes
04:03AndiXngwhich means that it is not always-on-top
04:03AndiXngbut it works, when renaming the parameter
04:03AndiXngthanks
04:03AWizzArdah hiredman, not sleeping. Of course :)
04:04hiredman:|
04:06AndiXnganother question: isn't it possible to override "finalize" in Clojure?
04:06AndiXngi found in an old chat log, that it was removed because of performance reasons
04:06hiredmanwhat do you mean override?
04:07hiredmanwhat?
04:07AndiXngi just want to have a deconstructor (called when GC removed the class), no matter if finalized is overridden or something else
04:07AndiXngis it possible?
04:10hiredmanare you using finalize for resource clean up?
04:11AndiXngI have a JavaSound synthesizer open
04:11AndiXngin an applet
04:11AndiXngwhen the sound engine class is closed, I want to close the synth
04:12AndiXngok, I could try it within the destroy-method of the applet
04:12AndiXngwould be the better way anway.
04:12AWizzArdWhy would that be a better way?
04:12hiredmanhttp://my.opera.com/karmazilla/blog/2009/01/14/getting-finalize-right-in-java-is-hard
04:13AndiXngno, it would not be better
04:13AndiXngbecause
04:13AndiXngthe sound engine should be able to close itself, without help from outside
04:13AndiXng(if the user forgets to call (close))
04:13hiredmanhow can you close a class?
04:13hiredmanyou mean call a close method?
04:14AndiXngok:
04:14AndiXngjavax.sound.midi.Synthesizer
04:14hiredmandon't paste a whole chunk of code
04:14AndiXnghas a close method
04:14hiredmanok
04:14AndiXngand I should call that method before the program exits
04:14AndiXng(I have to do that, because JavaSound is quite buggy in Sun's implementation)
04:15hiredmanhave you looked at with-open?
04:15AndiXngno
04:15AndiXngnever heard about that
04:15AndiXnggive me 10 minutes to read about it
04:16hiredmanten minutes?
04:18sgtzx_LauJensen: saw your last blog entry.. Good job!
04:18LauJensensgtzx_, thanks :)
04:18AndiXnghiredman: too easy for 10 minutes? :-D
04:19AWizzArdà propos closing a class.. can I get rid of them? Can I delete/gc classes in ram?
04:19LauJensenAnyone here who is advanced enough in math to reason about Mersenne primes with me in private for 5 minz?
04:19LauJensenAWizzArd, dropping the reference and waiting isn't enough?
04:20hiredmanAndiXng: it's a pretty sirt docstring, and the macro's usage us rather inuitive
04:20LauJensen,(doc with-open)
04:20clojurebot"([bindings & body]); bindings => [name init ...] Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order."
04:20hiredmanAWizzArd: like an actually Class class?
04:21AndiXnghiredman: yeah, but give me some time to actually understand what it does (I'm very new to Clojure)
04:21sgtzx_LauJensen: As a Python developer I know very well of the limitations imposed by the GIL, and I still love Python in a right-tool-for-the-job way. I think the examples you provided were interesting and I hadn't actually done much testing to see how much the scheduling penalty in Python could be (my Py code is mostly not using threads)
04:21hiredmanAWizzArd: you can, but you need to control the classloader to do so
04:21sgtzx_LauJensen There's a reason I use Java for enterprise stuff... :)
04:22AWizzArdhiredman: is that complicated?
04:22LauJensensgtzx_, oh ok. The examples all came from the Py community, but I glad you got something out of it
04:22AWizzArdThe thing I was thinking about: I need a dynamic parser. That is, a parser that gets changed while my program is running.
04:23hiredmansorry, I mean, Classes can be GC'ed under those circumstances, not that you can force a GC of them
04:23AWizzArdfnparse works good, but for performance reasons javacc would be faster.
04:23AndiXngother question inbetween: "(ns com.xenoage.labs.clj.eartraining.panel (:gen-class :extends ...." creates a new subclass for me. but how can I instatiate it? i tried to "(:use com.xenoage.labs.clj.eartraining.panel)" and then "(new applet)" but it tells me that the class applet does not exist
04:23sgtzx_LauJensen: Have you thought about CUDA + clojure?
04:23sgtzx_LauJensen: I.e. utilizing those powerful GPU cores with Clojure
04:23LauJensensgtzx_, Zach Tellman has already put up a great Mandelbrot Vs Clojure piece somewhere, which calcs using the GPU
04:23AWizzArdI could have a clojure program writing out the input for javacc. Then in the shell my program would call javacc on the generated input. Then it will call javac and compile the result into its classpath.
04:24AndiXng... ah sorry, I mean "(new panel)" of course
04:24AWizzArdThen it can load the fresh parser and begin to use it. But with such a method the old parser(s) would still remain in ram, but they are not needed anymore.
04:24hiredmanugh
04:25hiredmanAndiXng: for classes you use import, not use
04:25AndiXngarrr, yeah, thanks. what stupid question; I'm sorry.
04:25hiredman(the ugh was for AWizzArd)
04:26LauJensenhehe
04:26LauJensenAWizzArd, you're the duct tape programmer right ?
04:27AWizzArdUnfortunately all these parser generators have static grammars in mind.
04:28sgtzx_LauJensen: http://github.com/ztellman/penumbra/blob/master/src/examples/mandelbrot.clj
04:28sgtzx_LauJensen: very cool
04:28AWizzArdWith fnparse I can compose new parsers at runtime, but it is very slow in comparison to javacc.
04:28hiredmanhttp://stackoverflow.com/questions/1130869/java-garbage-collection-of-run-time-generated-code
04:28sgtzx_LauJensen: is he here? I wanted to ask him how the Penumbra uses the GPU directly... by way of a CUDA wrapper? I'd like to use my NVidia GPU to the maximum
04:29hiredmanI haven't really messed with classloaders, but I don't look briefly and (famous last words) they did not look very complicated
04:29AWizzArdhmm :)
04:29hiredmans/don't/did/
04:29AWizzArdhmm :(
04:30AWizzArdah ok, misread that don't
04:30LauJensensgtzx_, he's on vacation now - I want to do a blog piece taking Penumbra out for a spin, so I'll be tagteaming a little with him in the coming week
04:30LauJensensgtzx_, http://ideolalia.com/exploring-the-mandelbrot-set-with-your-gpu
04:30sgtzx_LauJensen: ok, sounds good
04:31sgtzx_yep saw that one :)
04:31LauJensenk, great stuff, he's very crafty
04:31LauJensen(a little too crafty with macros sometimes) :)
04:32hiredmanI think could just (.loadClass (ClassLoader.) "someClass")
04:32sgtzx_you know OpenCL? Now clojure bindings for that would be neat
04:32hiredmanor not
04:32hiredmanClassLoader is abstrac
04:32AWizzArdI will look into this. Sounds interesting and may be easy to test.
04:33sgtzx_I'm struggling to get my colleagues to look at Clojure though :(
04:33AWizzArdIn principle i should load some class C with my own loader L, kill all references to L and try to instantiate C.
04:34sgtzx_They think it's too far out there, in terms of syntax, "too FP" and also the prefix notation
04:34LauJensensgtzx_, no. I started on some wrappers for JMonkeyEngine though, that has some real potential, then I got sidetracked :)
04:34sgtzx_Mind these are a bunch of enterprise programmers
04:34sgtzx_LauJensen: do you have some clients at your company now that you are developing for in clojure?
04:35LauJensenNo, everything is painfully slow in Denmark at the moment, I'm afraid it'll be a little while before companies start developing/taking in new consultants again
04:35sgtzx_I see.. the recession hit you guys ?
04:36hiredmanI found an a.i. memo where sussman gets steele to take a chip design class, and for the class project steele made a lisp chip
04:36LauJensenAt first it lingered while we watched the rest of the world slowing down, we we're gearing up. Then almost overnight everything stopped. All contracts got cancelled/postponed etc.
04:36sgtzx_LauJensen: and if you got a nice assignment programming in Scala, would you take it?
04:37LauJensensgtzx_, probably not, but jobs always depend on: the job, the customer, the pricetag :)
04:37sgtzx_yeah
04:37AndiXnghm, I can't find the problem... http://nopaste.codersnet.org/pastes.php?view=270 but "Unable to resolve classname: panel (applet.clj:9)" - any idea? com.xenoage.labs.clj.eartraining.panel is a ns with (unnamed) :gen-class :extends JPanel (works perfectly)
04:37LauJensenhiredman, where do you find that stuff?
04:38sgtzx_LauJensen: that's why one of the things I do is .NET development. As long as the end goal is interesting. Right now I got .NET, Java (EE), C (embedded stuff), Python projects being worked on by me and my team
04:39sgtzx_However .NET forces me to run Windows. I miss OS X.
04:39hiredmanI was google for on of the λ the ultimate papers and found an mit ftp site with, it looks like, all of the ai memos
04:39hiredmanI am currently making a local mirror of all the pdfs
04:40LauJensensgtzx_, I try to focus on delivering quality of the highest degree, which means no/little imperative code. I'm not in a position where I want to compromise that + my reputation :)
04:40hiredmanftp://publications.ai.mit.edu/ai-publications/pdf/
04:40LauJensenhiredman, you getting into AI now ?
04:40hiredmannot really
04:40hiredmanthere is a lot of lisp stuff in there
04:41LauJensenk
04:41hiredmanthe problem is there is no way to recover the title of the memo from those pdfs
04:41LauJensenno meta data?
04:42hiredmanso I just have a bunch of AIM-????.pdf
04:42LauJensenI'm sure you can fix that with the pl macro ? :)
04:42hiredmannot that I can tell
04:42AWizzArdA compiled clojure-contrib.jar was around 2.5 to 3 mb in size some weeks ago. Now it's 550 kb. Is that right? It seems much less code gets compiled...
04:43jdzhiredman: somebody should run OCR on those memos...
04:44hiredmanI saw a memo on "building a hand like mechanism" so there must be an orc memo in there
04:44jdzhiredman: hmm, OCR would not be sufficient in many cases... but those reports good stuff!
04:44sgtzx_LauJensen: I also believe in delivering high quality... but I can't starve :)
04:45sgtzx_Sometimes you have to compromise....imho
04:45LauJensenSometimes... but not now :)
04:46LauJensensgtzx_, It was another story if I was employed by someone, then I would do as my contract stated.
04:46MaddasLauJensen: Out of curiosity, why not use Haskell then?
04:46sgtzx_Would be nice to have plenty of money so I could just fund myself to play around all day and eventually come up with something cool
04:46sgtzx_W/o the pressure of making it sell
04:46hiredmanAWizzArd: I still get jars of around 3 mb
04:46LauJensenMaddas, still learning it, ask me in a few months :)
04:47MaddasIf I don't forget :-)
04:47LauJensenhehe
04:47ambientbtw Lau http://tommih.blogspot.com/2009/10/python-clojure.html
04:47cgrandAndiXng: did you compile panel (I guess it's a genclassed namespace)?
04:48sgtzx_Lots of side-effects there
04:48sgtzx_:)
04:48sgtzx_and mutability
04:49AWizzArdhmm okay, then something is going wrong here, thx high
04:50LauJensenambient, clever boy :)
04:50ambienti was bored :D
04:50LauJensenoh you did that?
04:50ambientyeah
04:50hiredmanclojurebot: clojure?
04:50clojurebotclojure is far closer to perfection then python
04:50hiredman:/
04:50hiredmanthan
04:51ambientand that still is an advantage to python
04:51LauJensenah ok, then let me clarify: Clever way to post, referring mine then posting yours. The code looks like a dog vomitted on my screen? :)
04:51AndiXngcgrand: found the problem. i really have to :use the ns, not to :import the class
04:51sgtzx_LauJensen: naw man, it's Python, it's always beautiful :)
04:51LauJensenah ok, guess I missed that :)
04:52hiredmanclojurebot: python?
04:52clojurebotGabh mo leithscéal?
04:52sgtzx_clojurebot: scala?
04:52hiredmanclojurebot: python is ugly
04:52clojurebotIn Ordnung
04:52hiredmanclojurebot: show me scala!
04:52clojurebotshow is clojure.contrib.repl-utils/show
04:53hiredman~scala 1+1
04:53clojurebotInt = 2
04:53sgtzx_~scala hello
04:53sgtzx_So shy.
04:54hiredman~scala {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
04:54clojurebotAny = 1
04:54LauJensenhiredman, clojurebot is completely safe from blowing up due to overload now, loop/recur etc ?
04:54sgtzx_hiredman: are you a Scala fan?
04:54hiredmanLauJensen: safe is a strong word
04:54hiredmansgtzx_: nope
04:54LauJensenespecially in a <b> tag
04:55sgtzx_why not? :)
04:55hiredmanclojurebot's scala doesn't handle exceptions properly because when I was implementing it I never bothered to test with bad code
04:55hiredmansgtzx_: it's too complicated
04:56LauJensen,(loop [] (future (loop [] (recur))) (recur))
04:56LauJensenThat'll get a timeout?
04:56hiredmannope
04:56hiredmanwell, the outer one will
04:57LauJensenthat's enough though, it will kill the inner one as well ?
04:57LauJensen,(+ 2 2)
04:57hiredmanLauJensen: nope
04:57sgtzx_hiredman: doesn't seem much more complicated than java
04:57sgtzx_hiredman: apart from the extra syntax w/actors, functional programming
04:58sgtzx_hiredman: I don't know.. I'm just curious what you guys think
04:58hiredmansgtzx_: not really
04:58hiredmanscala is still tied to oo
04:59sgtzx_hiredman: but OO works very well with business programming
04:59LauJensenhehe
04:59LauJensenplease wake up sgtzx_ :)
04:59hiredman*snort*
04:59sgtzx_LauJensen: i'm hoping to...
04:59LauJensendo you think there's separate clojure and business domains?
04:59hiredmanscala strikes me as sort of second systeish
05:00hiredmansystemish
05:00sgtzx_LauJensen: nope
05:00sgtzx_LauJensen: but our brains think in objects, don't they? it's easy to think up: "ah, let's create a person, right, I want to use that object here and there, maybe let another object inherit from it, ..."
05:01hiredman~tell me about scala
05:01ambienti think in bubbles, actually, and streams
05:01hiredmandamn
05:01LauJensensgtzx_, No I wouldn't say I look at it like that
05:01hiredmansgtzx_: what is an object?
05:01sgtzx_maybe it's years of brainwashing, my exposure to OO
05:02jdzpeople think in individuals, not objects
05:02sgtzx_hiredman: an entity that represents something in my program, it can be modified, asked, and inherited from to create new entities that are slightly different
05:02hiredmansystemish
05:02jdzindividuals with properties
05:03sgtzx_jdz: sounds like an object to me, object = generic individual of which anew one can be instantiated at will
05:03hiredmansgtzx_: so if it can't be modified it's not an object?
05:03jdzsgtzx_: nope, that would mean that people have access to cloning
05:03hiredmanour java objects really objects? they cannot be inherited from, only Classes can be inherited from
05:03sgtzx_hiredman: in the conventional sense, I suppose it's not an object, no
05:04hiredmanare
05:04jdzsgtzx_: there is no inheritance in the real world
05:04hiredman~tell me about scala
05:04clojurebotscala is also<reply>"we are completely screwed on ==." -- seen in #scala
05:05sgtzx_jdz: but it is a nice way to visualize things. You start off with a ball, you inherit from it, add texture and content and call that Lemon
05:05hiredmananyway, hanging out in #scala gives the sens that scala is just java made more complex
05:05opqdonutsgtzx_: it's a horrible way
05:05opqdonutit doesn't show how inheritance is really used
05:05opqdonutcan you supply a lemon when you were asked for a ball? no.
05:05hiredmansgtzx_: so a lemon isa ball?
05:05jdzsgtzx_: no, it's not a nice way to visualise things (imho): look what it has brought upon us! (hint: C++ and Java)
05:06ambientall the people who use them can't be wrong...
05:06jdzlemon can be a ball depending on what you want to do with it
05:06hiredmaninhertience is nice for doing dispatch type stuff, the problem is people suck at it
05:06hiredmanschools don't seem to teach it
05:06sgtzx_hiredman: it's a ball, yes
05:06jdzbut that is not a feature of lemon, but the task at hand
05:06sgtzx_hiredman: it just happens to have a texture, and content inside
05:07hiredmanand most languages allow you to inherit from non-abstract classes
05:07jdzsgtzx_: i strongly disagree.
05:07sgtzx_hiredman: ok, maybe orange is a better example, it's more resembling a ball
05:07jdzsgtzx_: then you first must define what is a ball
05:07sgtzx_jdz: yea
05:07sgtzx_you must
05:07jdzsgtzx_: so, what is it?
05:08sgtzx_jdz: the details do not matter, you can define an abstract class and specify diameter, perhaps color and some other members
05:08jdzsgtzx_: makes no sense at all.
05:08hiredmanclojurebot: oo sucks
05:08clojurebotOO is to programming what astrology is to astronomy
05:08hiredmanbah
05:08sgtzx_jdz: the point is that now all other objects inheriting from ball, such as apple, soccerball, etc are all "balls"
05:09jdzsgtzx_: is a cardboard box a ball?
05:09hiredmanclojurebot: oo sucks is <reply>http://www.sics.se/~joe/bluetail/vol1/v1_oo.html
05:09clojurebotIn Ordnung
05:09jdzsgtzx_: if i play football with it?
05:09sgtzx_jdz: no, you wouldn't inherit frmo ball then, because it does not resemble a ball
05:09sgtzx_jdz: that's your call
05:09hiredmanis a webserver a ball?
05:10sgtzx_hiredman: you can inherit from ball, and tell others that a webserver is a ball, but the men in white coats would come and pick you up
05:10jdzsgtzx_: what makes apple a ball, and a box not a ball?
05:10sgtzx_jdz: the fact that the programmer knows that it is round, he is the one defining it
05:11jdzsgtzx_: not all apples are round.
05:11hiredmanthe other fallacy here is that oo is the only why to have hierachical dispatch
05:11sgtzx_jdz: the purpose of this example wasn't to be too detailed
05:11jdzsgtzx_: and you have fallen into the same tarpit other OO people have, namely, that a single individual may be many things at once depending on what you want to do with it.
05:11AWizzArdHow can I achive (defn foo [f] (println #'f))?
05:11sgtzx_jdz: but, let's just define that a ball doesn't have to be completely round then, but more or less round
05:12jdzsgtzx_: no, that's a wrong approch
05:12sgtzx_jdz: what is the right approach?
05:12AWizzArd,(let [f identity] (println "Var:" (var f)))
05:12clojurebotjava.lang.Exception: Unable to resolve var: f in this context
05:12jdzsgtzx_: that a bearing ball must be a perfect sphere, but a football ball can be a backpack
05:14sgtzx_jdz: let's say you have a collection, it contains many "things". Let's use cars as an example, you want to pick them out. However the collection also contains soccer balls. What is your approach to this?
05:14sgtzx_jdz: Cars can be many different things, but they have a few things in common; four wheels, steering wheel etc
05:14jdzsgtzx_: not necessarily
05:14jdzsgtzx_: what is a chair?\
05:15jdzsgtzx_: is it something with four legs and a horizontal surface, or is it something you can use to sit on?
05:15sgtzx_jdz: Let's assume then that this is your factory, and your have 8 different car models, they all have four wheels, steering wheel, brakes, etc
05:15AWizzArdAnd the big question is: if you remove just one atom of it, will it still be a chair?
05:15sgtzx_jdz: however some have different colors, some have V6 engines, and some have V8 engines
05:15AWizzArdIf yes, then one could repeat this step and see what happens :)
05:16jdzAWizzArd: right, if we focus on the four-legged-thing, what happens if i break on eoff
05:16hiredmansgtzx_: sounds like a bag of parts
05:16AWizzArddefining objects in the real world is not objectively possible, always just an opinion.
05:16sgtzx_jdz: regarding the chair, it is both... four legs, horizontal surface, sittable.
05:17AWizzArdsgtzx_: so if the surface has 1 degree difference from the horizon it's not a chair
05:17jdzsgtzx_: and then, break one leg off
05:17hiredmanwhat is the differece between that and Collection containing those parts?
05:17jdzsgtzx_: what do we get?
05:17sgtzx_jdz: something that does not qualify as a chair
05:17sgtzx_in practical terms, since you cannot sell it / use it
05:17jdzsgtzx_: no, it's still a chair, but with one leg broken off~
05:17jdz!
05:17jdzsgtzx_: and i can use it
05:17jdzsgtzx_: c'mon, sit on the side where you have the 3 legs, and no problem
05:18sgtzx_jdz: and if I take off the seat?
05:18sgtzx_jdz: still a chair, or just a few sticks
05:18jdzsgtzx_: exactly
05:18sgtzx_exactly what? :)
05:19jdzsgtzx_: if there's a frame that holds the legs together and you can use to sit on that thing, it's still a chair
05:19jdzif the seat was what holds the structure together, well, you no longer have a chair
05:19sgtzx_jdz: that is being very technical i.e. "how much can we remove before it is no longer a chair". You still end up with some shared aaspects of what a chair must have to be a chair
05:20jdzsgtzx_: that's not where i was heading.
05:20jdztake another example: what is a weapon?
05:20AWizzArdbreak this down to the subatomic level and the question of what is a thing becomes ridiculous.
05:20jdzsgtzx_: is table knife a weapon?
05:20jdzsgtzx_: is chair a weapon?
05:20sgtzx_jdz: first... let's do the car example before we forget about it :)
05:20hiredman,(let [basic-car {:wheels 4)] [(assoc basic-car :egine :v8) (assoc basic-car :seats :leather)])
05:20clojurebotUnmatched delimiter: )
05:20hiredmanbah
05:20AWizzArdIn the end one would have decide exactly how many particles should be bound together to make up a XY.
05:21hiredman,(let [basic-car {:wheels 4}] [(assoc basic-car :egine :v8) (assoc basic-car :seats :leather)])
05:21clojurebot[{:egine :v8, :wheels 4} {:seats :leather, :wheels 4}]
05:21jdzis car a weapon?
05:21sgtzx_and to define the carmodelX, it becomes quite simple
05:21jdzi mean: poeople kill with those things...
05:22ambientdepends on the context
05:22sgtzx_hiredman: that is actually quite similar, philosophically speaking, to OO
05:22jdzambient: right.
05:22hiredman(assoc basic-car :foor :fiftymikemike)
05:22hiredmanroof
05:22sgtzx_hiredman: you define something, then you define something else that takes basic-car and adds to it
05:22hiredmanno
05:22jdzsgtzx_: basic-car is a variable name
05:22sgtzx_ok then I misunderstood
05:22hiredmanabsolutely not!
05:23jdzsgtzx_: you can use "apple" instead
05:23hiredmanabsolutely not!
05:23hiredmanbah
05:23sgtzx_my question was, let's say you have a bag of things, a collection. You have bicycles in there, cars, soccer balls
05:23hiredmanirssi ate my line
05:23sgtzx_How do you identify all cars in that bag?
05:23hiredmanoo creates an isa relationship
05:23sgtzx_Some of them are different models, your factory has 8 models
05:23ambientif they tell me they are a car
05:23ambienti shall believe them
05:23sgtzx_and they all *have* to have 4 wheels, engine, brakes
05:23sgtzx_otherwise it is not a car
05:23jdzsgtzx_: by first defining what is a car and then looking in the collecting for matches.
05:24jdzsgtzx_: what? a car with 3 wheels is not a car anymore?
05:24jdzor with 8 wheels?
05:24hiredmansgtzx_: have you looked at multimethods?
05:24sgtzx_jdz: we assumed that all of the ones at your factory have 4 wheels
05:24sgtzx_jdz: let's assume that is a "car" for now
05:24jdzsgtzx_: well, and if somebody has parked his 6-wheel car in the factory lot, it suddenly is no longer a car?
05:25hiredmanyou can create a dispatch function which can check, does this bag have four wheels, does have a v8, etc ,etc
05:25sgtzx_hiredman: yes, i saw that... it's very interesting, but
05:25jdzsgtzx_: that assumption of yours is what i'm arguing against.
05:25ambientshouldn't you just care if the object has an adapter for the message you're going to send it?
05:25sgtzx_hiredman: what if there is another thing in the bag that just happens to have four wheels, v8, as well, but it is a tractor?
05:25sgtzx_hiredman: i.e. it matched everything, but it is not a car
05:25hiredmansgtzx_: if it matched everything then it is by definition a car
05:25sgtzx_in OO, you would knwo it's not a car, because it didn't inherit from the abstract Car class
05:26sgtzx_hiredman: but in reality it isn't... so what do you do?
05:26AndiXngany idea if (and why?) the ns "com.xenoage.labs.clj.eartraining.panel" is illegal? "com.xenoage.labs.clj.eartraining.panel2" works (just a "2" at the end). both compiles, but within an applet there is this strange error: http://nopaste.debianforum.de/29386
05:26jdzsgtzx_: then your OO is wrong
05:26jdzsgtzx_: because a tractor IS a kind of a car
05:26hiredmansgtzx_: that is just silly
05:26sgtzx_jdz: as I said, we assume "car" is something that only your factory makes
05:26jdzsgtzx_: tell me something you can do with a car that you cannot do with a tractor?
05:26sgtzx_want to call it something else?
05:27noidisgtzx_, instead of thinking in terms of data types, think about functions... write functions which only take the data they _need_, not functions which operate on some data type
05:27hiredmanthe idea of a one to one mapping between objects and physical entities is one the worst things about oo
05:27noidiand likewise return the data you have to return, not some type
05:27sgtzx_hiredman: could be
05:27noidiand then just slice and dice your data so that you can feed it to your functions
05:27hiredmanis
05:27sgtzx_noidi: that actually made sense
05:28sgtzx_hiredman: but in the example I posed, there was simply a bag of things
05:28Maddasjdz: Drive on the highway? ;-)
05:28sgtzx_hiredman: some of them were FactoryCars, some were Tractors
05:28sgtzx_hiredman: now, FactoryCar has 4 wheels, engine. So does Tractors
05:28jdzMaddas: you can do it on tractor. never mind the police, just drive through them.
05:28hiredmanwhat is the difference bwteen a car and a tractor?
05:28sgtzx_hiredman: But we wanted to pick out the FactoryCars
05:29Maddasjdz: Point conceeded.
05:29noidiif your function does something with wheels and engines, make it take a map with :wheels and :engine fields
05:29hiredmanwhat if someone drives the tractor on the road, do we consider it a car then?
05:29sgtzx_hiredman: I changed the example to FactoryCar now, to avoid the confusion
05:29sgtzx_hiredman: It *must* be a car from your factory.
05:29sgtzx_hiredman: Your factory has 8 models
05:29hiredman(assoc :factory :mine)
05:30jdzsgtzx_: my point is: one and the same thing (object; instance) can be many things at once. it can be one thing or the other or many at once depending on the context.
05:31noidiit's all just data
05:32sgtzx_hiredman: and then before you know it, your factory decides to produce tractors as well.
05:32noidiyou may interpret the same data as representing a tractor or representing a car
05:32jdzsgtzx_: i told you in the beginning of this discussion: in real world there are only instances; and there is no inheritance.
05:33hiredmansgtzx_: (assoc base :model tractor)
05:33jdzsgtzx_: all the classification stuff is purely mental device to optimise storage.
05:34jdzcgrand: correct.
05:34jdzcgrand: i mean, i agree :)
05:34LauJensenhehe
05:34noidisgtzx_, I had a huge culture shock trying to learn functional programming coming from OO, but I think I'm finally over it now
05:35octewhat would i use to join an array of strings in clojure?
05:35Chousukeapply str
05:35octeah
05:35noidisgtzx_, for me the big revelation was to start thinking about the functions instead of data types, like i said
05:35AndiXngnoidi: i'm still waiting for this state, but i think i'm on the right way ;)
05:35jdzocte: or interpose with a space or something else
05:35jdzocte: and then apply str
05:37ChousukeThe inheritance model is fine with a simple example like the Car-Tractor one, but then you'll get into trouble if you have your own data that's *almost* like the class that some API you're using requires...
05:37octejdz: thanks
05:37noidiinstead of artificially imposing a restriction like "this function only operates on tractors", write a function that works on things with wheels
05:37octethat's what i wanted to do
05:38noidi_if_ it happens to need wheels to do its job :)
05:38jdzclojurebot: logs
05:38clojurebotlogs is http://clojure-log.n01se.net/
05:38Chousukein fact, the data might be functionally equivalent, but since they're different classes they will be incompatible and you'll be :-(
05:38hiredmanhttp://gist.github.com/211677
05:39octeis there any way to get stacktraces that makes sense?
05:39hiredmanChousuke: like how every java lib has its own pair class
05:39octeyes, i wonder if they'll ever put a Pair<T1, T2> class into the jdk..
05:40Chousukethey should put a Pair *interface* instead ;/
05:40Chousukewith .first and .second
05:41hiredman.getFirstElement .getSecondElement
05:42hiredmanI, mean, this is java we are talking about
05:42AndiXnghm... i have two totally identical files (except the namespace), one has the ns "com.xenoage.labs.clj.eartraining.panel", the other "com.xenoage.labs.clj.eartraining.panel2". i tried it for 30 minutes now, the first one always results in http://nopaste.debianforum.de/29386 when using in an applet (desktop app works), the second one always works. is this possible or do you think i'm doing some nonsense here?
05:43hiredmanhow sure are you they are identical?
05:44hiredmanif you changed panel2 to panel would the sha1 of both files be the same?
05:44AndiXngcopy+paste everything, just added 2 to the ns. no self-references within.
05:45AndiXngi'll test
05:46hiredmanand where is the rest of the exception?
05:50sgtzx_sorry I was on the phone
05:50sgtzx_back now
05:50sgtzx_but I scrolled up and read
05:50sgtzx_It's definitely a culture shock... OO brainwashed mind -> FP
05:51noidisgtzx_, the important thing to remember is that there's no such thing as data having the wrong type. either you have the needed data or you don't
05:51hiredmanhttp://obiecte.blogspot.com/2008/09/oop-sucks.html
05:51noidiconverting it from one representation to another is easy and cheap in clojure
05:52sgtzx_noidi: i am always thinking in practical terms... my brain thinks in OO due to years of exposure
05:52sgtzx_brb
05:52noidie.g. if you have [[1 2] [3 4]] you can easily convert it to [{:first 1 :second 2} {:first 3 :second 4}] if that's what some function expects
05:54sgtzx_back
05:54sgtzx_noidi: yea I see
05:55AndiXnghiredman: this is the whole exception
05:55AndiXnghiredman: i'll upload a demo
05:56noidithe recently resurfaced sudoku solvers by peter norvig and ron jeffries are imo a great example of how beatiful non-oo code can be
05:56noidihttp://norvig.com/sudoku.html and http://xprogramming.com/xpmag/OkSudoku
05:57noidiand that is, also imo, much more interesting than whether or not tdd was used :)
05:58noidithe OO version gets all tangled up with classes, while the non-OO version is succinct and beautiful :)
05:58sgtzx_norvig loves python
06:00LauJensenhehe, nothing like nests of 'for loops'
06:00sgtzx_yea doesn't look very tasteful imho
06:00noidiLauJensen, they aren't really for loops, they're generator expressions
06:00noidijust like clojure's for
06:01LauJensenso why the many return paths ?
06:02noidiah yes, he uses regular for loops later on, but they're not nested ;)
06:03hiredmanhttp://lambda-the-ultimate.org/node/893 <-- venting on oo
06:04AndiXngapplet/applet2-problem: currently it seem to work ...?!? i hope, it is a NetBeans (plugin) cache problem or something like that, so forget it for the moment
06:06jdzbtw, remebered a nice article about modern OO: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html
06:08noidialso slightly related :) http://www.kimbly.com/blog/000063.html
06:08hiredmanhttp://lambda-the-ultimate.org/node/893#comment-8248 most of that thread is junk, but this is good
06:11noidione of the things that bothers me about oo "philosphically" is that it confuses objects for the real things that they represent
06:12noididata about the car is never the real car, no matter if its an instance of the Car class, [4 :ford] or {:wheel-count 4 :model :ford}
06:13ambientjdz iirc that was more about java
06:13jdzambient: no, it's about nouns and verbs
06:13noidinone of those is "more of a car" than the others :)
06:26AWizzArdHow can i make an array of 100 Objects? (make-array Object/TYPE 100) doesn't do the job.
06:27AndiXngAWizzArd: (make-array Object 100) ?
06:28rhickeyTYPE is only to get to primitive class through boxed class
06:28rhickey,Object
06:28clojurebotjava.lang.Object
06:28rhickey,Long/TYPE
06:28clojurebotlong
06:28rhickey,Long
06:28clojurebotjava.lang.Long
06:29AWizzArdoki thanks
06:29AndiXngbtw, both applets (applet and applet2) are working fine now. i suspect a cache bug in netbeans/enclojure
06:32AndiXngi think i found the reason for the strange bug
06:33AndiXngit seems, as if there is no main method allowed in classes loaded by a clojure applet
06:33AndiXngthis is strange, but i tested it repeatedly and the file with main method fails
06:35AndiXngand the error happens at a strange position ( http://nopaste.debianforum.de/29386 ). i'll try to create a simple example and post the bug to the mailing list.
06:37AndiXnghowever, the error is in the new plugin module, which is available only for java 6 update 14 or higher
06:37AndiXngcan anybody please test it? http://xenoage.com/temp/clj2/applet/ - should fail with the same error posted 2 lines above
06:39AWizzArdAndiXng: I get a NPE, at sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel(Unknown Source)
06:40AndiXngexactly
06:40AndiXngand this one should work: http://xenoage.com/temp/clj2/applet2/
06:40AWizzArdAndiXng: how many LOC of this applet did you write in Clojure?
06:40AndiXngit is exactly the same, but with no main method(s)
06:41AndiXngabout 100 lines
06:41ambientnew clojure-mode for emacs doesn't work anymore. it requires "swank-clojure-binary" or clojure jar path. upgraded from 1.5 to 1.8 through package-install
06:41AWizzArdAnd the .java loc?
06:41AWizzArdambient: do you use jochu or technomancy?
06:41AndiXngAWizzArd: 0
06:42ambientAWizzArd whichever clojure-install uses
06:42AWizzArdAndiXng: that's good, not too many.
06:42ambientclojure-mode works, but slime doesn't
06:42AndiXngAWizzArd: i think i'll post it as a second example in my applet tutorial (postet some days ago in the mailgroup)
06:43AWizzArdAndiXng: yes good, continue to post please. Btw, did you remove the main methods or renamed them?
06:43AndiXngAWizzArd: can you verify that http://xenoage.com/temp/clj2/applet2/ works?
06:43AndiXngAWizzArd: removed
06:43AndiXngAWizzArd: however, they should not be buggy, since they work when i start the program as a standalone app
06:44AndiXngAWizzArd: but i'll try
06:44AWizzArdyes, applet2 works. I am making funny sounds and bother my workmates :)
06:45rhickeyAndiXng: "class com.xenolabs.clj.eartraining.applet overrides final method"
06:45AndiXngrhickey: yes, this is when you are using java 5 or the old plugin, i guess
06:45AndiXngrhickey: and this is indeed interesting. i posted this already on the mailgroup. i think its a bug in clojure (compiler?)
06:46AndiXngrhickey: 'cause if you try it with java 6 (>= update 14 i guess) everything is fine
06:48AndiXngAWizzArd: renaming also works. it really seems to be the "-main" method which causes the problems.
06:53AndiXngAWizzArd: i could workaround the problem by creating a new file containing only the main method. this file is not referenced by the files used within the applet. then, the applet works.
06:57AWizzArdDid you test that?
06:59AndiXngAWizzArd: yes. in 10 minutes i've finished a small example demonstrating the "-main"-problem. i'll post a link to it here and (if anybody can reproduce the problems) in the mailgroup
06:59ambientwhat are the differences between swank-jonchu and swank-technomancy?
07:11octewhat would be the easiest way to have a loop counter in a doseq?
07:12octebasically what i want to do is: for(int i=0;i<strings.length;i++) print(i +". " + strings[i]);
07:20AWizzArdocte: you can use (doseq [[i s] (indexed my-strings)] (println i "and" s))
07:20AWizzArdindexed sits in clojure.contrib.seq-utils
07:20AWizzArd,indexed
07:20clojurebotjava.lang.Exception: Unable to resolve symbol: indexed in this context
07:21AWizzArdok, the bot doesn't know it, but just (use 'clojure.contrib.seq-utils) in the repl.
07:22octenice, thank you :-)
07:22jdz,(require 'clojure.contrib.seq-utils)
07:22clojurebotnil
07:22jdz,indexed
07:22clojurebotjava.lang.Exception: Unable to resolve symbol: indexed in this context
07:22jdz,clojure.contrib.seq-utils/indexed
07:22clojurebot#<seq_utils$indexed__697 clojure.contrib.seq_utils$indexed__697@85097d>
07:22jdz,(doc clojure.contrib.seq-utils/indexed)
07:22clojurebot"([s]); Returns a lazy sequence of [index, item] pairs, where items come from 's' and indexes count up from zero. (indexed '(a b c d)) => ([0 a] [1 b] [2 c] [3 d])"
07:26AndiXngif anybody has java 6 update 14 or higher and 5 minutes left to verify a bug, please help: http://www.xenoage.com/extern/bugreports/clojure-main-problem.zip
07:26AndiXngself-explanatory
07:26AndiXngjust call build.sh and then open the 3 HTML pages in your browser
07:26AndiXng2 should work (nomain and renamedmain) and 1 should fail (main)
07:28AndiXngcan anybody confirm this?
07:41ambientanyone had a problem with ELPA in Emacs where updating clojure-mode-1.5 to clojure-mode-1.8 breaks the system?
07:42ambienti don't want to delete all clojure directories and re-install but the alternative seems to be a lot of wasted time
08:04LauJensenAnyone here who is advanced enough in math to reason about Mersenne primes with me in private for 5 minz?
08:05vdrabI'm curious, what is the reason for the different ways of importing/using libraries? i.e., (import '(java.io Something)) vs. (use '[my-lib])
08:05vdrabwhy won't the latter work with quoted lists as well?
08:05LauJensenimport for java, use for clojure
08:05vdrabright,
08:05vdrabbut why the difference between lists vs. vectors?
08:06ambienti'd hazard a guess: performance characteristics
08:06vdrabhow so?
08:06ambientack, nvm
08:06LauJensenambient, for such a small op, what difference could that possible yield?
08:06vdrabalso, (use 'my-lib) seems to work too
08:07vdrabwithout the vector
08:07mikemvdrab: I think the vector allows for keywords, such as :as, or :only
08:07vdrabmikem: and lists don't?
08:08mikemvdrab: ah, I was comparing to your last example, (use 'my-lib)
08:08vdrabmikem: oh, sure.
08:09vdrabwell, it's not a biggie... it's just that most design decisions in clojure I've seen so far are really well thought out, so I wondered what prompted this one
08:10arbscht_,(doc use)
08:10clojurebot"([& args]); Like 'require, but also refers to each lib's namespace using clojure.core/refer. Use :use in the ns macro in preference to calling this directly. 'use accepts additional options in libspecs: :exclude, :only, :rename. The arguments and semantics for :exclude, :only, and :rename are the same as those documented for clojure.core/refer."
08:11LauJensenuse interns to your current namespace, require doesn't
08:11mikemarbscht_: yep, i read that. I just haven't written enough Clojure yet to completely understand :)
08:11mikemI'm still green
08:12vdrabon a related note, how can I import a single compiled java class (not in a .jar)? I'm pretty sure I specified the class path correctly, but it won't import...
08:14AndiXngwhat is the type hint for a String array?
08:14arbschtvdrab: (import 'packagename.Classname) or (import '(packagename Classname))
08:15arbschtvdrab: if you're sure the class path is correct, check again :)
08:15vdrabarbscht: I always need a package name?
08:15vdrabarbscht: lol. you're probably right
08:22rottcoddAndiXng: my guess would be #^"[Ljava.lang.String;"
08:27AndiXngrottcodd: thx
08:47rhickey,(class (into-array ["fred"]))
08:47clojurebot[Ljava.lang.String;
08:47jlillywhat does the -> function do in clojure?
08:48jlillybetter question: how can I figure that out myself?
08:48rhickey,(doc ->)
08:48clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
08:48LauJensen,(-> 5 (+ 2) (+ 3))
08:48clojurebot10
08:48AndiXngi hoped that the String[] typehint would fix the -main problem, but it is still there
08:49rhickeyhmpf, clojurebot elides the fact that it is a macro
08:49jlilly,(-> 5 (+ 2) (+ 3) (+ 10))
08:49clojurebot20
08:49rhickey,(macroexpand '(-> 5 (+ 2) (+ 3)))
08:49clojurebot(+ (clojure.core/-> 5 (+ 2)) 3)
08:50jlillyhuh.
08:50rhickey,(macroexpand '(clojure.core/-> 5 (+ 2)))
08:50clojurebot(+ 5 2)
08:51rhickeyso, (+ (+ 5 2) 3)
08:51jlillyreminds me a little of reduce, if I'm seeing it right
08:52rhickeyit is a code reorganizer, not a function
08:52jlillythat's kinda hurting my brain this early in the morning.
08:53rhickeythe best analogy is the threading one, where the initial arg gets passed to the first fn, then that result gets passed to the second, etc
08:54rhickey-> passes it first, ->> passes it last
08:54jlillythe threading reference didn't make sense, but that just sorta did.
08:54jlillyso it is kinda like reduce?
08:54jlillyexcept you provide a variable and forms instead of a function and forms?
08:55chouserI can see why it might remind you of reduce, but you wouldn't use it in similar circumstances.
08:55jlilly(GET "/product/:id"
08:55jlilly (str "You chose product: "
08:55jlilly (-> request :route-params :id)))
08:55rhickey,(->> [1 2 3] (filter odd?) (map str))
08:56clojurebot("1" "3")
08:56jlillythat's the context, from the compojure tutorial.
08:56jlillyrhickey: so that take 1,2,3 and maps them to strings, then filters out the odd ones?
08:56jlillyin reverse order b/c you did ->>, right?
08:57rhickeynot quite, the point of the ->s is to let you read left to right
08:57chouserinstead of inside out as you usually do.
08:57rhickeyso filters first, then strs
08:57jlilly,(-> [1 2 3] (filter odd?) (map str))
08:57clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: core$str__4257
08:58jlilly,(macroexpand (-> [1 2 3] (filter odd?) (map str)))
08:58clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: core$str__4257
08:58weissjis there any way to develop a java class and test at the REPL, without having to restart the REPL each time you edit/compile the java file? Some kind of classloader trickery?
08:58jlillythat's trying to do (map str (filter odd? [1 2 3])) ?
09:00chouserjlilly: note -> vs. ->>
09:00rhickeyjlilly: since -> puts the arg first, it will try to do (map (filter [1 2 3] odd?) str), which won't work. You an almost never swap -> and ->> since they work with functions that expect their args in different orders. ->> is most useful for the seq functions that expect the seqs last
09:00chouserjlilly: your expr would be like (map (filter [1 2 3] odd?) str)
09:00jlillyoh!
09:00jlilly-> makes it the first argument.
09:00jlillynot expands into the first function.
09:01jlillyI thought you meant that ->> would do the same as -> except expand into the last form first
09:01rhickey,(-> {:a 1 :b {:c 42}} :b :c)
09:01clojurebot42
09:02Chousukehmm
09:02Chousuke,(->> [1 2 3] (filter odd?) (map str))
09:02clojurebot("1" "3")
09:03jlillyso that called the map function with argument :b (which returns {:c 42}) and then called the map function on :c which returns 42?
09:03chouserChousuke: nice! but somehow I think I've seen that somewhere before...
09:03jlillyas I understand it, what I would know as dictionaries (python world) are actually function-like.
09:03chouserjlilly: yes
09:03Chousukejlilly: no, it called the :b function with the map argument, and then calls :c function with result of that. :P
09:03jlillyso if you call ({:key 4} :key) => 4 ?
09:03chouserexcept not "the map function"
09:04chouseryes
09:04chouserthat's calling the map as a function
09:04chouser"the map function" is the high-order lazy seq function named 'map'
09:04jlillygot it.
09:05Chousuke(macroexpand-1 '(-> {:a {:b 1}} :a :b))
09:05Chousuke,(macroexpand-1 '(-> {:a {:b 1}} :a :b))
09:05clojurebot(clojure.core/-> (clojure.core/-> {:a {:b 1}} :a) :b)
09:05chouserI suppose it's too late to start calling map collections "dictionaries" or "dicts"?
09:05Chousukehashmaps? :)
09:05chouserI suppose that implys keys are "words"
09:05jlillyso (-> {:a {:b 4}} :a :b) => (({:a {:b 4}} :a) :b)
09:06jlillyI think I've got it now :)
09:06Chousukejlilly: no
09:06chouserbut hashmap means something more specific... array maps and sorted maps are clearly not hashmaps.
09:06Chousukejlilly: it's (:b (:a {:a {:b 4}}))
09:06jlillyChousuke: ?
09:06jlillyhuh.
09:06chouseroh, sorry -- I mislead you. :-(
09:06jlillyso the keys of a map are also a function?
09:06Chousukejlilly: *keywords* are functions
09:07Chousukethey look themselves up in their argument
09:07jlillyI see.
09:07jlilly(({:a {:b 4}} :a) :b) -- that's also valid right? Just not what that expansion thing is doing.
09:07Chousukeyeah.
09:07Chousukebecause maps are functions of their keys
09:08jlillyalso, when would you want to use a keyword as a function and map as an argument rather than the other way around?
09:08Chousukejlilly: for example when the map is not a clojure map
09:08jlillyso when its a java thing?
09:08chouseror if the map might be nil
09:08Chousukeyeah. or when it might not be a map at all, but a set or something
09:08chouser,(:a nil)
09:08clojurebotnil
09:08jlillyooh. got it.
09:08chouser,(nil :a)
09:08clojurebotjava.lang.IllegalArgumentException: Can't call nil
09:09jlillyneat! :)
09:09chouseror when you want to use ->
09:09chouser:-)
09:09Chousuke-> is a bit weird at first but the way it works is really very simple
09:09jlilly(-> request :route-params :id) == (:id (:route-params request)) .. right?
09:09Chousukeyeah.
09:10jlillynow I just need to figure out what those variables are. hah.
09:10noidihmm.. is -> a monad? :)
09:10noidiafter all, it strings together a bunch of operations
09:10Chousukethe best way to learn how -> works is to use macroexpand on it a lot :P
09:10Chousukenoidi: no, it's a macro.
09:11Chousukenoidi: it has its own DSL that it transforms into Clojure expressions :)
09:11jlilly,(doc #"")
09:11clojurebotjava.lang.ClassCastException: java.util.regex.Pattern cannot be cast to clojure.lang.Symbol
09:11noidiI know that it's just rewriting code
09:11jlillysweet. tracebacks are docs enough :-P
09:12Chousukeheh :P
09:12Chousukeyeah, #"" is reader syntax for a regex pattern
09:14jlillyChousuke: I just saw yesterday that there are some weird shortcut stuff with #
09:14jlillywanted to be sure I was reading it right
09:15jlillyI think there's like #() and ^#()
09:15jlillyI think the 1st is an anonymous function, but I forget what the second one is.
09:15Chousuke#(foo bar) is a lambda shortcut
09:15Chousuke^foo is (meta foo)
09:15Chousukeand #'foo is (var foo)
09:15chouser^foo might be deprecated
09:16jlillyI just saw it in the clojure screencast on peepcode.
09:16jlillywhich is actually pretty decent. def. worth the $9
09:16jlilly(not for you guys, but still)
09:30namorHow would you take all but the last element of a collection?
09:31Chousukebutlast
09:31Chousuke(doc butlast)
09:31clojurebot"([coll]); Return a seq of all but the last item in coll, in linear time"
09:31namorcool, thx
09:32namorBTW, is there some better way to find functions than search the api page?
09:32chouserask in here
09:32chouser:-)
09:32namor:)
09:33chouserthe pages on clojure.org functions grouped by category
09:33chouserthere's a cheatsheet that some people seem to like
09:33chouserbtw, drop-last is an alternative to butlast
09:34noidinamor, (find-doc "related words")
09:53LauJensenis take-from-rear-of-seq in core yet?
09:57chouser~ticket #151
09:57clojurebot{:url http://tinyurl.com/ygjd5zx, :summary "Function to return last n items of a seq", :status :test, :priority :normal, :created-on "2009-07-12T02:45:06+00:00"}
09:59LauJensenno eta on that?
09:59rhickeyneeds a new name I think
09:59chouserlast-n ?
09:59rhickeyok
10:00chouserbrilliant and original, I know.
10:01cgrandlasts ?
10:02rhickeycgrand: somehow that makes me think I'll be getting more than one seq
10:02LauJensenits 'nth' from behind so to speak right?
10:02chouserLauJensen: no, it returns a seq
10:02LauJensenah ok
10:03rhickeytake-last would be another idea
10:04LauJensenrev-take ?
10:04chouserthose would be different from each other.
10:04rhickeyLauJensen: not retuned reversed
10:04chouseryou can already do (take (reverse ...))
10:04chouservectors already have subvec
10:04LauJensenok - I'll leave the name-selection to native english speakers :) Just let me know when I can use it
10:05chousertake-last would have the same behavior as last-n, right?
10:06jdztake n seq :from-end t
10:06jdztaking from end of inifinite sequences sounds like fun
10:07chouserwe already tried to stuff this behavior into 'last', but it didn't fit.
10:08cgrandthere's already drop-last, so take-last seems a good choice
10:10chouserIs it worth handling Indexed colls differently? I'm thining not.
10:10chouserthinking
10:10rhickeychouser: from an interface or impl perspective?
10:10chouserimpl
10:10chouserwell, both.
10:11chouserif the impl tried to take advantage of Indexed, then there'd be questions about what kind of object to return.
10:11rhickeychouser: let's say no to interface, still some advantage to impl
10:12rhickeythere is subvec already
10:12chouserright
10:13cgrandfrom an impl persepective, Counted is interesting, no?
10:15chouserwould allow you to keep less of the seq in memory while walking I suppose
10:16cgrandif Counted, take-last becomes a drop
10:29mibuJust popped in to say congratulations on the second year! The cake looks great.
10:40namorOk, so (seq "abc") returns (\a \b \c). How to get back from (\a \b \c) to "abc"?
10:41chouser,(apply str (seq "abc"))
10:41clojurebot"abc"
10:42namorHmm, so str returns a string if you pass it multiple characters as arguments?
10:43chouserstring always returns a string. it concatonates the string form of each arg
10:43chouser,(str \a \b 123 "xyz" Integer)
10:43clojurebot"ab123xyzclass java.lang.Integer"
10:43namorah, i get it. thx
10:46chouserrhickey: http://www.assembla.com/spaces/clojure/documents/b9iKQQUMir3OzreJe5aVNr/download/take-last.diff
10:51rhickeychouser: great - thanks!
10:54AWizzArdWhat should I use instead of doall?
10:54AWizzArd,(format "%s" (doall (map inc (range 5))))
10:54clojurebot"clojure.lang.LazySeq@1c3e4a2"
10:55chouserLauJensen: go go go
10:55octe,(format "%s" (map inc (range 5)))
10:55clojurebot"clojure.lang.LazySeq@1c3e4a2"
10:55octe,(format "%s" (apply str (map inc (range 5))))
10:55clojurebot"12345"
10:55octe,(apply str (map inc (range 5)))
10:55chouser,(format "%s" (pr-str (map inc (range 5))))
10:55clojurebot"12345"
10:55clojurebot"(1 2 3 4 5)"
10:55octedepends on what you want i assume :-)
10:57AWizzArdfine
10:58jlilly,(doc doall)
10:58clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
10:58jlilly,(doc pr-str)
10:58clojurebot"([& xs]); pr to a string, returning it"
10:58jlilly:-/
10:58jlilly,(doc pr)
10:58clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"
10:59jlilly,(doc println)
10:59clojurebot"([& more]); Same as print followed by (newline)"
10:59jlilly,(doc print)
10:59clojurebot"([& more]); Prints the object(s) to the output stream that is the current value of *out*. print and println produce output for human consumption."
10:59jlillyahh. print and println are for humans, pr and pr-str are for.. ? Network sockets and such?
11:01chouserjlilly: or the repl
11:01jlillychouser: which is for the repl? pr?
11:02chouserthe P in REPL is pr or prn
11:05jdzLauJensen: i just made a brian's brain simulator in CL (a very naiive version with board as a 2d array and making new boards in every iteration). it runs tons faster than the Clojure version...
11:05AWizzArdI have (binding [*in* (foo)] (let [x 1] ...)). Is it idiomatic (and correct?) to say (binding [*in* (foo), x 1] ...) instead?
11:05jdzLauJensen: i'll cooble up some blog entry (when i create a blog)
11:06chouserAWizzArd: won't even work unless x is var
11:06chouserAWizzArd: so, no.
11:06AWizzArdoki
11:24cgrandchouser: shouldn't take-last returns a lazy seq like drop does?
11:37chouserif the input seq is lazy, it will -- except it has to be realized first to know where the end is.
11:40chouserso it can't ever return an unrealized lazy seq. Only if there were a counted lazy seq could it, and we don't generally have such critters.
11:41rhickeychouser: not quite, as a seq from a point on a counted/indexed thing need not be realized, even though the source isn't lazy
11:44maacl_LauJensen: you around?
11:44chouserso if it had a special case for a counted/indexed coll, it could return an unrealized seq over the end of the collection. As it is, it returns a realized seq of the same.
11:45chousercgrand: is that what you were asking for? special cases for different kinds of colls?
11:45chouserI tried to word the docstring to keep that possibility open.
11:46chousera seq over a subvec, a split from a finger tree, whatever...
11:49chouserkotarak *is* spamming us.
11:49cgrandchouser: no, my remark on Counted was simple musing on my part, but yes I'd like take-last to return a lazy-seq and not force realization of its input -- like drop actually does
11:50cgrand,(class (drop 5 nil))
11:50clojurebotclojure.lang.LazySeq
11:50chousercgrand: how can it avoid realizing its input?
11:50chouserWithout Counted there's no way to know what the first item of the output seq should be until you've found the end of the input seq.
11:50cgrandsurround your take-last's body with lazy-seq
11:51chouseroh, delay all work until the first 'rest', then do all of it?
11:51rhickeyIs there a page yet for the Clojure in Action book?
11:52chouserrhickey: I saw a green paper, but I don't know of anything online yet.
11:52rhickeyI thought I saw a cover somewhere
11:53cgrandchouser: yeah, would be consistent with drop
11:53chouserthere was a cover shot in the green paper
11:53rhickeyah
11:53rhickeyso no link for the book yet
11:55chouserapparently not. can request the green paper: http://ow.ly/ufsr
11:57paoa totally uninformed question... would it be possible to have a persistent (on disk) data structure with the semantics already provided by clojure STM implementation?
12:00AWizzArdWhen I want to parallelize (doseq [[a b c] my-lazy-seq] ...), can I then in general do something nicer than (count (pmap (fn [[a b c]] ...) my-lazy-seq))?
12:00technomancythey always have the funniest-looking guys on them
12:02chouserwoman and a baby. does that mean something?
12:02Chousukehm
12:02Chousukewhy doesn't alter-var-root have a ! at the end? because it already has alter?
12:05rhickeyhttp://clojure.blogspot.com/2009/10/clojure-is-two.html
12:07rysHappy birthday!
12:07rottcoddpao: this might be of interest http://groups.google.com/group/clojure/browse_thread/thread/aa22a709501a64ac/b578f0915b55c4be?#b578f0915b55c4be
12:08AWizzArdtechnomancy: please look into your /msg'es
12:08paorottcodd: thanks... let me read...
12:10rysThat post just affirms I made the right choice when picking clojure to learn. I chose it primarily for the community around it. I'll find some cake!
12:10paorottcodd: I guess that stuff never ended in official repo...
12:22namorWhen I try to (compile 'hello), I get: java.io.IOException: No such file or directory (hello.clj:1). I'm started clj from the same directory, and if I do it from another dir, the error message changes.. any ideas?
12:22replacarhickey: congrats on Clojure's 2nd b-day!
12:24Raynesreplaca: I think it's Clojure's 3rd birthday.
12:24rhickeyreplaca: thanks!
12:25silkodysseyhappy birthday clojure!
12:25replacalet's see how it behaves in the terrible twos :-) Might see a lot of tantrums!
12:25Raynesrhickey: Is it Clojures 2nd or 3rd birthday?
12:26RaynesIf it's the second birthday, the Wikipedia page has been wrong for about 6 months now. :\
12:29rstehwienrhickey: Happy Birthday! I'm loving Clojure. Still wrapping my brain around my first Lisp and Functional language but it is a very fun ride.
12:29rhickeyRaynes: 2 years since first released
12:30RaynesOh, then yeah, the Wikipedia page has been wrong for a long time. :>
12:30Raynesrhickey: Happy Birthday to Clojure. :)
12:30rhickeythanks!
12:32namorHow would you compile a little script of clojure to a classfile? This compilation guide on clojure.org does not work apparently.
12:34steigerrhickey: ha ppy birrrth daaay tooo ... your son ? :) congratulations, man.
12:35steigernamor: how does that not work? use (:gen-class) with the options you like
12:35namorsteiger, if I try to (compile nsname), I get the error: java.io.IOException: No such file or directory (nsname.clj:1)
12:36namorsteiger, where nsname is the name of the namespace/file I try to compile.
12:36Chousukeis it in the classpath?
12:36steigernamor: did you start the Repl with the correct classpath?
12:36namorI started it from the directory of the file.
12:37namorAnd if I run it from another directory, the error message changes, so I suppose the classpath is correct.
12:37AWizzArdWhat does a "IllegalStateException: Var clojure.core/push-thread-bindings is unbound" mean? I have a (binding [...] ...) there.
12:37Chousukehmm
12:37steigernamor: usually it`s something like: java -cp path/to/clojure.jar:/directory/that/has/your/file clojure.main . that way, java will be able to `see` your file
12:37steigerhm
12:38ChousukeAWizzArd: push-thread-bindings is the new API used by the binding macro :/
12:38AWizzArdAh good, then I have an old clojure.jar on the server. Thanks.
12:39AWizzArdyup, problem solved :)
12:42somniumnamor: compiling to an executable .class file and executing a script with clojure.main are different, which are you trying to do?
13:36cemerickThe warmup time for the JIT is really painful in a thick-client setting. Has anyone tried clojure + gcj?
13:40chouserno but it sounds interesting.
13:40chousergcj can consume class files?
13:41cemericklast I knew -- jar file in, .so or .dll or .exe out
13:41cemerickit's probably more trouble than it's worth. I should just buckle down and write some kind of reasonable offscreen warmup process.
13:42technomancyhttp://justlooking.recursion.org/camping-xml-situps.png
13:44jevgeniHi guys. Just wondering - is there some kind of UML for functional languages? How can people communicate ideas to each other? (i.e. Oop langs use sequence diagrams and they naturally map to objects/classes/messages/etc)
13:45steigerUML sucks
13:46chousergenerally rhickey writes one or two very concise and somewhat cyrptic sentences. Then we all stare at them until enlightenment comes to us.
13:46cemericksteiger: a little harsh, no?
13:46chousermine too. sorry.
13:46steigercemerick: yeah, well, probably. sorry for that
13:47jevgenisteiger: I am not insisting on the uml as long as there is something I can use to explain the coding my friend/wife/cat :)
13:47cemerickjevgeni: not that I'm aware of. The units of interest are generally much smaller, so there's less of a need for formalisms. That said, some lingua franca in that area would be welcome.
13:47rhickeyprotocols will help organize things quite a bit, I think
13:48technomancythe non-ridiculous parts of UML are really not much more than that anyway.
13:48cemericktechnomancy: yeah, the problem is that everyone makes their pretty pictures differently.
13:49chouserjevgeni: we use class inheritence diagrams sometimes: http://tinyurl.com/clojure-classes
13:49chouserI suppose that's out of date again
13:49technomancyas long as everyone understands that a cylinder is a database and a cloud is a network, that's good enough for me. =)
13:50jevgenichouser: that's nice. thanks for showing it
13:51chouserHaskellers just define obscure unicode symbols as infix functions and then promptly drop straight into mathematical notation.
13:52rhickeyjevgeni: that diagram is broken down in these tutorial slides: http://clojure.googlegroups.com/web/tutorial.pdf
13:52jevgenirhickey: do you use omnigraffle for designing clojure programs as well?
13:53jevgenithx for link, I've not seen this tutorial yet
13:53rhickeyjevgeni: eventually there may be a video, but it was 5 hrs
13:56jevgeniI we take any typical use case, then it lays into declarative languages very well. is there any guidelines how to lay the story into FP languages?
13:57jevgenis/I/If
13:57cemerickjevgeni: most if not all of OOP is decidedly not declarative. Totally not an answer to your question, but it sounds like you're mixing up terminology in general.
13:58chouserjevgeni: I don't know that it's really so different. You'll still have bundles of related data and operations to perform on them.
13:59jevgenisorry, I meant imperative :)
13:59cemericknevermind, then :-)
13:59chouserPerhaps the main difference is the design needs to differentiate between values and identity. Other differences include: the operations don't generally live with the data (though they can), and the data is immutable.
14:05jevgeniCould you recommend me a book which can teach me how to design FP programs?
14:06jevgeniif there any..
14:06steigerjevgeni: how to design programs .
14:06steigerjevgeni: htdp.org -- it uses scheme, though
14:06steigerjevgeni: if you want something more hardcore, try structure and interpretation of computer programs
14:06jevgenisteiger: thanks!
14:07steigerjevgeni: you`re welcome. good luck with the book, it's very very good imo, if not the best on the subject
14:10technomancyso it looks like you cannot add your own metadata to test vars with deftest
14:11slyrus_where are queues described in the closure docs? I see them referred to in some of the API section, but don't see them in datastructures or sequences
14:11jevgenisicp is interesting, yes, but it is more about the math, rather than about designing some domain-specific solutions..
14:11technomancyright now I'm wrapping deftest with a macro, but it would be great if you could use regular deftest for that
14:11LauJensensicp is more about math?? :)
14:12jevgeniLauJensen: well, at least first chapter is full with math or I'm mixing up something:)
14:12technomancythat would allow categorizing tests by arbitrary metadata so you could have unit tests vs integration tests etc; and be able to run just your fast tests on their own
14:12LauJensenjevgeni, you're mixing it up my friend
14:12steigerjevgeni: sicp is hardcore in it's problem-solving. it`s for the real sharp mind (not my case). htdp focus more on the design of programs by working with more simple problems
14:12cemerickjevgeni: programming is applied math + logic, within some degree of approximation.
14:13csteinbachjevgeni: the first chapter of SICP is not at all representative of the rest of the book
14:13csteinbachjevgeni: skip to chapter 2 if your
14:13csteinbachjevgeni: not big on math
14:15steigercemerick: i'd say that in most of the time, logic is much more important than the other areas of math for coding
14:15cemerickyeah, it depends on what you're doing, of course
14:17technomancyivy fans: is it pretty easy to create a maven-style artifact that defines transitive dependencies using ivy?
14:17jevgeniI do mostly the integration of different systems, not so much math at all, I would say
14:25piccolinoHey guys, I'm trying to get a MacPort for clojure-contrib accepted. Is there any way we could do a release, or at least a 1.0 branch in github, so that it can pull a stable set of code?
14:26technomancypiccolino: you know about the 1.0-compatible branch, right?
14:26piccolinoYes, but the description seemed to indicate that that was going to have ongoing development, just development that is still compatible with 1.0.
14:26technomancyit has the occasional backport, but I think it's pretty stable.
14:27technomancyit's not technically a release, but I think it's pretty safe to treat it as such
14:27piccolinoOK, I'll try to convince them then.
14:27technomancyit's only had one commit since June
14:28technomancyand that was a bugfi
14:28technomancyx
14:28piccolinoYeah, I saw that. It's just hard to keep track of what exact code a given user has if the branch is changing.
14:29piccolinoIf the port says "This is 1.0," but the code can be different depending on when it's pulled, it might not pick up those bug fixes later, etc.
14:30technomancycontrib is kind of a "bucket o' stuff"... you just kind of have to roll with that.
14:32piccolinoYeah, unfortunately it also appears to be Clojure's standard library, since almost everythign I see on github depends on it.
14:33technomancyyeah, that wasn't the intention, but I think you really can't have a language as small as Clojure without a standard library... so that's what it's become.
14:35piccolinoYeah. I'd just like Clojure to be as easy to get rolling with as Scala, because right now, it's kind of a pain to get set up.
14:36technomancyit will improve as more people start to realize automated dependency management is necessary.
14:37piccolinoBut don't you have to start cutting releases for that?
14:37technomancyyou can use snapshots if you have push access to a server.
14:38froogtechnomancy: I wanted to ask if you could change/add lazy-seq to the clojure mode. right now 'lazy-cons' is mentioned twice.
14:38technomancyhah; really?
14:38technomancyI'll take it out; thanks
14:39froogtechnomancy: thanks, I was contemplating setting up my own git branch, but this is such an easy fix :)
14:39technomancyfroog: sure; pushing as we speak. =)
14:40piccolinoWhat does that mean? Snapshots? Aren't those releases?
14:40technomancypiccolino: snapshots are artifacts from between formal releases
14:40piccolinoRight.
14:40piccolinoFor what I'm talking about, even snapshots would be great.
14:41technomancyI guess you could call them ad-hoc releases
14:41piccolinoThey're a release in the sense of "some named version of the code that won't change again."
14:41technomancythat'll do the trick
14:41technomancyStuart Sierra has big plans for setting up a repo for this kind of thing.
14:42drewrI use an ad hoc ivy repo for that
14:42drewrhttp://ivy.draines.com/
14:43drewrif there's no official release then I create a signature based on the commit and date
14:43technomancyit'd be nice to have a community-maintained one; something like rubyforge
14:43technomancyI suspect this is what Stuart has in mind
14:43drewrclearly
14:43technomancyso each person doesn't need to maintain their own
14:44drewrjust saying that idea can be expanded to something community-wide
14:45piccolinoThat would be great.
14:46drewrwe're all going at it
14:46drewrhopefully the different vectors will converge at something awesome
14:47froogtechnomancy: got it, works great
14:48technomancymy only issue with Stuart's approach is that he thinks Maven's XML format is reasonable and expects clojure hackers to learn it, while I would rather have people write sexps.
14:48technomancybut I guess it's up to me then to make the wrapper work well. =)
14:49danlarkinwooo corkscrew!
14:49technomancyif only maven didn't have this crazy plexus dependency that would be easy. =)
14:51danlarkinyou're our only hope, techno-man kenobi
14:51technomancyhehe
14:54piccolinoHas this been discussed on a blog somewhere or anything like that?
15:02technomancydrewr: is it pretty easy to publish maven-compatible artifacts with ivy?
15:38KjellskiHi there =)
15:39chouserhello
15:40KjellskiI was just asking myself, is there a function already in clojure or clojure contrib, that can be used to ensure that all elements in a vector are continuous numbers? from the first on are just "inc"ed like: [ 24 25 26 27] => true and [ 2 3 5 ] => false
15:42chousernot that I know of, but should be simple enough to write.
15:42technomancy,(reduce #(and %1 (< %1 %2) %2) [1 2 3])
15:42clojurebot3
15:42cemerickI wonder: is anyone tracking the impact of changes in clojure.core on performance (on any level, microbenchmark or no)?
15:42Chousukeyou can try (= (take (count v) (iterate inc (first v))) v
15:42technomancy,(reduce #(and %1 (< %1 %2) %2) [1 2 1])
15:42clojurebotfalse
15:43Chousuke< is not enough
15:43Chousukeand you don't need to reduce, you can just apply it :)
15:43technomancytrue. and it's ugly. but it's close. =)
15:43Chousuke,(apply < [1 2 3])
15:43clojurebottrue
15:43KjellskiSure... but just thought I´m too stupid to find ^^
15:43Kjellskidamned... thats neat.... ^^ I´ll use the second version ^^
15:44Chousukeit doesn't do what you need though.
15:44KjellskiNo?
15:44technomancyoh, I missed the continuous part
15:44Chousuke,(apply < [1 2 4])
15:44clojurebottrue
15:44chouser,(every? (fn [[a b]] (== (inc a) b)) (partition 2 1 [4 5 5 7]))
15:44clojurebotfalse
15:45chousershort circuits, which reduce can't.
15:45serp_,(count 5)
15:45clojurebotjava.lang.UnsupportedOperationException: count not supported on this type: Integer
15:45Chousuke(let [v [1 2 3]] (= (take (count v) (iterate inc (first v))) v))
15:45Chousuke,(let [v [1 2 3]] (= (take (count v) (iterate inc (first v))) v))
15:45clojurebottrue
15:45KjellskiI see ... and try to understand ^^
15:46Chousukethe (take (count v) ... ) is a wart though. I wonder if there's any way to get rid of it.
15:46serp_,(take 5 (iterate inc 0))
15:46clojurebot(0 1 2 3 4)
15:46serp_,(take 5 (iterate #(+ %1 10) 0))
15:46clojurebot(0 10 20 30 40)
15:46serp_neat
15:47Chousuke(every? true? (map = (iterate inc 5) [5 6 7]))
15:47Chousukejeflkjsfdl
15:47Chousuke,(every? true? (map = (iterate inc 5) [5 6 7]))
15:47clojurebottrue
15:47serp_,(take 2 [1 2 3])
15:47clojurebot(1 2)
15:51KjellskiI just don´t get how this works... (let [v [1 2 3]] (= (take (count v) (iterate inc (first v))) v))
15:52chousercompares your original collection with a seq of the same length counting from its first value
15:53chousercould be (= v (range (first v) (+ (first v) (count v)))) if that makes more sense to you
15:54KjellskiGot it, thanks!
15:55KjellskiIs it right, that from the first false on, the second vectors next element wouldn´t be produced, due to its lazyness?
15:56Kjellski... in the iterate example...
15:57chouseryes
15:57Kjellskik, thanks.
15:58chouserhm
15:58chouserwell, that's what I would have thought...
15:58Kjellski^^, but?
15:59chouserstill looking, hang on. :-)
15:59Kjellskikk
16:00don333,(apply < [2 3 5])
16:00clojurebottrue
16:00chouserok, yes that's true, but it can be broken pretty subtly
16:01chousermade untrue I mean.
16:01chouser,(= '(1 2 3 4 5) (lazy-cat [1 9 9] (do (println "got here") [4 5])))
16:01clojurebotfalse
16:01chouser,(= [1 2 3 4 5] (lazy-cat [1 9 9] (do (println "got here") [4 5])))
16:01clojurebotgot here
16:02chouserbecause the iterate example had a lazy seq first (as returned by take), it will use lazy-seq's 'equiv' which is lazy.
16:04chouserbut if v had been first then it would depend on the type of v -- a vector being non-lazy starts of by comparing the sizes of the two args, which forces the whole lazy seq
16:04KjellskiOkay, so this your example, both of the vectors are only as long as the values continue to be true?
16:05KjellskiSorry for my english... seems to be wrong grammar... ^^
16:15chouserin my last two examples, on the second one was comparing a vector (= a-vector a-lazy-seq)
16:15chouserin that case the lazy-seq always gets forced
16:16KjellskiOkay. I need more practice ...
16:17Chousukechouser: that's somewhat surprising :/
16:17Chousuke,(= [1 2 3] (iterate inc 1))
16:17Chousukeboom :P
16:17clojurebotjava.lang.OutOfMemoryError: Java heap space
16:18Chousuke,(= (iterate inc 1) [1 2 3])
16:18clojurebotfalse
16:19Kjellski^^ with the order from Chousuke my heap explodes too ...
16:20KjellskiWhy?
16:21Chousukeapparently the .equals method for a vector forces its argument.
16:21Chousukebut the .equals method for a lazy seq doesn't.
16:21chouser.equiv, but yeah.
16:21Chousukeand if you force an infinite sequence... boom :P
16:21chouservectors compare size first, which is what you want if comparing two vectors
16:22ChousukeI think maybe it should have a check for this case.
16:22chouserI suppose it should ask it's arg if it's Counted first
16:22Chousukeit's not going to be too expensive. :)
16:23KjellskiI agree... ^^ ... at least for beginners like me :)
16:24kylesmith_cemerick: ping
16:24Chousukeit also makes it difficult to write code that may need to compare two arbitrary collections :P
16:24chouserrhickey: want a ticket for that?
16:27KjellskiSo, thanks again and cya again... I´m off =)
16:27cemerickkylesmith_: pong
16:31kylesmith_cemerick: if you're having problems with jvm warmup, you can try lowering -XX:CompileThreshold=10000
16:35cemerickkylesmith_: yeah, I saw that -- there's a lot of options around controlling the JIT, but I'm leery of messing around with them on a whim. Unintended consequences and all that. It definitely calls for some experimentation, though.
16:37chousercemerick: just write a little thing in C that throws up a splash screen while the jvm gets going.
16:39cemerickoh, we've got a splash screen we can hide behind if need be (we use the NetBeans RCP). I just hate the prospect of letting it sit there for ~30s while we warm things up.
16:39chouserwhoa
16:39chouseryeah
16:40chouserthat's too much for a splash screen.
16:40chouseryou need more of a mini-game
16:40cemerick30s is probably an exaggeration, but that's the highest I've seen the initial action take in the UI.
16:45slyrus_where's prog1??
16:45technomancyslyrus_: in the 1980s where it belongs. =)
16:45chouserwhat is that, (let [x y] .... x) ?
16:45slyrus_correct chouser
16:45chouserwhere .... is all side-effecty?
16:46slyrus_s/had/head/
16:46chouser:-)
16:47cemerickslyrus_: it's OK man, it's gonna be O–K. :-)
16:49slyrus_so, I've been trying to convert some of my lisp code to clojure. probably a bad idea, but, hey, gotta start somewhere. lots of side effects. i think i need to rewire my brain.
16:49slyrus_for example...
16:49lisppaste8slyrus pasted "non-clojurey clojure code" at http://paste.lisp.org/display/88766
16:50chouserheh. looks converted.
16:50Chousukeyeah :P
16:50chouserslyrus_: do you know about letfn?
16:50hiredmanpeople (not me) have 30 to 40 second OS boot speeds these days, so it's hard come to grips with the jvm taking a minute to start up
16:51Chousukeand the ref is overkill anyway. an atom would suffice, if you really want to do it like that
16:51chouserslyrus_: so you're making a local ref, using it to do some computation and then throwing it away?
16:51slyrus_chouser: yes, i just like the fact that i can use let for functions too
16:51slyrus_yep
16:51chouseryeah, don't do that. :-)
16:52Chousukeyou don't even need the nested let though, as far as I can tell :/
16:52Chousukeas far as I know you can refer to earlier bindings in it in later bindings.
16:53chouserIf you don't mind getting a bit off course, I highly recommend doing some projecteuler puzzles purely functionally
16:53chouserthey start simple and get tougher -- after a couple dozen problems you'll find your brain has been rewired for you.
16:54Chousukeand then you start forgetting that things aren't always immutable :(
16:54chouseryep
16:54slyrus_thanks chouser, will do
17:01lisppaste8slyrus annotated #88766 "v2" at http://paste.lisp.org/display/88766#1
17:02slyrus_looks like i need to find some time over the weekend for some puzzles...
17:02slyrus_thanks for the tips though. now back to work...
17:07neotykwhile working on one of projecteuler problems I improved contrib/math/lcm
17:08neotykwhat do I need to do to get http://github.com/neotyk/clojure-contrib/commit/b70d0c0fd16f6ea6b963fceb39b6d60f1ca55e95 in contrib?
17:08neotykI've already requested pull
17:08technomancyhave you read http://clojure.org/patches ?
17:09neotykkind off
17:10technomancyhttp://clojure.org/contributing also
17:10neotykit's really small change, signing CA and sending is 10 fold more effort than this patch
17:11technomancyaccording to some projects, (GNU in particular) patches under a certain size are not actually copyrightable, but I don't know Rich's stance on that.
18:10ol3`````x
18:12hiredmanclojurebot: ticket #151
18:12clojurebot{:url http://tinyurl.com/ygjd5zx, :summary "Function to return last n items of a seq", :status :fixed, :priority :normal, :created-on "2009-07-12T02:45:06+00:00"}
18:14durka42hiredman: how do you deal with "magically" updating clojurebot without having it disconnect?
18:15durka42is it just that you never change the actual onMessage function anymore?
18:16hiredmandurka42: yeah, I never touch that stuff
18:16hiredmanI pull it out of proxy and into normal function application as fast as possible
18:17durka42i see
18:17hiredmanand do any kind of abstraction stuff via functions
18:35kylesmithAre structs always faster than hashmaps? Structs are ~4% slower on my machine.
19:09dreishkylesmith: 4% slower at what?
19:11kylesmithit's a variation on constraint propagation.
19:11kylesmithso on each iteration, new candidates are being created, and other are being eliminated
19:12kylesmithI'm assuming the 4% is because the entire struct is being copied each time.
19:12dreishI think last time I microbenchmarked it, structs were more than twice as fast for creation than equivalent hash maps.
19:13dreishI think that was with 52 keys -- a-z + aa-zz.
19:13kylesmithI literally replaced a call to (hash-map ...) with (struct-map ...) and it was 4% slower.
19:14kylesmithmy keys are just integers
19:14dreishIf you can, use struct (without keys; vals must be in order) instead of struct-map.
19:15kylesmithwell, I only know one key/val initially. One key/val pair gets added on each iteration.
19:15dreishThat doesn't sound very struct-like.
19:16kylesmithit's not, but I wanted to benchmark it anyway.
19:17dreishWell, if you use a tool for something it wasn't intended for, it's probably not going to be very impressive.
19:18kylesmithstructs are just maps with shared keys, right?
19:19dreishA struct is implemented as a Java array, plus a Clojure hash of keys to integers. The integers are indices into the array.
19:19dreishThe key->int hash is created once and shared among all instances.
19:20dreishThat allows you to create new ones very quickly using the struct function, since it's just populating an array with your args, and copying the ref to the struct basis (the key->int hash).
19:21dreishAnd it also allows you to create marginally faster accessors, though hashes are already pretty hard to improve on for lookup performance.
19:21kylesmithI could probably try vectors, since my keys are already integers...
19:22dreishI was wondering whether I should ask whether they were consecutive integers ...
19:22kylesmithyeah, I can enforce them to be consecutive
19:41technomancy,(partition 2 [1 2 3])
19:41technomancyhe's deserted us!
19:41technomancyanyway, the return value is ((1 2))
19:41technomancywhich is strange
19:41technomancyI would expect it to be ((1 2) (3))
19:42technomancyI guess the docstring only specifies what happens to incomplete lists if a pad collection is supplied
19:46Chousuketechnomancy: that's the defined behaviour. you need to pad the sequence yourself
19:47technomancyChousuke: I understand, it's just surprising to me.
19:47technomancydidn't expect it to let elements just disappear
19:48Chousukeit makes sense though. you can ensure that you get items of exactly the required size.
19:49Chousukeand if you need to handle uneven sequences, you just add n-1 items as padding.
19:49technomancywhat I really want is "partition coll into n pieces", which partition almost gets me
19:50Chousuke,(doc partition-all)
19:50Chousukehm
19:50Chousukethat's in contrib, anyway
19:50technomancyI'll look in seq-utils; thanks
19:50technomancyah, perfect; thanks
20:16tomojis there anything like defvar in clojure?
20:17tomojbesides (declare foo) (if-not (.isBound #'foo) (def foo bar))
20:17technomancydefonce maybe?
20:17Chousukethere's something called defvar in contrib
20:17tomojdefonce looks right, thanks
20:18tomojI want it so I can recompile in slime without wiping out all my vars (possibly leaving a running jetty server which AFAIK I have no way to stop)
20:18technomancyit's nice how the clojure version is actually named after what it does, unlike CL. =)
20:19technomancytomoj: yeah, I use defonce all the time for that
20:19tomojyeah I always had to lookup which one was which in CL
20:22technomancyivy fans: is there a way to set the version in ivy.xml?
20:22technomancythe version of your project, that is... rather than of a dependency
20:26tomojtechnomancy: revision on the info tag, maybe?
20:28technomancytomoj: thanks!
20:29technomancydoesn't look like you can use revision="{version}" style replacement in there though. =\
20:29technomancybummer to have to hard-code it.
20:35tomojit looks like clojureql is not hardcoding it
20:36tomojI don't understand ant or ivy much at all yet, but it looks like the publish task dynamically grabs the version from a .properties file for ivy:publish
20:37technomancythis git repository took me 40 minutes to upload since it had so many jars in it!
20:38technomancyah, I had the interpolation syntax wrong
20:39somniumI still just use ant and a build.xml generator - hoping some compelling 'clojure-clouds' project emerges soon...
20:41technomancyexecutable XML is such a bad idea. =\
20:41tomojI was just going to say, I want something with no XML :)
20:41technomancytomoj: I've got a backburner project for that
20:41technomancyhttp://github.com/technomancy/corkscrew
20:41technomancyall sexp-based
20:41tomojwasn't there something in the clojure book like this?
20:41technomancydoesn't currently work since maven has some crazy classloader issues
20:41technomancytomoj: yeah, but that's just an ant clone
20:42technomancyand ant is an interpreter for an insane XML dialect
20:42technomancyso I fail to see the value
20:42technomancyI mean, other than as a teaching exercise
20:45somniumant's got variables, macros, and control constructs...
20:47technomancywhat more could you want? =)
20:47somniumis there a particular reason java doesn't have some tool called 'jake' instead of 3-major xml-dialects?
20:48somnium(if it had STM and first-class functions ant would almost be a poor man's clojure)
20:49tomoj"clojure" doesn't seem particularly friendly for naming projects :(
20:50tomoje.g. what would make/rake/jake be called for clojure?
20:50tomojclojake?
20:51Chousuke"cloak" :P
20:51somnium"jury"
20:52ambientsomething you can type fast
20:52ambientwith qwerty
20:52somniumI've got a couple macros immitating ruby's 'flay' tentatively titled 'perjure'
20:52somniumgonna run out of jure words soon
20:52Chousukefortunately.
20:52ambientoh, thee of little faith
20:52ambient:D
20:53Chousukethe puns are getting old
20:57tomojthe only ones I have in my words file are: abjure, conjure, injure, perjure
20:57somniumconjure's publicly taken
20:58tomojoh we can also take -sure words and use j instead, like compojure
20:58somniuminjure would be a cool name for a hostile-repl library
21:00tomojthat gives: expojure, leijure, meajure, pleajure, treajure
21:00hiredman:(
21:00somniumliejure looks norwegian to me
21:00hiredmanclojurebot: Xiphojure?
21:00clojurebotTitim gan éirí ort.
21:01somniumplenty of cl-words, maybe that'll be the new trend
21:01tomojbut cl looks like common lisp
21:01hiredmanclojurebot: Xiphojura?
21:01clojurebot2009:Jan:29:16:03:17 <hiredman> I call Xiphojura
21:02somniumclobber, clogs, clint eastwood... there's some potential
21:03tomojI've just been doing xxxx-clj
21:03LuytI'm a big fan of Clint's films
21:03LuytEspecially some westerns
21:03ambientyou could try other languages, i dont know any french but bonjour sounds a lot like bonjure to me
21:03somniumclojure-du-jour
21:04Luytplat-du-jour!
21:04Luyt"Joe Kidd" is one of Clint's greatest films
21:05somniumI liked Dirty Harry
21:05somniumIf we could get him as an evangelist, he could do webcasts called "Clint on Clojure"
21:06tomojlooks like "klojur" means something like "local seriousness" in lojban
22:31aldebrnGreetings friends. I have downloaded jline-0.9.94 and clojure-1.0.0 and am attempting to run "java -cp jline-0.9.94.jar:clojure-1.0.0.jar jline.ConsoleRunner clojure.lang.Repl" but Java complainx that it can't find a class "jline/ConsoleRunner"?
22:32scottjos? I'm not sure if windows has a different syntax for classpath, maybe ; instead of :
22:33aldebrnAha, WinXp
22:33aldebrnTrying it on my laptop instead of workstation at work
22:35aldebrnAh, I attempted ; instead of : in Cygwin xterm, didn't work, but works in Windows cmd! Thanks scottj
23:10j3ff86hey i got a question. (take n [collection]) returns the first n indexes from a collection, is there a function similar to take that lets you choose what indexes you want to take from?
23:22tomojI don't know of one, but you can combine drop and take
23:22j3ff86haha thats exactly what im doing
23:23tomojfor vectors there is subvec
23:24j3ff86ooh yeah
23:24tomojand subvec says it's O(1)
23:26j3ff86that works better, thanks
23:41dmiller7Is there an easy way to determine all the :use & :require dependencies in clojure-contrib?
23:50technomancydmiller7: http://github.com/hiredman/clojure-dependency-grapher maybe?
23:52dmiller7technomancy: Looks like what the doctor ordered. Taking two aspirin. Will call in the morning.
23:52dmiller7technomancy: thanks.
23:55technomancythank hiredman. =)