#clojure logs

2009-11-02

01:24nipraHow can I get "First Line.\nSecond Line." to be printed as two separate lines in REPL?
01:25wahjavanipra, (println "First Line.\nSecond Line.") ??
01:27niprawahjava, thanks a lot :-)
01:27wahjavayou're welcome, nipra .
06:00gerry`hello
06:00ordnungswidrighi
06:00gerry`in clojure, when to use "_", any docs about it?
06:00ordnungswidrigwhen you don't care about the binding
06:01gerry`,(def a [1 2 3])
06:01clojurebotDENIED
06:01gerry`,(let [a [1 2 3]]
06:01clojurebotEOF while reading
06:02ordnungswidrigIf you define (defn foo [x _] x) foo must be called with 2 args but as you don't care about the second one, name it _
06:02gerry`,(let [a [1 2 3]] (case a [1 _ 3] "ok" "oops"))
06:02clojurebotjava.lang.Exception: Unable to resolve symbol: case in this context
06:02gerry`,(doc deftype)
06:02clojurebot"clojure.contrib.types/deftype;[[type-tag constructor-name docstring? attr-map?] [type-tag constructor-name docstring? attr-map? constructor] [type-tag constructor-name docstring? attr-map? constructor deconstructor]]; Define a data type by a type tag (a namespace-qualified keyword) and a symbol naming the constructor function. Optionally, a constructor and a deconstructor function can be given as well, the defaults being
06:04gerry`case not support "_"?
06:04hiredman_ is not special
06:04opqdonut_ is just an identifier
06:04gerry`and?
06:04opqdonutyou could use, for instance, "unused" instead of it
06:04hiredman,(let [_ 1] _)
06:04clojurebot1
06:04hiredmanyou don't have to "support" it
06:05hiredmanit's just a convention
06:05gerry`,[1 _ 2]
06:05clojurebotjava.lang.Exception: Unable to resolve symbol: _ in this context
06:05hiredman,[1 x 2]
06:05clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
06:06gerry`,(defn hello [_] (println "hello"))
06:06clojurebotDENIED
06:09gerry`,(let [a (fn [_] (println "hello"))] (a "ok"))
06:09clojurebothello
06:11gerry`hiredman: any wild character in clojure just like _ in prolog?
06:11gerry`[1 _ 3] could match [1 "ok" 3] [1 "anything 3] etc?
06:12hiredmanclojure doesn't do pattern matching
06:13hiredmanthere are at least two macros floating around that implement pattern matching, but it is built into the language
06:14hiredmaner
06:14hiredmannot built into the language
06:14gerry`which?
06:15hiredmanwhich macros?
06:15gerry`yes
06:15hiredmanthere is one in contrib
06:15hiredman,(doc contrib)
06:15clojurebotGabh mo leithscéal?
06:15hiredmaner
06:15hiredman,(doc match)
06:15clojurebot"clojure.contrib.types/match;[[value & clauses]]; Given a value and a list of template-expr clauses, evaluate the first expr whose template matches the value. There are four kinds of templates: 1) Lists of the form (tag x1 x2 ...) match instances of types whose constructor has the same form as the list. 2) Quoted lists of the form '(x1 x2 ...) match lists of the same length. 3) Vectors of the form [x1 x2 ...] match vector
06:16hiredman~google clojure pattern matching
06:16clojurebotFirst, out of 1560 results is:
06:16clojurebotbrool » Pattern Matching In Clojure
06:16clojurebothttp://www.brool.com/index.php/pattern-matching-in-clojure
06:17gerry`i think case should support pattern match
06:18hiredmanI think Kings was an cool show and NBC made a bad movie canceling it
06:18gerry`just like "match" in scala, "case" in haskell
06:19gerry`hmm
06:21hiredmangerry`: http://clojure-log.n01se.net/date/2008-10-09.html#13:32
06:22gerry`ok,thx
08:08meganechouser: i think shell-out/sh is leaking file handles
08:08meganehere's the reason http://dlinsin.blogspot.com/2007/02/javas-runtimeexec-openes-too-many-files.html
08:11lisppaste8megane pasted "shell-out/sh" at http://paste.lisp.org/display/89677
08:12patricius_i'm wondering, could a web server be written in clojure with the same kind of throughput that yaws, the Erlang-webserver, exhibits?
08:12patricius_i'm trying to grasp the differences in terms of scheduling processes/threads
08:12meganethat's my try at fixing sh
08:12ambienti wonder how easy it is to understand my project later when most of the stuff is just macroes upon macroes :p
08:13hiredmanin some sense that is the measure of a macro
08:13ambientquess i have to crank up the documentation
08:13chousermegane: huh. I could have sworn I was carefully closing all the streams. :-P
08:13chousermegane: have you signed the CA?
08:24ordnungswidrigambient: you mean "macros all the way down"? :-) en.wikipedia.org/wiki/Turtles_all_the_way_down
08:25ambientwell, not all the way. just a lot of macros calling other macros calling other macros
08:29ambientit's actually constructing a whole sub-program... :|
08:29ambientdefined by given parameters
08:29ambientoh wait... i think that's the definition of a macro
08:44_atopatricius_: Clojure doesn't have lightweight threads (aka green threads) etc that I assume Erlang's processes are
08:45_atopatricius_: but you could certainly write a high-performance web server by using non-blocking sockets, select() and a thread pool
08:49meganechouser: CA? what's that
08:49chouserClojure's agents are not entirely unlike green threads
08:50meganeah.. contributor agreement.. no i haven't
08:52_atochouser: true, though I assume in Erlang you can spawn a few thousand processes and have all of them block simulataneously on read() cheaply (which is probably implemented under the hood using select). You couldn't do that with agents as you'd use up the thread pool or create a few thousand OS threads (which would be bad)
08:52chouser_ato: true
08:53chouserwelll, true that that's how Clojure behaves and that it would be bad for thousands of sockets. I don't know if it's ok in Erlang or not.
08:53meganechouser: you'll have to fix it yourself :P
08:53chousermegane: np
08:54AWizzArdAlthough Jetty for example can handle a few thousand threads concurrently.
08:55AWizzArdAnd in the past I think Java had green threads and then switched to OS threads.
08:55_atohttp://docs.codehaus.org/display/JETTY/Continuations
08:55_atohuh
08:55_atointeresting
08:56_atoit "suspends" a thread by throwing an exception and retries later
08:59cemerickis anyone writing web servers anymore? ;-)
09:01_atobut yeah, from a performance stand-point select and a thread pool (like what jetty does) is going to be just as good as whatever erlang does, because that's how erlang will be implented underneath. The only advantage with erlang is you don't have to be as explicit with state, you can use the call stack as your state
09:01ambientthis can't be abstacted with macro-fu?
09:02_atoyou could probably come up with something good enough, I think you'd need continuations to do it really nicely
09:05cemerickheh, if that were the case, apache would've been written in scheme
09:06cemerickor lighty, or nginx, or...
09:07_atofor most HTTP stuff it doesn't matter as most HTTP is stateless
09:08cemerickoh, so we're talking about a seaside-esque thing?
09:08_atoyeah
09:09cemerickI remember enjoying working with webobjects, which had great transparent session management -- totally resumable, stateless as far as the developer was concerned, etc.
09:09AWizzArdBtw, when I want to read from an input stream there is the .available method that tells me how much i can read without blocking. Is there a way to have my thread sleeping for N msecs OR until some more data is available?
09:10_atoI have horrid memories of WebObjects, a major app at work is written in it and WO is buggy as hell. But yeah the continuations stuff is neat
09:11cemerickThat's very surprising to hear. It was rock-solid when I used it.
09:11_atoAWizzArd: yes, but it's annoying. http://java.sun.com/j2se/1.4.2/docs/api/java/nio/channels/Selector.html
09:11_atocemerick: could be cause we're running on Solaris
09:11_atoactually WO itself is mostly okay, it's mainly the database layer EnterpriseObjects or whatever it is that we had trouble with
09:12_atothings like if you loop through a list of EO objects with a java for-each style loop half of the objects are null, where if you do a for (i=0; i<10; i++) {} style thing it works fine
09:12cemerick_ato: heh -- that's actually the piece of WO that is most widely acknowledged as being very innovative. Really set the bar w.r.t. ORM.
09:21_atoyeah, on paper it's great, but we just ran into lots of implementation problems. Like I said though, we're running on Solaris inside Tomcat which is not really what it's designed for and it's huge (poorly designed) app with a insanely complicated database schema. (I work at a library and boy do libraries love overcomplicated data schemas)
09:25AWizzArd_ato: oh :(
09:25AWizzArdCan you give one or two short examples of where Tomcat is not doing what it was designed for?
09:27_atoAWizzArd: sorry that wasn't clear, I mean WebObjects isn't designed to run in Tomcat on Solaris. It's supposed to run on OS X server... and I don't think it normally runs in a container
09:36_atotomcat is fine
09:36_atowell mostly fine, it has some weirdnesses but mostly they're due to JVM limitations
09:44cemerickTomcat is pretty darn solid. Holds its own against just about any other servlet container for 95% of use cases.
09:51cemerickanyone pay github for private git hosting, and want to share experiences?
09:56AWizzArdWhat is a good way to follow the flow of (or debugging support for) my app? contrib.logging?
09:56chouserI think there is at least once "trace" lib around
09:58raekhas there been any effort to make DWIM-like things for clojure?
09:59raekand another question: are the original s-expressions kept when code is compiled?
10:02chouserraek: 1) I don't know what you mean. 2) no.
10:08ambienti have a java callback function that i need to create with clojure. how do i enforce the types that are used to call that function?
10:08ambientlike "int javafunc(float[] foo, int bar)"
10:09ambient(fn [#^floats foo ??? bar] 0) is my best idea so far
10:10cemerickambient: type hints do not enforce types, they provide a way to avoid reflection
10:11ambientok
10:11cemerickif you need to provide a typed API to some Java code, you should proxy or gen-class an interface
10:24AWizzArdWho of you used clojure.contrib.logging? I would like to know where the log output is landing, and how I can turn logging of.
10:48AWizzArdDoes contrib have a without-exception macro, which returns nil in case of an exception? (try (some-operations-here) (catch Exception e nil))
10:53dakroneAWizzArd: (defmacro trycatch [f] `(try ~f (catch Exception e#))) ?
11:10stuartsierra,(binding [+ -] (+ 1 1))
11:10clojurebot2
11:10stuartsierraWhy doesn't that work?
11:11rhickey+ has inlining
11:11stuartsierraah, ok
11:11stuartsierra,(binding [mod -] (mod 1 1))
11:11clojurebot0
11:12danlarkinbad example :)
11:22arsatikiI just finished Halloway's book. Time to pass it around
11:23blackdog_stuartsierra, I'm having issues with http.agent, it doesn't seem like it's blocking, on a simple get, with one request relying on another to finish
11:23AWizzArdblackdog_: you mean (string (http-agent ...)) yes?
11:23blackdog_yes
11:23AWizzArdI noticed the same phenomenon.
11:23blackdog_i've just replaced httpagent with apache httpclient and my code and server are both good
11:24blackdog_ok, as long as I'm not alone, I'll send some details to the list later
11:24AWizzArdAnd that's really strange, because string under the hood calls result which uses await to finish.
11:24AWizzArdBut it is important that there must be some delay until await gets called.
11:24blackdog_i get a connection not closed error
11:24AWizzArdyes
11:25blackdog_when it tries to set the options for the next connection
11:25AWizzArdbut if you (let [a (http-agent ...)] (Thread/sleep 1000) (string a)) then it would work
11:25blackdog_like it didn't disconnect,
11:25AWizzArdor even better use (await-for a 1000) instead of Thread/sleep
11:25blackdog_yes, if I wait at the repl and reissue, it's all good
11:26blackdog_that's scalable ;)
11:26AWizzArdMaybe stuartsierra has an idea why this explicit await-for is needed.
11:29churibis there a fn like "some" which returns the first element for which pred is true?
11:30stuartsierraThis was reported on the list; there's a patch, working on it now
11:30rhickey,(first (filter odd? (range 1000000000000)))
11:30clojurebotjava.lang.ExceptionInInitializerError
11:31blackdog_stuartsierra, ok, thanks
11:31rhickey,(first (filter odd? (range 1000000)))
11:31clojurebot1
11:31churibthanks!
11:31rhickeychurib: leverages the fact that filter is lazy
11:32churibyeah, easy solution - i was to blind to see it :)
11:38spuzrhickey: do I need to sign the CA to raise issues in clojure or clojure contrib?
11:39rhickeyspuz: no, you can use the Support tab there
11:42spuzah not sure how i missed that
11:43stuartsierrablackdog_: should be fixed on master now
11:47AWizzArdstuartsierra: sounds good, thx
11:48spuzstuartsierra: you applied the patch?
11:48spuz(this is alex by the way)
11:48rhickeystuartsierra: thanks for fix to http://www.assembla.com/spaces/clojure-contrib/tickets/41
11:51stuartsierrawelcome
11:51stuartsierraspuz: no, I fixed it a different way
11:52spuzcool
11:52spuzYou got a good number of tickets closed today :)
11:53stuartsierrayeah, working my way through
11:55stuartsierrarhickey: when a core patch is ready, should I assign it to you or just mark it "Ready to Test"?
11:56rhickeystuartsierra: just mark as ready to test, thanks
12:24KjellskiHi there...
12:29replacaKjellski: hi
12:29Kjellskireplaca : hiho =)
12:30KjellskiAnyone got the enclujure shortcut for switching to repl and back in mind?
12:32Kjellski,(doc loop)
12:32clojurebot"([bindings & body]); Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein. Acts as a recur target."
12:37cemerickKjellski: Cmd-T on mac, probably Alt-T on windows.
12:39Kjellskicemerick : thanks!
12:40Kjellskicemerick : it was C-t but the hint did the trick =)
12:40cemerickThe mapping between Cmd and Alt/Ctrl is tough to nail down in general.
12:43KjellskiSure it is... do you have a Enclojure Cheat Sheet? I´m actually switching from emacs and on the homepage they just wrote look at the context menus...
12:43blackdog_stuartsierra, thanks, http-agent working as advertised
12:45cemerickKjellski: if you open the netbeans preferences dialog, and go into the keybindings section, you can look at just the clojure bindings
12:46Kjellskicemerick, something I could have done... sorry, a bit frightened from the emacs options "menu" ...
12:46cemerickKjellski: you're in a much more hospitable land now :-)
12:48Kjellskicemerick : *laughing*
12:48cemerickI'm surprised there's no one around to yell at me for my emacs trolling. :-P
12:49Kjellski*g* thought so too...
12:50KjellskiHow can I get the key-value pairs out of a map?
12:50cemerick,(seq {:a :b :c 5})
12:50clojurebot([:a :b] [:c 5])
12:50KjellskiOutch... thanks again...
12:52replacabut maps can be used directly as seqs in most cases, so you usually don't need the (seq ...)
12:52Kjellskicemerick: and anotherone for you, how can I force enclojure to just indent when it´s neccessary? like tabbing in a new line will not add tabs when it is already indented the right way?
12:53tomojreplaca: what is an example of a case where they can't?
12:53cemerickright, most forms wrap inputs in an implicit seq
12:54cemerickKjellski: hitting return will put the new line in the right place. 'Tab' is not 'reformat' like it is in emacs. Try Ctrl-R.
12:54Kjellskicemerick : now its M-r ... weird... ^^
12:55cemerickSee what I mean? :-)
12:57Kjellskicemerick : yes, pretty annoying
12:58cemerickit's worth filing a bug over. In the meantime, you can just rebind things to what you want.
12:59Kjellskicemerick : okay, so I´ll do that if it comes up again...
13:01Kjellskicemerick: Actually rebinding Reindent Clojure Code to TAB works just fine =)
13:01cemerickha. I never tried it. I've almost forgotten that that key is there.
13:01Kjellskicemerick : exactly what I wanted.
13:02Kjellskicemerick : it just sais "not recommended"... but it´s heaven... =)
13:04replacatomoj: I can't think of one
13:05chouser,(nil? (seq {}))
13:05clojurebottrue
13:05chouser,(nil? {})
13:05clojurebotfalse
13:27replacachouser always knows the subtlety!
13:27replacachouser: I'm really looking forward to your book - I was happy to hear you're doing it
13:28Kjellskireplaca : how is it called?
13:29chouserreplaca: thanks, that's great to hear!
13:30replacachouser: remind Kjellski of the title. It's in my mind as "Idiomatic Clojure"
13:30replacawhich translates to "Chouser" in my dictionary
13:31chouserthat's the working title, but it has it's detractors so we'll see. :-)
13:31Kjellskireplaca : *laughing*
13:31cemericka clojure book by chouser? Where do I buy? :-D
13:31Kjellski./signed
13:31chouseraw, you guys. It's actually Fogus' book, I'm just helping.
13:31KjellskiCan we see drafts or is it closed till release?
13:32cemerickchouser: First I've heard of it. Is there an announcement somewhere? (It's been a very busy morning.)
13:32cemerickuh, day.
13:32chouserNobody's even supposed to know about it yet, but I guess it leaked. :-)
13:33Kjellskichouser : somewhere, somehow...
13:33chouserThere will be a MEAP which is what Manning calls their on-line pre-release PDF thing
13:33chouserbut we're not quite there yet. Once there's a page for it, we'll make sure everyone knows. -)
13:33chouser:-)
13:33Kjellskichouser: I´m very interested... can I just subscribe somewhere?
13:34Kjellskichouser : okay.
13:34chousereither fogus or my twitter, or either of our blogs I imagine.
13:34chouser...for any announcements.
13:35cemerickchouser: well, at least you know there's a pile of interest. I'm sure everyone here will blog about it. It's about time someone banked some coin for irc time. :-)
13:35chouserheh. Right, I've been doing research for it right here for the last almost two years.
13:37fogus_My ears are burning ;)
13:37cemerickwhoa, #clojure has a strong echo
13:37cemerickfogus_: congrats :-)
13:38fogus_Thanks sir
13:38Kjellski*laughing* that´s what came in my mind... nice timing fogus...
13:39fogus_I was warned by chouser that I was getting slammed in here. ;)
13:40cemerickchouser: quick, trunc those logs, eh?
13:40chouserheh
13:40hamzahey guys, i have a vector of bytes [115 116 114] how can i build a string out of this? convert each byte to char then append?
13:41chouser,(apply str (map char [115 116 114]))
13:41clojurebot"str"
13:42chouser,(->> [115 116 114] (map char) (apply str))
13:42clojurebot"str"
13:42leafwwhat is ->> ?
13:42leafw,(doc ->>)
13:42clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last 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 last item in second form, etc."
13:42chouserjust what I showed there -- allows rearranging a set of nested forms.
13:44hamzathx, that worked which namespace is ->> defined ?
13:44tomojclojure.core
13:45hamzathank you, i guess my build is out of date..
13:45leafwwould be nice to have a fn like 'doc' or 'class' that lists the complete namespace and source package of a fn.
13:45Kjellskichouser can I ask for your blog?
13:46chouserKjellski: http://blog.n01se.net/ -- I actually share it with some friends, but everything they post is at least as interesting as what I do. :-)
13:50Kjellskichouser : thanks, that´s in my reader now... =)
13:50chouserKjellski: thanks! No worries -- you won't be overwhelmed with posts...
13:50chouserWhat little effort I put into blogging now goes into the book instead. :-P
13:51chouserplus some, I should say.
13:51KjellskiActually I can see a ")); at the very bottom of the blog... just my first feedback before reading ... ;)
13:52Kjellskichouser : Okay, that´s nice... I´ll wait for it...
13:57Kjellskichouser : can you see that too?
13:57tomojI can
13:57chouseryeah, thanks.
14:00KjellskiOkay, nevermind... first thought that was a bit hard as a first feedback ^^
14:01chouserno, not at all. working on it.
14:01chouserbut I hardly understand this blog software. so difficult. so much PHP
14:02chouserhuh. I think I broke it.
14:03KjellskiI think so too...
14:04KjellskiSo, sorry about killing you blog with my suggestions... but I have to leave... happy php'ing ... ;)
14:04chouserheh. ok, bye.
14:04Kjellskibye
14:15technomancychouser: just make sure the book doesn't end up with the title "Programming Clojure" =)
14:15chousertechnomancy: heh. got it.
14:17fogus_technomancy: Is that one taken? ;)
14:17ChousukeI had to code some Qt today in C++ and the machine I coded on was kind of slow so each compilation took at least a minute ;/
14:17technomancyfogus_: we don't want Clojure to be seen as just a copycat of Scala you know...
14:17Chousukemade me wish C++ were a dynamic language.
14:18hiredmanChousuke: that's not bad for C++
14:18Chousukehiredman: mind you, it's not a big application.
14:18fogus_technomancy: I guess that doesn't bode well for my planned chapter "Adding a Type System to Clojure"
14:18hiredmanwhile I was working on my reader I routinely rebuilt clojure over and over, which when I was on my netbook sometimes took five minutes
14:19fogus_(just kidding BTW)
14:19Chousukeit wasn't really fun to have to wait for a minute after you make some quick ten second edit and check that it works ;P
14:20cemerickdeveloping on a netbook? ouch.
14:20chouser"How to work around Clojure deficiencies: immutability and dynamic typing"
14:20hiredmanD:
14:20hiredmandeficiencies?
14:20chouserthat's chapter 2!
14:21chouserit includes macros that let you have mutable locals: mlet
14:21clojurebotHoly Crap.
14:21hiredmanI use my netbook a lot
14:22tomojI develop on my netbook almost all of the time
14:22Chousukechouser: are you really going to call them deficiencies? :P
14:23hiredmanit's just so easy, the computer is so small and it's right there, and you're just going to do some exploritory coding *500 lines of code later* huh, I guess I'm done
14:24chouserChapter 4 is entirely devoted to a reader patch that allows you to use C++ syntax to generate Clojure so you never have to look at parens.
14:25hiredmanhttp://gist.github.com/223246 <-- :P
14:25tomojI can't bring my imac out onto the patio while I smoke
14:26Chousukehiredman: argh.
14:27chouserok, just so it's clear I was kidding about every bit of book content info above.
14:28hiredmancc is a macro that, at macro expansion time, generates a .c file and compiles it, then returns a fn that when executed executes the native binary
14:31hiredmansort of a prototype, ideally you'd want to generate a shared library, not an executable, and have the macro return a fn that calls functions from the shared lib via jni or jna or something
14:47chouserfor anyone that cares, my blog is un-broken again. :-P
15:02djorkhttp://www.jwz.org/doc/java.html <-- Clojure sure goes a long way towards addressing these complaints
15:03hiredmanI finished coders at work this morning
15:04gyomnice
15:04hiredmandjork: it's also at least ten years old
15:04gyomhiredman : they all rant against C++, or almost all of them
15:04hiredmangyom: and the last few against C
15:04gyomhiredman : but I'm halfway through
15:05djorkits ten years old but Java hasn't fixed much of it in that time
15:05gyomI read an older book, something like "Programmers at work", and I thought the interviewer was doing a better job
15:05hiredmandjork: generally there are two classes of complaints against java, jvm issues and The Java™ Programing Language
15:06djorkthe JVM is much much better, that's for sure
15:06gyomin Coders at work it seems like the interviewer jumps back to the literate programming thing when it's not that relevant
15:07hiredmangyom: well it's interesting that taocp is mentioned in every interview, but no one uses Knuth's literate style
15:07chouserdjork: clojure also doubles-down on some of those (like interfaces)
15:07djorkyeah
15:08gyomhiredman : Yes, they all have a copy of taocp, all they all discuss whether math is relevant or not.
15:09hiredmanyou need a certain bit of math just to be able to use taocp as a reference
15:10gyomsure, you need math to understand why log(n) is O(n^{1+epsilon}), at least
15:10gyomhum
15:10gyomn log n, that is
15:11hiredmanthe bibliography of coders at work shall be mined for material
15:11hiredmanthere were some nice quotes here and there too
15:11hiredman~programmer
15:11clojurebot"There has to be something a little wrong with you for you to be a really good programmer." -- L Peter Deutsch
15:13hiredmanthere is another one about programmers being the worst optimizers
15:52tmountainone more reason to love clojure
15:54chouserI live by doc/source/show and occasionally javadoc
15:55hiredmanjavadoc javadoc javadoc
15:55frooghas there been any discussion about docstring format, something like doclet?
15:56hiredmanjavadocs are so great
15:59hiredmanI'm not
16:00chouserhm... still sounds like sarcasm. :-)
16:00hiredman~hiredman
16:00clojurebothiredman is an evil genius.
16:07cemerickone of these days, I'm going to have to bite the bullet and put together a javadoc generator for clojure projects.
16:08hiredman*huge list of IFn's that take Objects*
16:09cemerickhaving defclass around should make it somewhat easier to do, actually
16:11technomancyI'd have a lot happier time with javadoc if it didn't use frames for everything
16:12technomancymakes mouseless browsing trickier
16:12hiredman*shrug*
16:12technomancybut I find that usually the slime inspector is a much more convenient alternative ... need to get a blog post up about that.
16:12tomojdoes the slime inspector show javadoc comments?
16:13froogtechnomancy: that's more a result of how the javadoc was generated, isn't it?
16:13technomancytomoj: no, but usually javadoc comments are stuff like getFoos: gets all the foos from the object.
16:13hiredmanhyperlinked autogenerated docs are genius
16:13technomancyso you're usually not missing much
16:13tomojyeah
16:13hiredmanhttp://www.igniterealtime.org/builds/smack/docs/latest/javadoc/
16:13technomancythere are exceptions, but that's the common case
16:14technomancyfroog: there are nicer templates, but they are not often used. I guess I could generate my own.
16:15hiredmanclojuredoc should generate some kind of wikifiable information
16:15froogtechnomancy: I meant that you can generate the doc with another doclet, like texidoclet, if it was up-to-date
16:15froogthen you could generate info files from there
16:16technomancyfroog: yeah, having a copy of the source checkout can be a hassle at times. but if you have it and the docs are good, that's probably the way to go.
16:16chouserI use 'show' until I need a more meaningful javadoc comment like "make sure you always call foo before bar"
16:16technomancyyeah... slime inspector is like a hyperlinked version of repl-utils/show
16:16froogtechnomancy: true, you need the source for that
17:06ordnungswidrighi all
17:07djorkhi!
17:07djorkmy friend wants to start learning programming tonight
17:07djorkI want to teach him Clojure
17:07djorkbut...
17:07djorkthe Java part might be a problem
17:07ordnungswidrigdjork: could be a magic night then
17:08hiredmanteach him lua by writing a lisp interpreter in lua
17:08ordnungswidrigdjork: or start with the lambda calculus. a solid theoretical founding cannot be wrong ;-)
17:08ordnungswidrigdjork: so why do you think the java part is a problem?
17:09djorkLua might be good
17:09djorkJava is troubling because he has no OO experience
17:09djorkno programming at all in fact, just web markup
17:10jasappwhat's wrong with clojure?
17:10ordnungswidrigdjork: I see, clojures stack traces must be frightning to him them
17:11jasappscheme, drscheme in particular, is great for that sort of thing
17:11djorkyeah the stack traces might be rough
17:13djorkDrScheme could be good
17:13ordnungswidrigbtw. is there a plan to improve the stack traces anyway?
17:13hiredmanordnungswidrig: maybe after or as part of cinc
17:13ordnungswidrigcinc?
17:13hiredmanclojure in clojure
17:14ordnungswidrigturtles all the way down, again :-)
17:14hiredmanlua is a neat little language, a simple lisp would be, maybe a few hundred lines
17:15ordnungswidrigslime masters available? how to I "slimify" a buffer after connecting to a running swank using slime-connect?
17:15technomancyM-x slime-mode
17:15technomancybut that should happen automatically for you
17:16technomancyyou should launch slime using M-x slime rather than M-x slime-connect btw
17:16ordnungswidrigtechnomancy: I start swank by maven
17:16ordnungswidrigtechnomancy: To avoid all kinds of classpath issues
17:17technomancyoh gotcha. it still should activate slime-mode for you though. wonder what's going on.
17:17ordnungswidrigM-x slime-mode enables slime[clojure] but the keybindings are missing...
17:17ordnungswidrigtechnomancy: maybe it's a slime-swank-emacs-version isssue. using slime 2009-05-17
17:18ordnungswidrigshould I switch to the epla branch?
17:20technomancyactually the "maven" branch is the current release candidate
17:21technomancycheck the swank-clojure mailing list, I haven't updated the docs in the project yet.
17:21ordnungswidrighuh, I don't see this one on github
17:25djorkoh hey, nice clojure cheatsheet for http://cheat.errtheblog.com/
17:26djorkhmm, not the best ever
17:31ordnungswidrighmm, string contains in clojure? Only via java or is there an idiomatic way?
17:35tomojI think there are generally not clojure wrappers for things that are very easy to do with java
17:36ordnungswidrigwhich makes sense in a way
17:38dnolen,(re-find #"e" "Hello")
17:38clojurebot"e"
17:38dnolenordnungswidri ^
17:38ordnungswidrig*g*
17:41technomancythey would make such great predicates
17:42ordnungswidrigtechnomancy: can't you macro it?
17:42dnolenordnungwidri: technomancy means something like (#"e" "Hello") -> "e", can't macro that.
17:43technomancyin a turing-tarpit kind of sense such a thing might be technically possible, but not practically.
17:43hiredmantechnomancy: fnparse :D
17:43spuzHow does one retrieve input from the stdin or repl?
17:44hiredman*in* is boundg to System.in by default
17:47hiredman,(hiredman.clojurebot.factoids/predicate-style-definition {:remainder "foos | are | great"})
17:47clojurebothiredman: Pardon?
17:47hiredmanclojurebot: jerk
17:47clojurebotexcusez-moi
17:48hiredman,(predicate-style-definition {:remainder "foos | are | great"})
17:48clojurebot[{:subject "foos", :object "great", :predicate "are"} {:remainder nil}]
17:48hiredman,^(first (predicate-style-definition {:remainder "foos | are | great"}))
17:48clojurebot{:type :predicate-style-definition}
17:50hiredmanclojurebot: foos | are | great
17:50clojurebotc'est bon!
17:50hiredmanclojurebot: foos?
17:50clojurebotfoos are great
17:51hiredmanclojurebot: forget foos | are | great
17:51clojurebotI forgot that foos are great
17:52ordnungswidrighiredman: what's that goog for? Teachning clojurebot?
17:52ordnungswidrigs/goog/good/
17:52hiredmanclojurebot's factoid stuff uses fnparse for parsing
17:52ordnungswidrigme is not expected to understand fnparse, right?
17:53hiredmanordnungswidrig: clojurebot by default assumes "is" as the predicate
17:53hiredmanbut using that style with the predicate seperated out by the bars you can use arbitrary predicates for factoids
17:54ordnungswidrigah, I see.
17:54hiredmanclojurebot: I | can | dance
17:54clojurebotOk.
17:54hiredmanclojurebot: I?
17:54clojurebotI can dance
17:54hiredmanclojurebot: forget I | can | dance
17:54clojurebotI forgot that I can dance
17:54ordnungswidrigsomething different. How can I use functions that will be declared later?
17:54hiredmandeclare
17:55ordnungswidrighiredman: hmm, some things are just too obvious
17:55spuzhiredman: This appears to work, but do you know if there's a pre-baked function in clojure or clojure contrib that does the same? (defn prompt [msg] (println msg)(second (read-lines *in*)))
18:07ordnungswidrighttp://clojure.pastebin.com/m648ea526
18:07ordnungswidrighow can I simplify this one?
18:08ordnungswidrigbasically I'm passing a context through a serieas of function applications
18:09hiredman->
18:10hiredman,(1 (+ 2) (* 4))
18:10clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
18:10hiredmangrrr
18:10hiredmanstupid inlining
18:10hiredman,(1 (#'+ 2) (#'* 4))
18:10clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
18:10hiredmanoh
18:10hiredmanmea culpa
18:10hiredman,(-> 1 (+ 2) (* 4))
18:10clojurebot12
18:11ordnungswidrighiredman: no with destructurizing?
18:11hiredmanhmmm
18:11hiredmanyeah
18:12ordnungswidrigcries for a monad, I think.
18:13hiredman(-> ctx do-foo ((juxt first (comp do-bar second)))
18:13hiredmanetc etc :P
18:14ordnungswidrighiredman: nice. event point-free
18:14hiredmanpointless :P
18:15ordnungswidrigyes :-) clojure is acutally often point-free. I wonder it's because of the style in #clojure or if the language encourages a point-free style.
18:16The-KennyBecause point-free = good :)
18:16ordnungswidrigThe-Kenny: up to a limit
18:17The-Kennyordnungswidrig: Of course.
18:17ordnungswidrigI remember really scary pint-free expression in #haskell
18:17ordnungswidrigthe flip-apply-flip-flip-apply-of-death
18:18The-Kennyhaha :D
18:18ordnungswidrigmore a solution to rubic's cube than a haskell function
18:18hiredmanoh man
18:19ordnungswidrigwhere, hmm, the haskell folks love algebra. so this seems all reasonable.
18:21hiredman,((partial (comp seq reduce) (comp (partial apply conj) (juxt first (comp (partial + 1) second)) list) []) (range 10))
18:21clojurebot(1 2 3 4 5 6 7 8 9 10)
18:22ordnungswidrighiredman: is this id on seqs or a general identify?
18:22ordnungswidrighiredman: or on seqs of ints?
18:23hiredmanit's (partial map (partial + 1))
18:23hiredmanbut strict using reduce
18:24ordnungswidrigI see. This wasn't an identity at all.
18:24hiredmanhmmm
18:24ordnungswidrigneed to sleep soon :)
18:24ordnungswidrig,(range 10)
18:24clojurebot(0 1 2 3 4 5 6 7 8 9)
18:24hiredmanI should pull the mapped fn out to be the second arg to make it general
18:29ordnungswidrigIs wraping an sexp with an (do (println (str "xxxx")) sexp) idiomatic for debug printing?
18:29ordnungswidrigOr is there a better way?
18:30hiredman(doto something prn)
18:30hiredmanbut sure that works
18:30ordnungswidrighiredman: this will print the result of something?
18:31hiredmanyes
18:31hiredmanand return something
18:31jhawk28hiredman: does clojurebot have a limit on the output?
18:31hiredmanevaluated to
18:31hiredmanyes
18:31hiredmanI always feel dirty when I saw "return"
18:31Chousukeordnungswidrig: it would be more idiomatic to use a debug macro I think :)
18:31ordnungswidrigit like ? (let [x something] (do (println x) x)
18:32hiredmanordnungswidrig: yes, but with prn instead of println
18:32ordnungswidrigChousuke: a reader macro? Like !(something) will evaluate to (doto something prn)
18:32tomojI always feel dirty when I see "prn"
18:33hiredmansay
18:34ordnungswidrigsay what?
18:34hiredmancorrecting my earlier statement about return
18:35hiredmansay return not saw return
18:36ordnungswidrighiredman: oh dear, but that was a late one. Event regex wouldn't helped out and I don't know, if sed expressesions are commonly well understood on IRC.
18:36ordnungswidrigs/Event/even/
18:37hiredmanI see regexs on irc everywhere
18:38hiredmanthe other day I saw someone correct themselves with a regex that used back references
18:38jasappthat's kind of disturbing
18:38technomancyI'm still waiting for a client that can automatically DTRT when it sees someone type things like s/foo/bar/
18:40hiredmanhttp://luaforge.net/docman/view.php/83/95/ANoFrillsIntroToLua5VMInstructions.pdf <-- nice
18:44chousertechnomancy: wave will come first
18:44chouser^ random expression of hope disguised as an unlikely prediction
18:44hiredmanhmmm
18:48jasappdoes clojurebot have a way to refer to someone's last comment?
18:48hiredman~seen jasapp
18:48clojurebotjasapp was last seen in #clojure, 0 minutes ago saying: does clojurebot have a way to refer to someone's last comment?
18:49jasappahh, interesting
18:50jasappis there a way to call seen from clojurebot's clojure evaluator?
18:51hiredmanpossibly
18:52hiredmanit would be some work because clojurebot tries to discourage digging around in its own internals from the sandbox
18:52jasappit'd be kind of cool to feed him/her a regular expression and run it over someone's last comment
18:52jasappbut it'd also be a big waste of time, too
18:53hiredmanI suspect it would end up like clojurebot's tinyurl plugin
18:53The-KennyI think something like this would be cooler in a client, not a bot.
18:53ordnungswidrighiredman: I was the one with the backreference
18:53jasapptrue
18:53The-KennyPersonally, I would like to see a irssi plugin :)
18:53ordnungswidrigsounds like a no-brainer for erc
18:53The-Kennys/ a / an /
18:55arbschtyou can probably bend /lastlog in irssi to do that
18:55ordnungswidrigit's 01:00am local time which means bed time. *moahn*
18:56ordnungswidrigcu all
18:56The-KennyIt's not 01:00 am here, it's 00:57 am :D
19:39technomancydrewr: I'm looking at your use of swank in clot; what's the purpose of wrapping start-server in that repl call with the stop atom like you did?
21:08weissji'm trying out some project euler problems, one is to return the 10001st prime. my strategy is to have a primes function return a lazy seq of primes. and a prime? function that iterates over previous primes and divides the current candidate by that list.
21:08weissjhow can i make sure the list of already-calculated primes doesn't get recalculated each time
21:09weissjie, each call to primes accesses the same list
21:11_ato__(def primes-seq (primes)), then just use prime-seq instead of calling your primes function each time?
21:11_ato__or use memoize on primes
21:13_ato__weissj: note there's a clojure.contrib.lazy-seq/primes but I guess you want to solve it yourself :)
21:13weissj_ato__: yeah :)
21:15weissjwould be a bit too easy to use that: (nth primes 10001)
21:28lisppaste8jweiss pasted "untitled" at http://paste.lisp.org/display/89704
21:28weissjcan someone tell me what's wrong with this ^
21:29weissji get: java.lang.RuntimeException: java.lang.ClassCastException: clojure.core$num__5233 cannot be cast to java.lang.Number (NO_SOURCE_FILE:0)
21:29weissjon the line that starts with (take
21:31weissjnevermind - used "num" instead of "mynum"
21:41weissjanyone know why this happens?
21:41weissj(take 1 (lazy-seq (conj (primes) 2)))
21:41weissjjava.lang.StackOverflowError
21:41weissji wrote the primes function which obviously has infinite recursion problems, but why does it even get called? i only want 1 item in the seq, and that should be the 2 i conj'd on there first
21:43chouserI think you mean (lazy-seq (cons 2 (primes)))
21:44chouserwhat you have is a bit interesting, though.
21:46chouser,(take 1 (lazy-seq (cons 1 (lazy-seq (prn :hi) '(2)))))
21:46clojurebot(1)
21:46chouser,(take 1 (lazy-seq (conj (lazy-seq (prn :hi) '(2)) 1)))
21:46clojurebot(1)
21:46chouserhm, clojurebot doesn't show that :hi gets printed on the second but not the first
21:48chouser,(take 1 (lazy-seq (conj (lazy-seq (prn :a) (cons 2 (lazy-seq (prn :b) '(3)))) 1)))
21:48clojurebot(1)
21:57chouserand that one prints :a but not :b
21:58chouserconj on a lazy seq forces one extra step
22:15qedhello all
22:21solussdis there a easier way to access something in a vector of vectors? e.g. easier than this?: (def grid [[1 2 3] [4 5 6]]) ((grid 1) 2)
22:30chouser,(get-in [[1 2 3] [4 5 6]] [1 2])
22:30clojurebot6
22:30chousersolussd: ^^^
22:30solussdexcellent.
22:47emitsessions in compojure, where exactly do I use the decorate with-session... by itself? inside defroutes?
22:57emitok to answer my question I can just decorate the route itself...
22:57tomojI would think you would decorate the handler
23:09samlhey, I do C-c C-d d to see document of symbol.. and C-x o, q to kill the document buffer. can i kill it faster?
23:09samlin Clojure Box
23:19hiredmanqed: well, at least you get all the batteries that way
23:20hiredman<3 XeLaTeX
23:20_atosaml: hmm.. for me (not using Clojure Box just my own emacs) C-c C-d d makes the doc buffer focusued, so I just press q.
23:21saml_ato, oh i see. weird
23:21hiredmanclojurebot: hiredman | <3 | XeLaTeX
23:21clojurebotOk.
23:22hiredmanclojurebot: hiredman?
23:22clojurebothiredman <3 XeLaTeX
23:22_atosaml: Otherwise you could just leave the buffer open but hide it (C-x 1) it'll get reused next time you C-c C-d d, so you don't have to worry about it make hundreds of them
23:23saml_ato, yah but wouldn't it leave hundreds of buffers?
23:24_atonah, it'll just reuse the same one
23:24_atoat least, again, that's what it does for me
23:27saml_ato, ah thanks. kinda hard to see what's going on for a noob like me :P
23:29_atoyeah, I'm not too good with emacs either. A real emacs guy would either know a key combo for kill other window or would have some 10 keypress way of defining one and adding it to your .emacs :P
23:31_atoI know the first steps: you could define a keyboard macro with C-x ( C-x o q C-x ) and then name it with M-x name-last-kbd-macro, but I'm not sure how to then bind that to a short keystroke
23:32j3ffis there a built-in function that returns the max value in a sequence?
23:32tomojwell
23:32_atoj3ff: yes, funnily enough it's called "max" ;)
23:33tomoj(apply max the-seq)
23:33samUL_ato, ah thanks
23:33j3ffthanks
23:33tomojnot sure how well it scales to very large seq
23:33tomojs
23:33tomojperhaps reduce max would perform better
23:34_ato,(time (apply max (range 1000000)))
23:34clojurebot999999
23:34clojurebot"Elapsed time: 545.892 msecs"
23:34_ato,(time (reduce max (range 1000000)))
23:34clojurebot999999
23:34clojurebot"Elapsed time: 239.206 msecs"
23:35j3ffinteresting
23:35_ato,(time (apply max (range 1000000)))
23:35clojurebot999999
23:35clojurebot"Elapsed time: 403.153 msecs"
23:35j3ffone more question, is there another function to return said index of the max? :)
23:35_atohmm
23:35tomoj'I feel uneasy about passing very large seqs to functions with apply
23:35tomojno, you will have to write your own for that I believe
23:35tomojbut it's not very hard
23:36j3ffalright, thanks
23:36j3ffyeah
23:36tomojmost clojure doesn't like thinking about indices
23:36_ato,indexed
23:36j3ffyeah its because im implementing an algorithm into clojure
23:36clojurebot#<seq_utils$indexed__697 clojure.contrib.seq_utils$indexed__697@ec0f07>
23:37_ato,(apply max-key second (range 10000))
23:37clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
23:37_atohmm
23:37_atooh right
23:38_ato,(apply max-key second (indexed [8 2 4 9 5 5]))
23:38clojurebot[3 9]
23:38_ato(as in index 3, value 9)
23:38j3ffwhoa cool
23:39j3ffthanks!
23:41tomojah I didn't know max-key existed
23:41tomojnice
23:43j3ffis indexed part of a library?
23:43_atoclojure.contrib.seq-utils
23:43j3ffthanks
23:44_atobtw, about using apply, functions that take an arbitrary number of arguments like + and max are defined like: (defn max [x y & more])
23:44_atothat will happen is the first two values of the seq will get assigned to x and y and the rest of the seq to more
23:44_atoso that's really cheap
23:45_atoand then max will just deal with the first two cases and recurse
23:45_atoso it's usually about the same as doing reduce
23:46_ato,def max
23:46clojurebotjava.lang.Exception: Unable to resolve symbol: def in this context
23:46_atoclojurebot: def max
23:46hiredmanI seem to recall max using reduce internally
23:46_atoyep
23:47hiredmanand I remember using reduce externally was faster than using apply max and max's internal reduce
23:47hiredmanbut I don't remember why
23:48_atoyeah, that's strange, in theory it should be doing almost exactly the same thing
23:48_atojust one more or two more function calls
23:49hiredmanthis was all gone over, maybe six months or so a go in here
23:52tomojwell
23:52tomojwhen you apply a function to a huge seq
23:52tomojdoes some large tail of the arguments just get left inside a seq, to be reduced inside the call?
23:53hiredmanyes
23:53tomojcalling functions with a huge number of arguments always makes me feel uneasy
23:55hiredmanfor more than four args I like to use map destructuring