#clojure logs

2010-01-14

00:00arohnerif I put a dorun around it, I see 12 prints, and then exception
00:00arohnerif I take the dorun off, I see 0 prints, and then exception
00:00hiredmanerm
00:00arohneryeah.
00:00hiredmanhow are you consuming the for?
00:00arohnerI'll try to come up with a reproducing example
00:00arohnerthe for is returned by a function. I'm calling the function from the repl => the repl is consuming
00:01hiredmanhmmm
00:02hiredmanI certainly cannot reproduce it
00:02hiredman(for [x (range 13)] (if (= x 12) (throw (Exception.)) (prn x)))
00:04hiredmanoh!
00:04hiredmanare you using println or print?
00:04arohnerprintln
00:04hiredmanhmmm
00:05hiredmanthought it might be a flushing issue
00:05arohnerI reproduced it using your example, moving the body into a separate function
00:05arohnerlisppaste8: url
00:05lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
00:06lisppaste8arohner pasted "weird println issue" at http://paste.lisp.org/display/93372
00:08arohnersigh.
00:08arohnerit happens in slime, but not at the repl
00:08arohnernot at the real console
00:08arohnerit's a slime issue.
00:09arohnerwell, thanks for the help
00:31yangsx1Maybe this just happens to me. Projects using maven and thus leiningen sometimes make it difficult to work, because access to the central repos may fail, as is the case here in Beijing. Fortunately clojure and clojure-contrib havent moved to maven or lein to build themselves.
00:34hiredmanyou can add a repository you have more reliable access to
00:34durka42i can't seem to compile the latest contrib against the latest clojure
00:34durka42java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V
00:38hiredmanworks for me
00:39yangsxhiredman: thanks for the tip, but I even cannot make "lein-stable deps" finish itself (maybe a temporary problem with the release of clojure 1.1).
00:40hiredmanyangsx: and the problem is you are unable to grap the jars from maven central?
00:40hiredmangrab
00:40hiredmanhttp://groups.google.com/group/tuscany-sca-chinese/browse_thread/thread/3113aebbcbe710b4
00:41hiredmandurka42: that works for me was for you
00:42yangsxhiredman: No, because "snapshot org.clojure:clojure-contrib:1.1.0-master-SNAPSHOT" could not be retrieved
00:42hiredmanah
00:42durka42hiredman: hmm. i'll clean out the dir and try again
00:44durka42hiredman: huh, now it worked
00:48hiredmanit would be nice if someone figured out what that exception is
00:49hiredman<init> is a constructor, (I)V means it takes an Integer and returns void
00:50hiredmanand restfn has a constructor with that signature
00:50hiredman:|
01:53optimizeris there any chance a shell (like bash/zsh) written in clojure?
01:54unfo-optimizer, i was thinking about it myself ;) but that
01:54unfo-'s as far as it has gone
01:54unfo-but dunno, haven't googled for it
02:30G0SUBwhat is the best way to convert a string to a stream and vice versa?
02:31G0SUBI am trying to download a zip file using an http client and I want to unzip it in-memory and get the unzipped string back.
02:34replacaG0SUB: I think you want StringReader or StringBufferInputStream
02:35G0SUBreplaca: looking. thanks.
02:37G0SUBreplaca: does that behave like a File? ZipFile can take only a file.
02:38replacaG0SUB: no, isn't there a way to zip a stream?
02:39replacayeah, ZipInputStream
02:39G0SUBreplaca: looking
02:41G0SUBreplaca: OK, how do I convert a StringReader to an InputStream?
02:45replacaG0SUB: are you trying to read from the string or from the HTTP result?
02:45G0SUBreplaca: yes
02:45G0SUBreplaca: http result.
02:45replacaif you're getting zip back, you can't change it to a string cause it won't really be one
02:45LauJensen(slurp* url)
02:46replacayou'll have to get it as a byte stream from the http request
02:48replacainstead of calling slurp, just do (reader url) and pass the result to ZipInputStream and I think you'll be good to go
02:48G0SUBreplaca: thanks. I am using c.c.http-agent, btw.
02:51replacaG0SUB: well http-agent has a stream function right on it: http://richhickey.github.com/clojure-contrib/http.agent-api.html#clojure.contrib.http.agent/stream
02:51G0SUBreplaca: yeah, I think that should work.
02:52G0SUBreplaca: thanks for the tips. I am really a Java n00b.
03:04replacaG0SUB: np.
03:09G0SUBreplaca: I need a bit of help in writing a fn which reads a zip file from a stream and return an outputstream of uncompressed data.
03:25replacaG0SUB: so you absolutely need an inputstream? (an outputstream would be going back the other way)
03:25replacaor do you just need data?
03:26G0SUBreplaca: If I get the unzipped data as a string, I am fine. the zip file will have only one file in it.
03:30replacaYou're basically going to have to loop on that .read method in ZipInputStream and build up a stream
03:30replacathe part I'm not remembering now is how you decode the bytes into a String
03:30G0SUBhmm
03:31replacaI would just use loop..recur on the .read and then use (apply str (map bytes-to-str acc)))
03:32replacawhere acc is the vector of read results from your loop and bytes-to-str is the func that converts the byte array to the string
03:32replacaI'd help more, but I really have to crash
03:32G0SUBreplaca: how should I write bytes-to-str?
03:32G0SUBreplaca: no problem. thanks a lot.
03:33G0SUBah, (String. byte-array) works
03:34replacaYeah, that should be OK as long s you don't try to run it in japan or anything
03:34G0SUBhehe
03:34replacait'll barf if there's a difference between where you are and what you're reading
03:35G0SUBright, but my data is just ASCII
03:35replacaok, I've given you the tools. Let me know how it goes!
03:35replacayeah, you should be ok
03:35G0SUBreplaca: yep. many thanks :)
03:35replacagoodnight!
04:11Raynesthe-kenny: Ping.
04:40lypanovdoes running the AOT provide me with information such as misspelt function names in definitions that are called elsewhere like java does?
04:41lypanov(as in, i have a method C() and three callers Cx() does AOT fail during compile as it can't find Cx()?)
04:41lypanovs/three callers/& call/
04:42Chousukemethod? you mean java method?
04:43lypanovChousuke: both clojure "methods" defs.
04:43LauJensenlypanov: AOT compile to regular java class files, so for clojure functions you get that those kinds of errors
04:43Chousukethe compiler will complain if you refer to nonexisting vars or classes, but not methods. They are resolved at runtime using reflection (unless you use type hints)
04:43lypanovah, cool. thx LauJensen!
04:43lypanoveep.
04:44lypanovmaybe clojure is the wrong language for getting gwt going with :)
04:44lypanov(am trying to decide between clojure and scala)
04:44Chousuke,(foo 3) ; should fail during compile-time
04:44clojurebotjava.lang.Exception: Unable to resolve symbol: foo in this context
04:44lypanovbut i guess the dynamicness of clojure makes that impossible
04:44Chousukewhat exactly is the problem?
04:45lypanovChousuke: is the reflection path also taken when using AOT?
04:45Chousukeyes.
04:46lypanovif so, and thats part of the basics of clojure.
04:46lypanovi can't imagine that its possible to generate java that gwt will accept.
04:46lypanovas reflection is not allowed by gwt.
04:46Chousukeif you do (.someMethod x), you don't know the type of x
04:46Chousukeso it needs reflection
04:46Chousukebut you can avoid it with type-hinting, like (.someMethod #^MyClass x)
04:46lypanov*nod* and without type hinting it can't name mangle etc
04:48ChousukeClojure has a var called *warn-on-reflection* that you can bind to true before evaluation
04:48Chousukeyou can make code entirely non-reflective using that.
04:49Chousuketype hints are threaded through forms so usually you don't need them everywhere.
04:50LauJensenlypanov: try adding this to your main (set! *warn-on-reflection* true) and then compile. That'll give you a list of every single expression which needs a type-hint to rid the reflection
05:29Raynesthe-kenny: ping-number-2.
07:00lypanovanyone around know the internals of clojure?
07:00lypanovLauJensen / anyone else: how feasible do you think it is to generate java from clojure?
07:01lypanovassuming i add type hints everywhere.
07:01lypanovare there other dispatch types that java can't deal with?
07:01LauJensenClojure compiles to bytecode, seamlessly integrated on the JVM - Its no problem
07:02lypanovLauJensen: i should add background, i'd like to generate java source, which is the input gwt needs.
07:02LauJensenAh sorry
07:02LauJensenAt present I think you'd be happier in Java for that purpose :)
07:02lypanovyes, but this is a long term project.
07:03lypanovand the project tech, is the project. if you know what i mean.
07:03lypanovtrying to decide between scala or clojure as the source lang i use.
07:03LauJensenIf you have some time I recommend producing a small prototype in both languages, then compare experience
07:23lypanovLauJensen: good idea. can't think of what exactly i should prototype though.
07:23lypanovwill learn more about clojure and give that some good thinking.
07:24lypanovstill not convinced that i'm looking for a dyn lang. more of a compiles-moan sorta guy.
07:25lypanov(ruby from '99 till '04, then paid work forced a shift to java and i did ruby only in spare time, just made shift to ruby again for commercial work and realllly see the downsides to dyn and thinking more of scala)
07:25lypanov(maybe its just that ruby sucks rather than dyn sucks)
07:34LauJensenlypanov: I had a fun (but dangerous thought), what if you wrote Clojure, compiled to bytecode and decompiled into Java (http://www.dmoz.org/Computers/Programming/Languages/Java/Development_Tools/Translators/Decompilers_and_Disassemblers/) ?
07:35the-kennyLauJensen: I tried that
07:35lypanovLauJensen: at least scala generates much bytecode that can't be decompiled.
07:35the-kennyIt's almost readable, but good for searching for performance issues
07:35lypanovi guess its the same with clojure.
07:35LauJensenthe-kenny: In this case it doesn't need to be readable, just passable to gwt
07:36the-kennyLauJensen: hm.. it uses much RT etc. I don't know if this would work
07:37LauJensenThis discussion would probably be easier with c-in-c in place and Chouser or rhickey weighing in
07:37LauJensenforget 'possibly'
07:38lypanovc in c?
07:39LauJensenClojure is being implemented in Clojure, so all you have to do is provide a bootstrap and compile to any language you want
07:41lypanovits now in java?
07:42lypanovminimalistic bootstrapping is teh hard :)
07:42lypanovmaybe when chouser/rhickey are back they can weigh in.
07:42lypanovi'm 100% certain many people are interested in this.
07:54Raynesthe-kenny: Did you ever figure out the error you were getting in Slime when you tried to require something?
08:01rhickeylypanov: what do yuo want to do with the generated Java?
08:03lypanovrhickey: as input to gwt.
08:03lypanovwe're currently ruby/backend java/frontend. which is irritating. i'm slowly moving towards x/{backend,frontend}
08:03rhickeylypanov: you'd still run the risk of the GWT converter balking at something
08:03lypanovthere is a scala -> gwt project already, but its very primitive.
08:04lypanovrhickey: it depends what is generated. at least for scala its very hard as some generated bytecodes have no java equiv. eg throwing exceptions without a throws declaration.
08:05lypanovand it has tail call opts, which use jumps. so this requires lots of fixups to the ast.
08:05lypanovif clojure was easier / better matched, itwould make it a lot easier than doing the same for scala.
08:05rhickeylypanov: the lack of goto is definitely a problem with generating Java source
08:05lypanovotoh, clojure has the dyn side of things.
08:06rhickeylypanov: the dynamic aspect can go away with AOT and type hints
08:06lypanovrhickey: ast tree manips and break/continue usage fixes that, just lots of boring special case tree manip.
08:07rhickeylypanov: yes, and for Clojure that only occurs with recur
08:07lypanovrhickey: i'd like to have a unit tests -> produce type hinting.
08:07lypanovto remove even the need for manual type hinting in actual source.
08:07AWizzArdwhat is bad about manual type hinting?
08:08defnall that reading! and typing!
08:08AWizzArdIt's okay when the editor can hide/unhide the types.
08:08AWizzArdTyping.. it takes just a few seconds. This is not what reduces the productivity of a good programmer.
08:08defni was kidding, for the record...
08:09AWizzArdReducing the complexity of multithreading is where Clojure helps. Typing #^String does not make me unproductive. Working with locks does.
08:10AWizzArdType inference is okay, but in that case we would need a function (get-inferred-type #'foo) which our editors can use.
08:11lypanovAWizzArd: thx for the input. type annotation scares me much less now.
08:17Licensertypes are so much typeing?
08:18RaynesTyping is so much typing.
08:28chouserlypanov: I did once try to run the Java parts of Clojure through the gwt compiler.
08:28chouserI did so hoping to get PersistentHashMap in JS without hand-translating it.
08:29chouserbut it really didn't go well at all. I don't remeber everything gwt complained about, but it was enough that I spent a couple weeks translating the collection classes by hand instead.
08:32LauJensenchouser: isnt this the case where c-in-c would really give lypanov some mileage?
08:33chouseronly if there were a Java source back-end, and only if it produced Java source that gwt liked.
08:33Chousukec-in-c will solve all your problems and cure cancer.
08:34lypanovchouser: depending on how much i can get to like clojure, i'm open to writing that.
08:34lypanovis there a better beginners doc than http://java.ociweb.com/mark/clojure/article.html ?
08:35djorklypanov: I can bet you will like it very much
08:35lypanovi'm enjoying it :) but in case my research into things to read was flawed, prefer to ask.
08:35djorklypanov: it's a good article
08:35djorkbut I would also recommend just reading the docs, as they detail most of the corners of the language very succinctly
08:35cemerickI pine for a clojure-friendly gwt. Regular web development sucks.
08:36djorkI am trying to grok compojure right now
08:36lypanovcemerick: you do devel in which fallback is required, or interested in something pure clojure?
08:37cemericklypanov: fallback?
08:37cemerickdjork: The docs are sparse (and scattered), but it's a nice little framework.
08:37lypanovcemerick: ajaxless version for ie6 / noscript lovers
08:37cemerick(as long as you stay away from the sexpr html generation, IMO)
08:37cemericklypanov: no, I could care less about that.
08:37lypanovcemerick: heard of pure.js?
08:37cemericknope
08:38lypanovhttp://beebole.com/pure/
08:38lypanovwe're using it here. with jquery.
08:39lypanovit allows me to shove the designers html/css tarballs on line and make my code just hammer them into working functional apps.
08:39lypanovnow i'd just like to replace the js i'm currently doing that with, with clojure.
08:39djorkcemerick: you're using Enlive, right?
08:40cemericklypanov: eh, I'm not too concerned with separating js from html
08:40cemerickdjork: yes, badly
08:40cemerickthere's a ton of capability there, but I haven't grokked it yet (esp. template/snippet composition)
08:40lypanovcemerick: well, my concern is more separation of js/html from code.
08:41lypanovas in, data vs pretty.
08:41djorkyeah
08:41djorkhah
08:41djorkEnlive is really an amazing idea, I'm not sure if it's new or what
08:41lypanovah
08:41lypanovits the same idea
08:41djorkit kind of turns the template idea on its head
08:41lypanovsomeone just released the same thing for rails also.
08:41lypanovglad this is at last catching on
08:42djorkI don't really see anything about "selector-based templating" in Google
08:42cemericklypanov: yeah, looks like pure is the same as enlive, but driven by js
08:42djorkexcept for enlive
08:42lypanovdjork: gimme asec
08:42cemerickwhich means I immediately don't like it ;-)
08:42djorkheh
08:42djorkah, pure.js yeah I think I've seen that around
08:43lypanovdjork / cemerick: http://github.com/jferris/effigy
08:44cemericknice
08:44djorkyay
08:44djorkyeah, templating languages suck primarily because they make editing such a hassle
08:44lypanov*nod*
08:44djorkthey break syntax highlighting and structured editing
08:45djorkI was really thrilled to find Enlive because I am trying to build a web dev environment for the iPhone.
08:45djorkAnd editing anything but well-structured HTML is nearly impossible with the approach I am taking...
08:45lypanovafter doing non paired devel for 2 weeks with a designer i finally gave up and started to rewrite everything to use pure.js
08:45lypanovproductivity soared
08:45djorkyeah
08:46lypanovability to replace that js would a nice lang would just make it all so much nicer
08:46djorkno more <%= @f.x { |y| y.bar } %>
08:46LauJensenlypanov: Had a look at Clojure script?
08:47djorkscriptjure?
08:47djorkOK I have 10 minutes (self-imposed) to get compojure and enlive working
08:47lypanovreading.
08:47lypanovdjork: i think he refers to http://github.com/technomancy/clojure-contrib/tree/7ea70da82e42416864e2f97e3d314aced34af682/clojurescript
08:48lypanovis that the one LauJensen?
08:48cemericktotally, totally OT, but: does it seem like a good idea to others that dates formatted for storage as strings should be converted to UTC (to avoid oddball daylight savings time rules, etc)?
08:48LauJensenlypanov: I think you'll find it under Chouser
08:48lypanovah, another one. hehe
08:48LicenserOkay people :) I
08:48Licenser#v
08:48LauJensendjork: I have a screencast showing you how to get going with Compojure+ClojureQL in about 10 minz, and another one showing of Enlive (2 actually)
08:48Licenserargh
08:48esjcemererick: is what I do.
08:49djorkoh yeah? I'd love to see them
08:49LauJensenThen head over to www.bestinclass.dk -> click blog
08:49lypanovLauJensen: wantttttttt
08:50lypanovs/ed/ing/
08:50djorkcemerick: absolutely, every time
08:50djorkthere's no other way to store dates as strings as far as I am concerned
08:50cemerickOK, good to know.
08:50LicenserI've a question, I'm working on a bit game stuff in clojure and have the folowing situation, I've a 'game'-struct that holds all the unit structs. each update function gets the game and and 'id' for the unit passed to do the stuff with it it should do. Now I come to the points where the units should become 'inteligent' but passing every AI script the entire game map to update it sounds a bit of a overkill for me or is that a good idea?
08:50cemerickI've never really had to deal with dates before where I cared much.
08:51djorkLicenser: passing a large object is never a problem because it's really passing a reference to that large object
08:51djorkinternally
08:51lypanovum. who is chouser on http://github.com/richhickey/clojure-contrib/network ?
08:51Licenserdjork: I know it's not a memory problem but just a thing of well niceness
08:51djorkbut generally, in functional programming, you want to pass everything a function needs to know about to it directly
08:52djorkanother thing to consider is having AI functions that return the action that they think should happen
08:52LicenserIf I have somehting like: (recharge-battery game unit-id engine-id ammount) I kind of feel it gets crouded
08:52Licenserwhile it keeps nice and functional
08:52djorkthey take the game state, look at it, and say "move this here, move that there"
08:52djorkbut without actually mutating the game state
08:53sparievLicenser: have you seen this paper http://portal.acm.org/citation.cfm?id=1176617.1176630
08:53djorkthat's really not too bad Licenser, and you can create macros and closures around things to keep it slim
08:53Licenserspariev: no
08:53Licenser*nods* Also I am not compfora
08:53djorkbut that argument list looks totally sane
08:54cemericklypanov: chouser is here :-)
08:54Licensercompfortable with allowing the AI to mutate the entire game - so I like the idea of returning 'what should happen' stuff
08:54lypanovcemerick: aye, saw him earlier just wondering based on LauJensen's reply where i can find his github fork
08:55sparievLicenser: not sure it's relevant to your problem, but it describes interesting patterns regarding to game ai imho
08:55djork"udvikling" is such a funny word to my English-speaking eyes :)
08:55ChousukeLicenser: you might be able to use a global binding to provide a read-only view of the game state
08:55lypanovduh... that would be Chouser with a C
08:55djorkwhat does it mean, literally?
08:56ChousukeLicenser: eg (def *game*) then a macro (with-game-view @some-ref-holding-the-actual-state (charge-battery ...) ...)
08:56LicenserChousuke: that is a good idea
08:56Chousukethough as usual, you'll need to be careful if you do threading
08:56chouserlypanov: you're looking for clojurescript? Did you find it? I'm afraid it's rather out of date now
08:57lypanovchouser: i found the repl but chrome doesn't like that at all.
08:57lypanovchouser: just reading your c-in-c post. whats the status on that out of interest?
08:57Licenserhmm yea it is kind of complicated. So far (since all functions are internal and 'trusted') it is kind of easy I just pass them the game and the stuff they should change and the y do
08:58djorkLicenser: in my very limited MUD game dev in Clojure I've found that passing the game state around is a good thing
08:58Licenserdjork: *nods*
08:59chouserlypanov: ongoing. "master" branch of clojure has perhaps 90% of the features required for cinc.
09:00RaynesYay! I think I got clj-apache-http into a reasonable state now. No more libs included in the github repo, and no more nasty ant build files. :D
09:00RaynesAnd no more namespace with about 37 dots in it. :<
09:00chouserlypanov: huh, clojurescipt.n01se.net works fine for me in chromium on ubuntu. I'm a bit surprised -- haven't tried it in ages.
09:00Licenserwhat makes it kind of complicated that it's not going to be a actual game but should be kind of a library for simulating game combats
09:00RaynesWhy do people do that anyway? Do people really enjoy typing org.this.that.overhere.overthere.overtherainbow?
09:02LauJensenLicenser: I wrapped JMonkeyEngine a while ago
09:02chouserRaynes: it's recommended by the Java docs, and guarantees no namespace clashes
09:03cemerick...and is totally ignored by a lot of java libs :-/
09:03Rayneschouser: But this isn't a Java application. :|
09:03cemericksorry, s/java/clojure
09:03Chousukeyou should have at least two segments in your namespace, anyway :/
09:04Licenserah LauJensen not a graphics library just something to calculate events, outcomes and things
09:04cemerickRaynes: distinct namespaces are good. 50 different libs claiming the "http-client" ns (or whatever) would not be good.
09:04LauJensenLicenser: JME is vast
09:04djorkI like my namespace to be the name of the project
09:04Chousukeyeah. namespaces allow for better naming overall.
09:05RaynesI changed the ns to cljapachehttp. It was like 5 segments long. I suppose I can add another segment.
09:05LicenserI trust you but I want my own LauJensen :P
09:05djorknaming an ns after the github project is close enough to unique for most purposes :)
09:05djorkunless you want to use two forks at once
09:05djork:P
09:05Chousukeit's not like you need to type the full org.whatever.foo very often
09:05RaynesI've just seen lots of projects where the ns was just the project name, so I figured that was a good option.
09:06chouserRaynes: there are definitely some people advocating that
09:06chouserI'm not fully convinced either way.
09:06Rayneschouser: Leiningen does it, so I figured it would be good.
09:06ChousukeRaynes: I think it causes problems in some cases, because the class for the namespace will end up in the default package
09:06djorkhmm
09:07cemerickIt's a bad path to take, on all but the most superficial criteria.
09:08RaynesI suppose I'll add another segment or two, but what it was originally was a bit obscene.
09:08Licenserwell thank you all for the input I'll play around a bit more :)
09:08chousercemerick: technomancy has argued that it has cause major upheaval when the maintenance of a lib has moved from one "site" to another, requiring all users of the lib to switch from org.foo.magiclib to com.bar.magiclib
09:09Chousukechouser: well, that's not really needed :P
09:09chousermy response to that was -- if it's actually the same lib, why not leave the name alone?
09:09chouserChousuke: right
09:09cemerickchouser: that's a good point, but *choosing* a proper ns is totally orthogonal to *having* a useful ns to begin with.
09:11chouserso far I haven't named many public non-contrib clojure libs. But for example, I'm insufficiently arrogant to claim "clojure-jna" as a top-level name, so I'm happy I didn't have to come up with something more creative and could just call it net.n01se.clojure-jna
09:11Chousukeif you have more than two segments it'll also be easier to differentiate forks.
09:11Chousukewhich might not be needed that often, but it's an advantage nonetheless
09:15RaynesI'll also point out that the original namespace didn't really make much sense in the first place, which is one of the reasons I changed it.
09:17chouserRaynes: fwiw, it's taken me many many months to be acclimated to the deep and nearly-empty directory trees required by java and clojure for projects named this way.
09:17chouserI guess I am used to it now though. ...doesn't anger me the way it did once. :-)
09:18Rayneschouser: That is annoying, but it's the name that didn't really make sense.
09:18cemerickIf you're managing a large and diverse codebase (or interrelated set of codebases), it's simply the only way to cope. We end up having 3-6 segments depending on the project, etc.
09:21RaynesI changed it back to what it was originally. I guess the author owns the twinql.com domain. That was what had me a little confused.
09:25RaynesI'm just trying to get clojure-twitter and all of it's dependencies fixed up and on clojars. Going good so far.
09:27djorkfor(Object o=null;;o=new Object[]{o});
09:27chouserdjork: ew
09:27djorkcrashes the JVM in a very inelegant way
09:28djorknot graceful
09:28djork:) just for fun (saw it on Reddit)
09:28djorkbrb
09:29chouser(loop [o nil] (recur (to-array [o])))
09:29chouserthere, much better.
09:31cemerickRaynes: don't let us push you around any :-) If you think it needs a different ns, that's your call.
09:32Raynescemerick: Naw. It's the authors call. ;)
09:32cemerickRaynes: sounded like you were forking
09:32jcromartieall of you professionals use your real names :)
09:33Raynescemerick: I am.
09:33cemerickRaynes: then whether a new ns is used is your call, IMO
09:33RaynesIt's better that it keeps it's old name anyway. I imagine there is some code out there using this besides clj-oauth (which I'll be migrating to leiningen as well)
09:34RaynesGood point, but still, this way people don't have to change their code if they pull it off clojars.
09:35RaynesPlus, you guys have given a good argument for multi-segmented namespaces.
09:37sparievwhy could code like (pmap #(* % %) (range 0 10)) work fine in lein repl, but throw java.util.concurrent.RejectedExecutionException in slime when connected to lein swank server ?
09:37sparievi'm using 1.1.0-master-SNAPSHOT
09:38sparievhere's full commands for swank / repl as seen in ps - http://pastebin.com/m65144fcc
09:39spariev(clojure-version) shows "1.1.0-master-SNAPSHOT" in both cases
09:41bpattisonI need to call a Java function that takes a double array, how do I great a double array of a given size in clojure?
09:41bpattisondouble[] adfGeoTransform = new double[6];
09:41bpattisonpoDataset.GetGeoTransform(adfGeoTransform);
09:42mjt0229does that method modify the array as a side-effect?
09:42the-kennybpattison: double-array should be the function
09:42mjt0229I was wondering recently how Clojure handles Java interop for java methods that have side-effects.
09:43the-kenny,(double-array [1 2 3])
09:43clojurebot#<double[] [D@1669fc6>
09:43Chousuke,(make-array Double/TYPE 6)
09:43clojurebot#<double[] [D@2fab89>
09:43bpattisonthe-kenny: excellent. thanks!
09:43{newbie}What do you guys think about point free clojure?
09:43the-kennymjt0229: "Normal" Java datatypes are mutable like in every java program
09:43mjt0229Oh, of course.
09:44Chousuke{newbie}: useful sometimes, but not as idiomatic as in haskell.
09:44mjt0229I ran across an API that expects me to pass in an empty Set, which it would fill on my behalf with the information that I wanted.
09:44{newbie}Chousuke: isn't point free a bit bad for someone who want to profile
09:45mjt0229I guess the point is that you can pass in a sorted set or a hash set, depending on what you're interested in.
09:45{newbie}each "method" individuali?
09:45Chousuke{newbie}: may be? I don't know.
09:45{newbie}individually?
09:45mjt0229But I wouldn't do it that way, at least not without returning the set after I was done with it.
09:45Chousukemjt0229: you can't pass in one of the persistent set types though.
09:45Chousukemjt0229: since they don't support mutation
09:46mjt0229Right, it would have to be (.fill obj (HashSet.))
09:46Chousukeyeah.
09:46mjt0229Well, that doesn't retain a reference, but you get the idea.
09:46the-kenny(let [myset (HashSet.)] (.fill obj myset) myset) would work :)
09:46mjt0229indeed.
09:46Raynesthe-kenny: Did you ever figure out that error you were getting with swank around the first whenever you tried to use/require something?
09:46the-kennyRaynes: Yes
09:47the-kennyIt had something to do with my init-file
09:47the-kennyafter I removed it, everything worked fine
09:47Chousukeor even better, finish it with (set myset) to get a persistent set :)
09:47the-kenny(the only thing it modified was some *vars*
09:48Raynesthe-kenny: Just asking because I had the same problem earlier and asked on the mailing list. It has something to do with *warn-on-reflecting* being set to true. Setting it to false fixes it.
09:48the-kennyRaynes: Yeah, that was one of the vars I was setting
09:48Raynesreflection*
09:48the-kennyA very very strange error
09:49Raynesthe-kenny: I believe somebody has figured out the cause of the error. Hopefully.
09:51Rayneshttp://github.com/ztellman/swank-clojure/commit/1f79e9312650bb41b541d8c601382ac22900939c
09:53the-kennyuhh that's awesome
09:54chouserThe MEAP is up, so you can read the first 4 chapters, plus more as we write them. http://joyofclojure.com/
09:57chouserrhickey: did Manning not contact you for technical review?
09:58rhickeychouser: nope
09:58chouserhmph. That's silly.
10:03cemerickthis is funny: http://github.com/Scriptor/pharen
10:06jcromartiehah
10:07jcromartieobligatory mention: http://github.com/jcromartie/objclj
10:07jcromartieneeds some love
10:07jcromartieand maybe a better name
10:08cemerickinsanity :-)
10:09cburroughschouser, Yesterday you suggested I use LinkedBlockingQueue and ThreadPoolExecutor instead of trying to be overly complicated. I just wanted to let you know it appears to have worked out well
10:10spariev_pmap work in slime if run via M-x swank-clojure-project or just M-x slime, only behaving strange in lein swank server
10:10chousercburroughs: great, thanks for the update.
10:11chouserjcromartie: cool!
10:13stuartsierra~log
10:13clojurebotsee logs
10:13stuartsierra~logs
10:13clojurebotlogs is http://clojure-log.n01se.net/
10:13chouserjcromartie: I think someone else has done something similar (without the Objective-C aspirations), though I'm not finding it now.
10:16defnjcromartie: pharen is awesome lol
10:16jcromartiedefn: I guess so? Why are you telling me? :P
10:16rhickey'maenadic' - fancy
10:16stuartsierraReturning from yesterday; double-argument dispatch with protocols http://paste.lisp.org/+2015
10:16jcromartiebut yes pharen looks awesome
10:16stuartsierrarhickey: is that what we you talking about Tuesday evening?
10:17defndefmacro: you posted the link
10:17defnerr jcromartie you posted the link
10:18jcromartieI pasted a link to my own lisp-to-C project, cemerick pasted pharen
10:18defnah, my mistake
10:18defnwhat's the lisp-to-C named?
10:19cemerickI wouldn't say awesome...scary is more like it.
10:19cemerickIMO, of course :-)
10:19defncemerick: i think we're all on the same page there
10:19defnit's novel and cool though
10:20cemericknovel, for sure. Perhaps I'm feeling curmudgenly today.
10:20defni know i am
10:22chouserI hadn't considered it before, but ... a PHP backend for cinc might actually be pretty popular.
10:22stuartsierradoes PHP have bytecode?
10:22chouserbeats me
10:24cemerickthat's the whole point of zend, right? Have a JIT in the background to speed things up?
10:24jcromartieI had a friend that tried to convince me that Perl was bytecode-compiled and ran on a VM
10:25chouserjcromartie: perl6? :-)
10:25jcromartiehis argument was that any interpreted language that is parsed into a tree structure and run by an interpreter counts as bytecode and a vm, where the C data structures are "bytecode"
10:25jcromartieyeah
10:26chouseroh, I see. "compiled" and "vm" *maybe*, but to me bytecode implies serialized.
10:26jcromartiehttp://php.net/manual/en/book.bcompiler.php
10:28rhickeystuartsierra: kind of. I think the complex-parts protocol complicates things - it's ok to just have implementation-aware code use :r and :i, and to not try to normalize other numbers as complexes. Also, putting add-number and add-complex into the same protocol implies a closed-ness that doesn't exist - you could instead have adding-long and adding-complex etc protocols, obviously an open set
10:30rhickeystuartsierra: but yes, the fundamental trick is (add anX aY) -> (add-X aY anX)
10:30chouserI need to read that, but I did something probably similar for finger trees
10:32chouserappending one tree on another requires different code for each combination of node/deepnode
10:33rhickeyprotocols let you do double-dispatch without the type-intrusion of the visitor pattern
10:34rhickeychouser: chapter 2 is a doozy
10:34stuartsierrarhickey: Cool, thanks. I was playing with several ideas at once, that's how complex-parts got in there.
10:34chouserrhickey: :-/ yeah. I think it's going to get trimmed back a bit before we're done.
10:34stuartsierraAnd I was thinking that adding-* should be separate protocols.
10:35rhickeychouser: I'm sure what-goes-where will be more evident when you have all of your material in hand
10:36rhickeyi have to admit the early infix example made me cringe a bit
10:38chouserat our current rate for pages-per-section, we'll overshoot our page goal by quite a bit. Hopefully that means will be able to toss out all the least valuable content and end up with something very solid.
10:38cemerickrhickey: on the php project page, you mean?
10:38rhickeycemerick: no, in Joy of Clojure
10:39cemerickoh, right
10:39lypanovchouser: do you think i should wait on the js conversion project until you get to 99% c-in-c or should i get into it now in case its needed to shape c-in-c?
10:39chouserlypanov: what are your plans for a js conversion project?
10:40lypanovchouser: basically, plug clojure via java source gen into gwt.
10:41Raynesuser> (two + 2) => 4
10:41Raynes:D
10:41RaynesI def'd two as + and unmapped +.
10:41Raynes:>
10:41spariev_oh, I have finally fixed my error with pmap - turned out I used old 1.0.0 version of lein-swank, and new 1.1.0 works just fine
10:46chouserlypanov: it will be much easier to reach a useful stable state after cinc, but I expect some things could be done now to get there sooner.
10:48chouserlypanov: for example, it would be interesting to have a maps-and-vectors version of Clojure's compiler analysis tree (AST?)
10:49chouserif you could build such a thing that rhickey signed off on, then you could start work on code to convert that to java sources, code that you ought to be able to drop in to cinc once it's all done.
10:59mjt0229What's the proper type hint for an array? appending a '[]' doesn't appear to work.
11:00chouserdepends a bit. what type of object is in the array?
11:01mjt0229Let's assume its a Java object, not a primitive.
11:01mjt0229It's an object defined in a Java library, whose api returns (inexplicably) an array rather than a list.
11:01chouser#^objects
11:02chouseroh. if it's being returned to you, why do you need to hint it?
11:02mjt0229I'm binding it in a let form to a name.
11:03chouseryou only need a hint if you're going to use it in a way that can take advantage of that hint
11:04angermanOhh as we are on the Array thing. That usually has that strange [D... or so look. How much would it break if clojure would internally translate Object[] into the correct type-hint?
11:04mjt0229I've set *warn-on-reflection* and my access via aget is reflecting. I think I can restructure the loop so I don't need to use aget.
11:04mjt0229yeah, in Java it looks like [LString, I think.
11:06chousermjt0229: 'aget' itself should require reflection. You might need to hint what 'aget' returns.
11:06mjt0229ah.
11:07chouser"shouldn't"
11:07mjt0229that indeed does appear to be where the reflection is occurring, but there wasn't a binding there, so I didn't know how to place a type hint in that form (it's just a few nested calls)
11:07defnmmm partition -- mutually exclusive and exhaustive
11:08chouser#^String (aget a x) ; should work
11:08chousermjt0229: if you're playing with type hints, you might find repl-utils expression-info helpful.
11:09chouser(expression-info '(let [a #^ints map] (aget a 1))) ;=> {:class int, :primitive? true}
11:09mjt0229Cool, I'll take a look.
11:09chouser(expression-info '(let [a #^"[Ljava.lang.String;" map] (aget a 1))) ;=> {:class java.lang.Object, :primitive? false}
11:09mjt0229So, you can place type hints alongside any method invocation?
11:10mjt0229ie, (println #^String (first ["foo" "bar"]))
11:10mjt0229that's not a great example, but I'm just trying to show the syntax in a little context
11:11chouseryes but with a pile of caveats. :-)
11:11mjt0229for what it's worth, I was using a counting loop over the array, but I was able to switch it to a simple list comprehension and get the type hints correct.
11:11mjt0229Which has improved the readability of the code, not surprisingly.
11:12chouser:-)
11:19RaynesI'll probably have to wait until the first of the month for any loose cash. :\
11:22chouserRaynes: Manning runs deals occsionally, sometimes as much as half-off. When they tell us they're going to do that, I generally remember to tweet it.
11:22lypanovLauJensen: (i speak dutch, so... yeah, irony). man.... my wife won't let me use clojure anymore as your page says it gives 10-25x more "fart" :(
11:22Rayneschouser: Cool. I'll follow you.
11:24RaynesTwo?
11:24LauJensenhehe
11:24LauJensenlypanov: I didn't know that the woman where in control in Holland :)
11:25lypanovLauJensen: she vetoed my request for more power.
11:25LauJensenhaha
11:25chouserRaynes: there's also http://tinyurl.com/clojureinaction
11:26RaynesOh dear.
11:26jcromartieClojure Inaction
11:26lypanovbut inaction only has 3 chaps and joy has 4. so joy is obviously superior.
11:26jcromartiesounds demotivating
11:26lypanovhehe
11:26jcromartieI've had quite a good amount of Clojure inaction lately.
11:27Rayneslypanov: Joy also looks like it is going to cover more than the other one.
11:27lypanovi'll prob just end up buying both, in action has some neat sounding sections on hadoop.
11:27RaynesSuch as protocols and types.
11:27lypanovRaynes: aye, in action is more practical.
11:28lypanovi usually use such books as ref and bed side reading so for me all depends on writing style. as in, how fast i can read it without interruptions stopping me.
11:28RaynesI'll get Joy first, because chouser is awesome, and get Luke and this guys book eventually.
11:29chouserI expect "in action" to be larger and have more examples relating to specific kinds of deployments (testing, IDEs, web sites, amazon services)
11:30Rayneschouser: Are you trying to accomplish something specific with Joy?
11:31chouser"joy" is meant to be more about understanding clojure itself in more detail. not so much how it works internally, but how best to use it and hopefully bring the reader along to be able to think about problems in a more clojurey way.
11:32lypanov(also, i'm really picky, and 99% of the time i end up not using the libs that are the most popular)
11:32Rayneschouser: Yessir, your book is definitely for me.
11:32{newbie}so wich books is more focused in the innerwards of clojure?
11:33RaynesDamn people and their fancy lib directories full of jars on github.
11:33mjt0229ooh, more clojure books?
11:34RaynesLuke's book will be coming out before the rest of them.
11:35lypanovRaynes: which is that?
11:35Rayneslypanov: It's on apress.
11:35chouser{newbie}: I don't know of a book that plans to cover the internals.
11:35Rayneshttp://www.apress.com/book/view/9781430272311
11:35RaynesIt's a whole other book.
11:35chouser{newbie}: http://java.ociweb.com/mark/clojure/article.html has a lot of detail about the innards of the STM
11:36lisppaste8stuartsierra pasted "Automated 2-argument type dispatch with protocols" at http://paste.lisp.org/display/93387
11:36stuartsierraPhew!
11:36stuartsierraI did it!
11:36chouser{newbie}: for innards of PersistentVector, try http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/
11:37{newbie}chouser: that last link was good
11:37{newbie}the previous one ins't very detailed
11:37{newbie}thought
11:38chouserstuartsierra: whoa
11:38angermaninteresting. lein swank does not add the classes folder to the classpath
11:38angerman:/
11:38{newbie}here is the deal the compiler/interpreter classes at my univ where optional, and I choose another option so where i'm realy lacking is in hte parsin compilation front
11:39dysingerstuartsierra what's needed for rsync for the maven repo ?
11:39dysinger(IE, do we need an rsync server set up )
11:39dysingerdo you have an RTFM doc pointer ?
11:39stuartsierradysinger: I think all you need is SSH access and an rsync client on the server
11:40stuartsierralet me find the link
11:40dysingerk
11:40dysingerI know you can rsync with ssh
11:40dysingerbut you can also rsync with rsync:// without giving someone a login on your box
11:40stuartsierraHere's one post describing what to do: http://vafer.org/blog/20081026142413
11:41stuartsierrahere's the Maven docs: http://maven.apache.org/guides/mini/guide-central-repository-upload.html
11:42stuartsierralooks like Maven needs a user account set up with their public key
11:42dysingerI see
11:42dysingerok that looks easy enough I'll get it done today
11:42stuartsierragreat!
11:43stuartsierraBut back to the fun stuff - double dispatch!
11:44mjt0229stuartsierra: which version of clojure provides deftype? Is it not in 1.1?
11:46chousermjt0229: master branch from github
11:46mjt0229thanks.
11:46mjt0229I've got some reading to do, it looks like.
11:47stuartsierraI don't know if this is worth the trouble. I just wanted to see if it was possible.
11:47stuartsierraIn theory, I suppose one could extend it to more than 2 arguments, but the mind boggles.
11:47chouserstuartsierra: very interesting
11:50chouserthat is indeed very much like what I did (by hand) for app3: http://tinyurl.com/ylx4j3k/finger_tree.clj#LID288
11:50chouserI'm trying to think if I could use your macros...
11:52chouserthe problem being that I've alrady got protocols with other methods, the double-dispatch is just for one of the methods.
11:52stuartsierraHave you rewritten the finger-trees with deftype and defprotocol?
11:53chouseroh, yeah, that was an older version.
11:54chouserand the api for deftype has changed since I converted it over
11:55chouserhttp://tinyurl.com/yeh5fgg/finger_tree.clj#LID343
11:55dabdit would be nice if the if-let macro let the user refer to the binding in the 'else' part. Is there any reason this is not possible?
11:55lisppaste8stuartsierra annotated #93387 "Removed some dead code" at http://paste.lisp.org/display/93387#1
11:56chouserdabd: you want to know if it was nil vs. false?
11:56dabdchouser: no, I want to use the value of the test in the else part too
11:57chouserin the else part, the value of the test could only have been either nil or false.
11:57stuartsierraI'm not sure if it works for non-commutative functions.
11:57stuartsierraAt least, you have to be very careful.
11:58chouserstuartsierra: ah, app3 is not commutative, so yes the args are sometimes in reverse order and must be handled carefully.
11:59stuartsierraI wonder if I can fix that?
12:00dabdyes you are right I am misusing the macro. the test should return a boolean and I was trying to make it return a numeric value.
12:00stuartsierrayes!
12:01lisppaste8stuartsierra annotated #93387 "Fix argument order" at http://paste.lisp.org/display/93387#2
12:02stuartsierraThat works for non-commutative functions as well.
12:11stuartsierraYou wouldn't want to do this for 3 arguments anyway - you'd need too many methods
12:14stuartsierra2^3 for two types, 3^3 for three types, 4^3 for four types, ...
12:24RaynesWhy oh why did this guy have to add his lib directory and all of his project's dependencies to his repo on the initial commit.
12:35stuartsierraBecause everyone's afraid of Maven.
12:37Raynesstuartsierra: I just went through hell trying to remove stuff from the initial commit. Took me 2 hours to figure out how to do it. You do it by looking up the answer on stackoverflow.com.
12:37Raynes:>
12:42polypuswhat's the deal with AOT compilation and namespaces. i seem to remember somebody in here say something about them having to be at least binary (foo.bar) in order to compile. is that right?
12:43wiligtechnomancy: Ok, I have some working code for swank-clojure that fixes that bug at least in my simple tests.
12:43mtmchouser: Congrats on getting the MEAP up; I know it's probably ridiculous to ask, but are there any "coupon codes" for 'The Joy of Clojure' yet?
12:44technomancywilig: wow; great
12:44technomancycan you use read-line in the slime-repl buffer?
12:44wiligtechnomancy: hmm, explain what you mean? sorry, I'm really green.
12:46technomancywilig: currently entering (read-line) in the slime-repl hangs it since the I/O streams for that buffer are not hooked up quite right
12:46stuartsierrapolypus: I think that's correct; namespaces need 2 parts
12:46technomancyI think this is related to the bug you were talking about, but I'm not 100% sure
12:46wiligah, let me try
12:46polypusstuartsierra: ty
12:47chousermtm: none that I know of -- will tweet as I hear of them.
12:47wiligtechnomancy: Still hangs, let me have a look at it.
12:47technomancywilig: must be something else then... thanks for looking into it!
12:47technomancywhat did you end up changing?
12:48wiligio.clj right where you said it would be.
12:48mtmchouser: no problem, thanks (as an aside I find it amusing that Manning has free shipping for orders > $45; 'The Joy of Clojure' is $44.99) ;-)
12:48polypusmtm: same happened to me the other day with snow leopard on amazon. 1 cent off
12:49wiligthe clojure.contrib.sql tries to call println on the proxied object, but was failing. so I created an interface, and added that to the proxy
12:49wiligso sql exceptions now get reported correctly.
12:50polypusso i ended up buying an ssd to make up the diff :)
12:51wiligtechnomancy: I also rewrote call-on-flush-stream to call-on-write stream and was able to get rid of the scary threading bit. Hopefully it will work for all cases, but I don't know enough to test it rigorously.
12:53chousermtm: one benefit of working with a publisher: I don't have to defend such decisions. :-)
12:54mtmchouser: I would have gladly overpaid by $0.02, it's just the generous kind of guy I am
12:55chouserI didn't even know what they were going to charge until it showed up on their site.
12:55technomancychouser: they let you work in your own document format?
12:55technomancyI've heard of authors writing for manning in the past that had to use MS Word; that shocked me.
12:55tcrayfordchouser: do you want feedback on ze book?
12:55mtmwell, the book is ordered; now, get cracking on the next chapter! :-D
12:56chousertechnomancy: I guess they've used Word in the past, but now they've also got a docbook-like format. So we've built a toolchain that produces that xml.
12:57technomancynice
12:57chousermtm: yessir!
12:57technomancyI guess the prags use docbook too; makes sense
12:57chousertcrayford: of course!
12:57tcrayfordI'm finding one of the paragraphs annoyingly written (end of page 8)
12:57tcrayfordthe one talking about concurrency and idioms
12:59chousertcrayford: noted
13:00tcrayfordI can rewrite it if you want
13:01chouserheh... Well the first couple chapters are already getting major rework. Thanks anyway.
13:01tcrayfordaye
13:01mtmchouser: do you want minor editorial comments (grammar, case, etc.) posted to the author forum, sent by email, or noted here?
13:02chousermtm: the forum is probably the best, though I think the whole book will go through a couple more rounds of review an editing for that kind of error before it goes to print.
13:02chouserreview and editing
13:03chouserall comments are welcome
13:03chouser...especially comments that contradict other comments, because then we can just do whatever we want. ;-)
13:05chouser37% off with code "j1337"
13:08technomancy"Take this REPL, brother, and may it serve you well." always makes me feel like coding is an adventure.
13:08tcrayfordit feels like the start of a choose your own adventure book
13:09technomancyor like you just got the Master Sword in Zelda
13:09MefachedLisp is an adventure
13:10MefachedIt's an interesting language, unlike C-likes
13:10tcrayfordI'd dispute the idea that interesting programming comes from the language
13:10tcrayfordIts like saying interesting gardening comes from a good lawnmower
13:11greghthere could still be an interesting lawnmower, though
13:12qbgtcrayford: Then Lisp is like having a mecha for a lawnmower.
13:12hiredmanthe language is not just a single tool
13:12hiredmanit is a set of tools
13:13tcrayfordand what you think in
13:13tcrayfordand a religion
13:13hiredmananyone who actual works with tools can tell you the end product relies a lot on the tools used
13:14hiredmane.g. a square cut with a hand saw is harder than with a chop saw
13:14hiredmanand there are also techniques and opinions too
13:15hiredmanthe bookkeeper were I work is into woodworking, he would rather die than use a metal fastener of any kind
13:15hiredmanjust does all kinds of joints
13:16chouserand a lisp is different from many other language types because it gives you a wider range to tool-making tools
13:16tcrayfordWhich *can* be more interesting
13:18Raynestcrayford: That gardening metaphor needs work. :\
13:18tcrayfordyeah :(
13:19RaynesBesides that, there are some really cool lawn mowers out there. :>
13:19tcrayfordwas kinda implying that lisp was a really cool lawn mower
13:20RaynesIndeed. Lisp would be a lawnmower transformer.
13:20RaynesOptimus Macro.
13:27LauJensen1Raynes: Are you what is commonly referred to as a 'redneck' ?
13:27RaynesLauJensen1: No. My family is from the north. I hardly even have an accent.
13:28LauJensen1Ok
13:29wiligtechnomancy: Trying to add read-line support to swank-clojure, but there is nothing currently as far as I can tell. Here's to mucking things you don't understand!
13:29technomancywilig: that's been my entire strategy so far with swank-clojure
13:29technomancyapparently it used to work (over a year ago)
13:30wiliglol
13:30wilighmm, troubling. then I just don't understand what's going on it here. wish I had the working version.
13:30wilig*in here
13:32wiligwoot! just got it to fail where I expected it to. on the first try no less. progress. :-)
13:32technomancyI'm cheering for you
13:33wiligI'm so in the blind. Wondering what the heck #^ means.
13:34technomancyit's a type hint for the following form
13:34Raynestechnomancy: Thanks for telling me about interactive rebasing. I never would have thought to get rid of the lib files from history. I'm new to gi.
13:34wiligah
13:34Raynesgit*
13:35technomancyRaynes: see also: http://alexvollmer.com/index.php/2009/01/18/meet-magit/
13:35wiligso now to impersonate a bufferedreader
13:37technomancywilig: fyi: swank-clojure uses a lot more type hints than necessary
13:37technomancydon't feel the need to be that explicit in your own additions
13:37wiliggreat! and I plan to add a test or three.
13:39wiligtechnomancy: is there some significance to returning {:tag StringWriter}? Does :tag have some meaning I'm unaware of?
13:41technomancyit's not actually a return value; it tells the compiler that the function is going to return an object of a certain type
13:41technomancythe return value is the form immediately preceeding that
13:41technomancyif the type hints are getting in the way don't be shy about ripping them out
13:41wiligAh, now that is enlightening
13:42wiligwill do, just nice to understand what the heck it means.
13:42technomancyI highly doubt they were added only to performance hotspots as they should be; they seem to be sprinkled liberally all over the place
13:43hiredmanit's hard to imagine slime having performance hotspots
13:43technomancythat too =)
13:43chouserI was just about to say something to that effect.
13:44technomancyswank-clojure is a prime example of "my first clojure project" that was just too useful not to become widely used. every language has 'em. (cough *rdoc*)
13:46technomancynot to knock jochu; I'm really grateful for his work
13:47hiredmanhe is apparently writing another reader
13:48technomancyisn't that joshuachoi?
13:49hiredmanok, there was a j and a ch
13:50kotarakWasn't Chousuke writing something up about a reader? He has at least a working syntax-quote in Clojure.
13:50bpattisonI'm calling a Java method from Clojure that a JNI wrapper to a C function. It takes a single argument, which is an array of double of size 1. I'm assuming that's a JNI thing. If I invoke the routine in Java it works fine, but when I try to invoke it in Clojure is get exception aoubt boxArgs
13:50bpattison at java.lang.Class.cast(Class.java:2990)
13:50bpattison at clojure.lang.Reflector.boxArg(Reflector.java:364)
13:50bpattison at clojure.lang.Reflector.boxArgs(Reflector.java:396)
13:51bpattisonany ideas to try?
13:51hiredmanthat is not the whole exception, feel free to pastebin it somewhere
13:53Chousukekotarak: Actually I ran into so many corner cases in the macro version that I decided to take the same "reader magic" approach as the current reader does.
13:54bpattisonhere's the complete exception http://pastebin.com/m6fe684dd
13:54bpattisonbut I'm not sure its all that helpful
13:59chouserbpattison: what the your line of clojure code look like that's doing the interop call?
14:02Mefachedwill someone send me their ~/.clj_completions ? I can't get this script from the wiki to generate it. easyegoism@gmail.com
14:04MefachedNevermind, I got it to work
14:05bpattisonchouser: (let [minv (make-array Double/TYPE 1)] (.GetMinimum band minv)) where band is a Java JNI class
14:09chouserbpattison: class cast error suggests that .GetMinimum is expecting a different type than what its getting. You're clearly giving it a array of primitive doubles, so perhaps its expecting something else.
14:10chouserbpattison: does your version of clojure have double-array ?
14:11chouserif you use that instead of make-array, and also type hint 'band' if it isn't already, the exception should show you the name of the class it's actually expecting.
14:11bpattisonchouser: yep, I'm running 1.1.0-alpha -- should upgrade to the new release -- but here's the java code that works Double[] min = new Double[1]; poBand.GetMinimum(min);
14:11chouserah!
14:11chouserthat's an array of boxed (not primitive) doubles
14:12chousertry just Double instead of Double/TYPE in your make-array
14:13bpattisonchouser: woo hoo. that worked like a champ -- would have never figured that one out
14:14cemerickcgrand: I've been pondering http://groups.google.com/group/enlive-clj/browse_frm/thread/f9a9f280110d6d2f and it looks like the "functional" approach you outline there will work for us. Does that remain the ideal approach?
14:17Raynesclj-oauth is now on zeh clojars!
14:17RaynesOne more project to go.
14:18LauJensenHow many people would dred using a library which required you to add 5 items to your classpath to work on/with it ?
14:18cemerickLauJensen: that's why some of us are beating the maven horse :-)
14:19konrdoes it really matter if I compile or eval my code (slime-eval-defun vs slime-compile-defun) while developing it?
14:20Chousukekonr: they probably do the same thing.
14:20Chousukesince Clojure has no interpreter.
14:20technomancykonr: the distinction is leftover from common lisp; in clojure they should have the same effect
14:22tcrayfordchouser: liking the infix example at the start of your book. Had never thought about doing that
14:23chouserheh. great. :-)
14:25tcrayfordthough maybe put the operators in proper BDMAS order [/ * + -]
14:25cgrandcemerick: yep, that's still the way I promote
14:25qbgIf I have a loop that concat's and next's on a seq but the total length of the seq never grows large, am I at risk of running out of memory?
14:26RaynesLauJensen: That is exactly why I'm moving these projects to leiningen. ;)
14:27LauJensenRaynes: I'm not talking about when compiled, but about when you fork it etc to hack on it
14:27RaynesLauJensen: Still doesn't really matter. If it's Leiningen, and you use swank-clojure-project, you never have to deal with those 5 items directly.
14:27chousertcrayford: I guess that would be [- + * /]
14:27arohnerqbg: probably not. the real determination of whether you run out of memory is whether you hold the head somewhere
14:28tcrayfordtechnomancy: is it just me, or does disconnecting from swank-clojure mean you can't reconnect?
14:28tcrayfordchouser: the way you've defined it there, yes
14:28cgrandcemerick: I'll wrote some examples as soon as I have more time
14:28qbgGood, then I should be able to TCO my DSL I'm writing.
14:29RaynesLauJensen: But I suppose that applies to Maven as well.
14:30cemerickcgrand: The alternative where one (for example) defines specific element classes that are going to get plucked and dropped into matching slots in a parent template is intriguing. I suspect something like this will be needed eventually -- I worry about managing that composition manually.
14:31RaynesLauJensen: If I don't reply to your next message, it's not because I'm ignoring you. It's because I wont be here in about 13 seconds.
14:31LauJensenOk- thanks for sharing your opinion
14:33polypusi have a list of namespace names each of which contains a single (def specs ...). i'd like to get a list containing the values of each specs. what's the best way?
14:36polypusin file a i have (ns a) (def specs ...) in file b the same. i have '[a b c ...]. i'd like a list of specs by going (map f '[a b...])
14:36stuartsierra(map (fn [namespace] (ns-resolve namespace "specs") list-of-names))
14:36stuartsierraor something like that
14:37polypusty, i'll have a look
14:37stuartsierra(map (fn [ns-symbol] (ns-resolve ns-symbol 'specs)) list-of-symbols)
14:38polypusstuart: thx that's it
14:39ordnungswidrigoauth? nice!
14:44MefachedI can't get M-x slime to bring up Clojure in Emacs. I followed the instructions at http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started and my .emacs is http://pastebin.com/m6e10a365
14:45arohnerI have a big nested data structure (maps and vectors). I want to run a function f on every child node, and return the "updated" structure. Is there a better function to use than for + update-in?
14:45arohnerI want something that does a walk + update-in
14:47stuartsierraarohner: clojure.walk does that
14:48arohnerstuartsierra: interesting. though that seems like a big hammer, and I'd have to distinguish between the nodes I want to change and the nodes I don't
14:48stuartsierraThe function you pass to pre/postwalk has to have a conditional then
14:49stuartsierraYou could also copy the style of walk with more conditions to avoid walking the nodes you don't need to change.
14:51arohnerhrm. in my ideal world, I want a function that I can pass some kind of "x-path" like spec and a function. distinguishing between nodes seems messy.
14:51arohner(update-in-many [:a :b * :foo] f)
14:51stuartsierraarohner: that would be cool, but I don't think it exists. clojure.zip might help
14:52arohnerI might write it...
14:53arohnerstuartsierra: thanks for the help
14:53hiredmanthat soulds awful familiar
14:53hiredmansounds
14:53hiredmanI think there was talking about some kind of wildcard update-in
14:55hiredmanI think it floundered on the "how to represent wildcards" issue
14:55arohnerdoes clojure.zip handle maps?
14:55hiredman* is a symbol that could resolve to something, :* could be a key
14:56hiredmanarohner: it can
14:57hiredmanI would be surprised if there where by default
14:58hiredmanthe "mapping" of a map to a zipper has no, uh, default? immediate? obviouse solution?
14:58hiredmanit depends on the domain of the maps
14:58hiredmanlike xml-zip
14:58hiredmanah
14:59hiredmanthe "mapping" of a map to a zipper has no obvious domain
15:00arohnerk. I'll make this work the ugly way, then see if I can come up with an update-in-many that makes sense
15:03stuartsierrarhickey: When/how will protocols take over clojure.core?
15:04ordnungswidrigtake over?
15:04arohnerordnungswidrig: the whole point of rhickey building protocols was to rewrite the clojure compiler / core in terms of them
15:05lypanovchouser: should i use the manning forum for stylistic corrections? (aka, smoother reading)
15:06chouserlypanov: sure, thanks!
15:06konrwow @ http://bc.tech.coop/blog/081120.html
15:06technomancykonr: stuart halloway added that to swank-clojure so it's built-in now
15:07rhickeystuartsierra: after we get enough feedback on stand-alone implementations of protocols, we can look at moving some of the core abstractions to protocols. But - we need to avoid breaking changes for Java (and Clojure) clients extending the current abstraction interfaces. I think there will be a new protocol (with its new interface) and extension to existing interface
15:08stuartsierrarhickey: So you don't plan on major breaking changes in, say, 2010?
15:08rhickeydid I say that?
15:08lpetithello, there
15:08rhickeylpetit: hi
15:09rhickeystuartsierra: it depends on how far we get. but it would be with a major (2.0-ish) release
15:09hiredmanthe main effect on core.clj seems like it mostly be changing tests for implementing certain interfaces to tests for protocols
15:09stuartsierrarhickey: This is for purposes of the book.
15:10rhickeystuartsierra: which book?
15:10stuartsierrarhickey: Ok, 2.0, that's what I wanted to know.
15:10stuartsierrarhickey: the one that I am theoretically writing with Luke.
15:10rhickeyah
15:11stuartsierrahiredman: It's more than that. Imagine if 'map' is a protocol. Then you can implement a 'map' specific to strings, arrays, maps, etcetera.
15:11rhickeyarohner: a broader goal is really to support, in Clojure, the kinds of things I needed to do to write Clojure itself, such things being useful in general
15:12RaynesProtocols are awesome. I missed typeclasses.
15:13rhickeyheh
15:13hiredmanstuartsierra: I don't believe map would be a protocol
15:14hiredmanseq would be a protocol, and map operates on seqs
15:15rhickeythere would be a protocol for the map data abstraction
15:15hiredmanrhickey: a protocol for map the noun, yes?
15:16rhickeyhiredman: right, but map the verb would still be a fn on seqs
15:17rhickeythere could be a polymorphic mapping fn, but it wouldn't be map, that contract specifies seqs, laziness etc. It can't start returning Strings when given Strings
15:17hiredmanmaking the core seq processing functions into extendable protocols (leaving out the implicit seq transformation) would completely change the language
15:18rhickeyhiredman: not really, the polymorphism is already there for most of those. While there are some manually-handled types, I haven't gotten a request for a new manual handler in over a year
15:19rhickeyit is just a move from interfaces for polymorphism to protocols
15:19rhickeyhiredman: or maybe I misunderstood you
15:19rhickeyyou mean map/filter etc?
15:19lpetitrhickey: just sent my donation through paypal. No pb to add my name on the donators page
15:19hiredmanrhickey: the sequence processing functions are at the core of the user experience of the language
15:19hiredmanrhickey: ys
15:19rhickeylpetit: thanks!
15:20lpetitrhickey: now would you go to ccw's "donate" page and submit the form ? :-p
15:20lpetitrhickey: just joking, of course :)
15:21rhickeyI often get asked about Eclipse support
15:21Rayneslpetit: You need to add auto-indentation already. ;)
15:21lpetitRaynes: ok ok, I know that, and you're right. Don't remember, though : "help welcome" :-)
15:22Raynes:p
15:22lpetitRaynes: I'm currently working on a port of paredit for ccw. Already have been able to code, on my free time, open-round, open-curly, open-square
15:22RaynesNeato.
15:24lpetitrhickey: I don't publish news about ccw releases each time I make one on the ml. I will certainly do when I feel a gap has been filled in some areas (auto-indentation, paredit, faster code completion). Since I know your time is counted, I invite you to only spare it on ccw when you see news about it from me in the ml.
15:24stuartsierrarhickey: what about things like first/second? Could there be an "ordinals" protocol?
15:25rhickeyI think I have a bias against Eclipse - I've never liked it for Java
15:25rhickeystuartsierra: other than the one for nth?
15:26stuartsierrarhickey: Maybe that would be enough. I was thinking about tuples
15:26rhickeyI'd certainly concentrate on replacing the existing interfaces before new inventions
15:26stuartsierraok, fair enough
15:26rhickeystuartsierra: tuples are specialized vectors
15:26rhickeywould satisfy same set of protocols
15:26stuartsierraok
15:27stuartsierraSo basically, anything currently implemented as RT/foo or an interface is a good candidate for a protocol.
15:28rhickeystuartsierra: interfaces first
15:28hiredmananything in a .java file
15:28stuartsierraok
15:28stuartsierrathansk
15:29rhickey42 interfaces in clojure.lang
15:29stuartsierrawow, I didn't realize it was that many
15:29rhickeyClojure really is abstraction-based
15:30stuartsierraI count 47 by grep.
15:31{newbie}I frear that clojure is becoming an OO language
15:31_fogusrhickey: pre-cambrian == pre-defmacro?
15:31stuartsierra{newbie}: not at all; it's becoming something better
15:31{newbie}ppl will start writing java in clojure
15:31stuartsierrathey try to do that anyway
15:31rhickey{newbie}: not by any common definition of OO
15:31ChousukeYeah, I think we'll see an explosion of inappropriate deftype use at first :/
15:32{newbie}rhickey: but the new deftype looks alot like an object
15:32Chousukeuntil people figure out how it really should be used.
15:32rhickeyexcept immutable
15:32rhickeyand no concrete derivation
15:32rhickeyno statics
15:32{newbie}okay
15:32rhickeyno ctor bodies
15:32rhickeyetc
15:33hiredmangeneral usage deftype should be without methods all together, yes?
15:33stuartsierrayes
15:33RaynesSomebody should write a blog post on how it should be used, along with protocols.
15:33rhickeyhiredman: in-place protocol impls are fine
15:34rhickeywhenever the type defininer knows they need to support a protocol, that will be fastest
15:34lypanovchouser: wonderful book. inaction lost me on the 3rd page.
15:34rhickeyextend when you are not the type owner and can't convince them :)
15:35stuartsierrarhickey: Really? deftype with protocol impl's inlined is faster?
15:35ordnungswidrig*lol* googling for "rainbow emacs" gives me: http://tinypic.com/view.php?pic=2urqmgl&amp;s=6
15:35rhickeystuartsierra: yes
15:35stuartsierrainteresting
15:35the-kennyordnungswidrig: Looks like the url isn't working
15:35stuartsierraworked for em
15:36ordnungswidrigthe-kenny: works for me?!
15:36the-kennyordnungswidrig: Ah, sorry. Bug in my weechat plugin for detecting urls
15:36lypanovrhickey: silly random q, do you think clojure refactoring tools could ever rock?
15:36ordnungswidriganyway, does anybody know how to _get_ emacs rainbow parens?
15:37rhickeylypanov: some refactorings, yes. Unlike a lot of dynlangs, in a Clojure ns every name has only one mapping, so rename can work. I think IntelliJ already does this well
15:38stuartsierrarhickey: by the way, did you see my generalized 2-arg-dispatch-protocol macro?
15:38rhickeystuartsierra: yes - very cool!
15:38hiredmanordnungswidrig: http://delicious.com/search?p=rainbow&amp;chk=&amp;context=userposts|clojurebot&amp;fr=del_icio_us&amp;lc=0
15:38stuartsierrarhickey: thanks
15:39lypanovrhickey: (one of the first things that made me even look at clojure was the fact that you noted that you used idea)
15:39lpetitstuartsierra: where is it please ?
15:40ordnungswidrighiredman: thanks. would you mind to update the second link on del? The final period brakes the url
15:40stuartsierralpetit: http://paste.lisp.org/+2023/1
15:41lpetitrhickey: a correct "rename" refactoring would have to know about aliases, wouldn't it ?
15:41rhickeylpetit: yes
15:41rhickeybut doable
15:41lpetitrhickey: so not so easy to make it bullet proof. aliases could be created under the hood via macros ..
15:42rhickeylpetit: right, macros can do things no static analysis can ever see
15:42lypanovit could still warn on textual matches.
15:43lypanov(with heuristics)
15:43lpetitsure, but my point is, it will never allow the same degree of confidence java refactoring tools provide, and thus, I doubt one will use it as extensively as e.g. with java, where aggressive refactoring is quite usual
15:44lypanovi've never worked on a java codebase that didn't require some level of understanding of implication when doing refactors.
15:45lpetitstuartsierra: I was getting confused by the name defdouble, and then the example on numbers :-)
15:45stuartsierraoh yeah, hadn't thought of that
15:45stuartsierraDidn't know what to call it, really.
15:46stuartsierradefprotocol2? defdoubleprotocol? def-2arg-generic?
15:46lpetitlypanov: when seeing a new codebase, it's really common for me to to rename refactorings as I read the code, with total confidence, improving the codebase by the way (at least I hope so! :-) )
15:47Raynesstuartsierra: defstuartsierrawroteaneatdoubleargdispatchprotocolmacro
15:47lpetitstuartsierra: defbiproto :-p
15:49stuartsierradefbi
15:49stuartsierraaddbi, extendbi
15:49RaynesIs there any information anywhere that explains when deftype/defprotocol should be used, and why?
15:49lpetitis it not too connoted ?
15:49stuartsierrathere's some notes on the assembly wiki
15:50stuartsierralpetit: that was a joke, mostly
15:50lpetitok, so it's like in French :)
15:50RaynesNot what I'm really aiming at.
15:51rhickeyRaynes: want to write a fn like seq - use a protocol
15:51RaynesNobody has really written any real world examples yet. Of course, chouser will be doing so in his book.
15:51rhickeywant to use defstruct - use deftype
15:51stuartsierraI wrote some conceptual stuff; at http://stuartsierra.com/2009/12/14/objects-are-not-adts
15:52lpetitstuartsierra: could it be even more generalized to an arbitrary number of n first args dispatch ?N
15:53stuartsierralpetit: I thought about that, and my mind boggled.
15:53lypanovlpetit: i work in web world. where code references eg js / html. or custom sql. or whatever.
15:53stuartsierraJust think, for 3-arg dispatch on N types you need N^3 methods.
15:54lpetitstuartsierra: multimethods use :default for that, no ?
15:54rhickeystuartsierra: don't solve problems you don't have
15:54lpetitarg, no, no default impl for protocols so far
15:54stuartsierra:)
15:54lpetitrhickey: just brainstorming :)
15:54rhickeylpetit: Object works as a default for all but nil
15:54lpetitrhickey: oh yes, remember now, thx
15:55stuartsierraAnd I couldn't think of a case where you would actually *need* 3-argument dispatch.
15:55rhickeyand you can extend protocols to nil
15:55polypusbtw, to anybody reading stuartsierra's post. liskov did a talk at oopsla recently which you can view at infoq
15:56stuartsierrapolypus: got a link?
15:56polypushttp://www.infoq.com/presentations/liskov-power-of-abstraction
15:56stuartsierrapolypus: thanks
15:56lpetitlypanov: don't understand
15:56polypusss: np
15:59stuartsierrapolypus: added link to the post
16:01polypuscool
16:02lypanovlpetit: sorry, busy here. point was, i've never worked on a project before in which i could reliably do refactors without knowing something. but sounds wonderful ;)
16:04lpetitlypanov: ok, sorry, had switched subject in the mean time :)
16:11arohnerlisppaste8: url
16:11lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
16:13lisppaste8arohner pasted "what do you think of update-in-many?" at http://paste.lisp.org/display/93406
16:13arohnerI think this is pretty cool.
16:14stuartsierranice
16:14stuartsierraloses some type information, e.g. vectors become seqs
16:14arohneroh right. I can add an into
16:14stuartsierrajust be careful with lists - they conj backwards
16:17arohnerthat sounds like another function
16:17arohnertype-preserving map
16:17stuartsierraSean Devlin posted "same" on the list, but that's a heavyweight version.
16:18stuartsierraYou only need a handful of tests - clojure.walk shows which ones
16:18chouserhm, maybe just a fn that does (into (empty ...)), but reverses the result if its a list
16:18stuartsierrathat ... should ... work
16:19stuartsierraIf you don't have to handle MapEntry's
16:20stuartsierra(let [x (into (empty y))] (if (list? x) (reverse x) x))
16:21hiredmanor just switch to cons if it is a list
16:21chouser,(class (cons 1 '(2 3)))
16:21clojurebotclojure.lang.Cons
16:21chouser,(class (empty (cons 1 '(2 3))))
16:21clojurebotclojure.lang.PersistentList$EmptyList
16:21chouserhuh
16:21stuartsierracons makes seqs, not lists
16:21hiredman,(binding [conj cons] (into () '(1 2 3)))
16:21clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
16:22hiredmangar
16:22hiredman,(binding [conj (fn [a b] (cons b a))] (into () '(1 2 3)))
16:22clojurebot(3 2 1)
16:22hiredman:|
16:22arohnerstuartsierra: do you have a hint on where to find 'same'? google is failing me
16:22hiredmanwait
16:22hiredmanhmm
16:23hiredmananyway, I just hate to see that reverse
16:23stuartsierraarohner: it was posted to clojure-dev
16:23chouserstuartsierra: well, cons makes Cons', but apparently an empty Cons is a EmptyList. :-)
16:24technomancyany chance we could get dynamic binding enabled on a whitelist basis rather than for all namespaces starting with "clojure"?
16:24arohneroh right, I remember this thread
16:24hiredman,(isa? clojure.lang.Cons java.util.List)
16:24clojurebottrue
16:24technomancyis that something for which I should draw up a patch?
16:24technomancysorry--*direct* binding
16:25stuartsierraI thought direct binding was enabled everywhere unless you specifically disabled it?
16:25hiredman:(
16:25technomancystuartsierra: from a usage perspective it's enabled everywhere for vars that point to fns in namespaces that start with clojure
16:26technomancybut there's no way to turn it off to, say, rebind clojure.test/test-var
16:26technomancywhich is a problem
16:26technomancyless problematically, there's no way to turn it *on* for namespaces in which you want it (other than naming your namespace "clojure-$FOO")
16:26technomancy~ticket #246
16:26clojurebot{:url http://tinyurl.com/ybzjj4e, :summary "direct binding inhibits clojure.test functionality", :status :new, :priority :normal, :created-on "2010-01-14T00:35:44+00:00"}
16:27hiredmanI would rather have opt in than opt out
16:27stuartsierraI see
16:27technomancydefinitely
16:27stuartsierraI thought there was a call-site metadata param to turn off direct binding
16:28hiredmanreally?
16:28technomancyoh, maybe I'm missing something
16:28technomancythat would certainly help
16:28technomancyI was just looking in the compiler where isDirect was set
16:28hiredmanit would be great, if someone who knows about direct binding could write something up on the curret state of same
16:28rhickeytechnomancy: is test-var designed to be rebound?
16:29ordnungswidrigWhat is the best practice for unit tests? I have a separat .clj file which declares the test in the same ns. But now after load-file the files seem to fight for the ns.
16:29technomancyrhickey: it's not specifically, though clojure.test/report is
16:29technomancythe ns docstring for clojure.test suggests rebinding it
16:29stuartsierraclojure.test/report has {:dynamic true} metadata
16:30rhickeytechnomancy: then it is designed to be rebound and can be declared :dynamic true
16:30hiredmanhmm
16:30rhickeythere will be other knobs
16:30technomancyhere's the situation I'm in though: we have some tests that hit the network, and we'd like to skip them for normal test runs and have them be opt-in
16:30rhickeyTBD
16:31technomancyif we could rebind test-var, it's easy
16:32technomancydirect binding in clojure.core gets you real measurable production performance increase. direct binding in clojure.test gets you faster tests, which is nice, but in many cases not worth the loss of dynamism.
16:33technomancyin our case it gives us much slower tests since we no longer have a way of switching off the tests involving network access
16:34lisppaste8lpetit pasted "reinventing the wheel ?" at http://paste.lisp.org/display/93408
16:34rhickeytechnomancy: so the question becomes, should you get that feature by runtime-patching test yourself or adding the toggle capability you want ,to clojure.test
16:34lpetitAm I reinventing the wheel with this function ?
16:34technomancyrhickey: I just think a whitelist approach to direct binding would be wise
16:35rhickeytechnomancy: who owns the whitelist?
16:35technomancyrhickey: since it will now be enabled in things like clojuresque, clojure-http-client, clojure-jna, etc. without the approval of the authors of those libs
16:35technomancyrhickey: a better approach would be to use ns-level metadata, but currently ticket #130 means that won't work with AOT'd namespaces. =\
16:35lisppaste8arohner pasted "map-same" at http://paste.lisp.org/display/93409
16:35ordnungswidriglpetit: how does startslike differ from startsWith?
16:35technomancyrhickey: I think even a whitelist that's hardcoded into Compiler.java would work for the present
16:36technomancyuntil #130 is resolved
16:36lpetitordnungswidrig: startsWith implies a full match on the arg, look :
16:36lpetit,(.startsWith "b" "bar")
16:36clojurebotfalse
16:36arohnerinterestingly, map-same resolves my need for map-keys and map-vals
16:36lpetitwhere (starts-like "b" "bar") returns true
16:36rhickeytechnomancy: I'm not enamored of the whitelist idea, one persons whitelist might not correspond to another's
16:37Chousuke,(.startsWith "bar" "b")
16:37clojurebottrue
16:37ordnungswidriglpetit: hmm, isn't it simply flip . .startsWith ?
16:37rhickeytechnomancy: but my question still stands - isn't this toggle capability a missing feature of test?
16:37lpetithmmm
16:37ordnungswidriglpetit: say, #(.startsWith %1 %2) ?
16:38lpetit,(.startsWith "bar" "bartoldi")
16:38clojurebotfalse
16:38ordnungswidriglpetit: uhm, #(.startsWith %2 %1) I mean
16:38technomancyrhickey: sure; I've considered cooking up a patch to clojure.test to implement it there, but I wanted to try it out for a while in our own project to see how it works in practice first.
16:38lpetitwhere (starts-like "bartoldi" "bar") returns true
16:38Chousuke,(.startsWith "bartoldi" "bar")
16:38clojurebottrue
16:38technomancyit's certainly not a feature that's too specific to our project
16:38Chousukeagain, isn't it just the argument order? :)
16:38lpetityes, but I don't want to know how to order the arguments !
16:39Chousukeso does (starts-like "bar" "bartoldi") also return true? :/
16:39arohnerlpetit: so why not sort by length?
16:40ordnungswidrigarohner: good point!
16:40lpetitChousuke: sure. I need to go to sleep, or tomorrow I'll have to recode everything I'm doing tonight :-)
16:40technomancyI'm really just advocating using direct binding more sparingly for now until it's seen more use and the implications are better-understood.
16:41technomancyrhickey: I figured this note in the code was an indication that you felt the same way: //todo - more specific criteria for binding these
16:41technomancy=)
16:42rhickeytechnomancy: yes, and direct binding is on in order to flush out use cases like yours. In the absence of knobs, it's easiest to turn it off. But ther eis one knob now, :dynamic true
16:42ordnungswidriglpetit: so "bar" "boo" will also return true? Then its a simple equals on the first letter?
16:42rhickeyI'm not going to rush to whitelists
16:42arohnerrhickey: how would you turn off direct binding? re-def'ing?
16:43technomancyok, I guess I can do that with a re-def inside a with-ns call
16:43rhickeyarohner: could be any of: build flags, ns attributes, declarations, whitelists etc
16:43arohnerI mean now, in the clojure.test case
16:43technomancyassuming using vary-meta to add :dynamic won't work since once it's compiled it's too late
16:44lpetitNo, I missed a test case : inverting the args will not work for (starts-like "bar and foo" "bar") (which should return true) :
16:44lpetit,(.startsWith "bar" "bar and foo")
16:44clojurebotfalse
16:44rhickeytechnomancy: you realize the kind ofthing you are doing is subject to random breakage of other things?
16:44technomancyrhickey: well in this case I still call the old version of test-var. I just check a predicate first.
16:45technomancyso the chance for breakage is pretty slim
16:45technomancyIf I were rebinding it to a totally new function that didn't reference the old, then I'd be more worried
16:45rhickeytechnomancy: until someone else does the same thing
16:45technomancysure
16:45technomancyI do think this would be better implemented in clojure.test
16:45rhickeyright
16:45technomancyI'd just like to flush it out in my own code first
16:46rhickey:dynamic true
16:46technomancyyep, will give that a go. thanks.
16:47rhickeytechnomancy: I'm going to try to hold out on turning off dynamic binding in an effort yo flush out more cases like yours, then probably disable until knobs are in place
16:47rhickeyer, direct binding
16:48technomancysounds good. right after a release _is_ a good time for that kind of thing.
16:48technomancyand for the record I like the idea of basing it off ns-level metadata a lot better than a whitelist, it's just not feasible given the AOT-ns-metadata bug right now.
16:50technomancyI'll close out that ticket then.
16:57Mefachedhttp://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Installing_clojure.contrib I built clojure-contrib with ant, but I don't understand what the next line is telling me to do.
16:58tcrayfordyou need to build it with a command line option that has a path to clojure.jar
16:59tcrayfordoops
16:59tcrayfordignore that
16:59tcrayfordthe bit after that is to do with actually launching clojure
16:59MefachedI run Clojure in Emacs, not from a command line
17:00tcrayfordwith swank-clojure?
17:00MefachedYes, I believe so
17:00tcrayfordjust change to a directory that's setup right and launch it then (you want your source code in ./src/ and your tests under /test/
17:01tcrayfordyou can ignore the stuff about startup scripts, they aren't needed if you're launching from emacs (or using lein)
17:02MefachedOK
17:03tcrayfordand that article is kinda old/outdated
17:04tcrayfordcheck out the readme for swank-clojure on github
17:19lisppaste8lpetit annotated #93408 "completed, and now, reinventing the wheel, or not ?" at http://paste.lisp.org/display/93408#1
17:20Qvintvshow can I change a seq of chars to a string? ie, (\a \b \c) -> "abc"
17:20lpetitso, reinventing a function in java, core or contrib ?
17:20hiredmanQvintvs: apply str
17:21Qvintvshiredman: thank you
17:22chouserlpetit: there is subs for .substring
17:23lpetit(doc subs)
17:23clojurebot"([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."
17:24chouserI don't know of an existing fn that does exactly what you've got there.
17:24lpetitchouser: ok, so more java independent.
17:25lpetitchouser: I need this for my parser : brute force lookahead, without having to bother whether the string I'm parsing abruptly finishes without knowing if the match is exact. In doubt, say it matches.
17:25chouseralso saves you from having to hint to avoid reflection, as would 'count' instead of .length
17:25technomancywould it be cool if subs counted negative offsets from the end of the string?
17:25technomancyI got spoiled by that in Ruby and Elisp
17:26chouserpython does negative offsets like that too -- liked it in every language that had it.
17:26chouserbut nothing in clojure does currently, I think?
17:26technomancyI patched up subs to do it at one point
17:26technomancycan't remember if I submitted a ticket for that
17:27chousermaybe nth too. and subvec
17:27lpetitwould make subs have more substance than just being a simple java wrapper :)
17:27technomancylooks like I was a lazy slacker and didn't ticket it =(
17:27technomancychouser: oh, good call
17:28lpetittechnomancy: to which extent did you patch paredit to be more clojure-aware ?
17:28chouserdunno if rhickey would go for it or not.
17:28technomancychouser: dunno about nth though; couldn't that cause unintended realization of lazy seqs?
17:28chouserany negative would have to fully realize the lazy seq
17:29technomancylpetit: I just had to teach it to treat [] and {} as pairs; I think that was all there was to it.
17:29lpetittechnomancy: I mean, when having this "#{ }|" (with cursor represented by pipe | at the end), do you end up if trying to delete } with "#|" or with "" for example ?
17:30lpetittechnomancy: ok, so eventually paredit.clj will beat paredit on clojure support :-p
17:30technomancylpetit: oh, I see. no, it only deals with paired characters.
17:30technomancylpetit: well you certainly have an advantage; you don't have to use elisp. =)
17:30technomancyof course, once I implement a clj-to-elisp compiler, then it won't matter.
17:31chouserwouldn't elisp-to-clj be easier?
17:31lpetittechnomancy: I'm in the process of writing paredit in clojure, for clojure. I make this IDE independent so that eventually everyone can benefit from this.
17:31technomancycool
17:33technomancychouser: well theoretically once clojure is more self-hosted, it would be a lot less work to write a new compiler target for. elisp is pretty huge in comparison.
17:33polypuslpetit: verry nice
17:34lpetittechnomancy: I've rather quickly stopped trying a elisp-to-clojure direct port of paredit.el, too many hooks inside of emacs internals, too many functions with side effects. I finally just copied the commands spec. Currently just have open-* commands, but it's a start :-)
17:34tolstoyIs memoize thread-safe?
17:34hiredmanyes
17:35technomancylpetit: sounds wise
17:35tolstoyEr, hm.
17:35jcromartietolstoy: everything is thread safe as long as it's pure clojure
17:35jcromartieother Java classes can't be guaranteed to be thread safe though
17:35tolstoyAh, okay. the (doc memoize) didn't say much, but I can see that. Oops! ;)
17:35lpetittechnomancy: yes. Then back to coding, I need to handle the case of literal chars I've forgotten in the process :-)
17:37tolstoyjcromartie: Yes, I mess myself up because I'm creating a cache of complied schemas, thus the self-confusion.
17:38chouserjcromartie: almost. there are a few gems like super-proxy that are not thread safe
17:38jcromartieoh really? I haven't heard of it
17:38jcromartiehow can you make pure clojure code non-thread-safe?
17:39chouserer, proxy-super I mean.
17:39Chousukeproxy-super is not pure clojure I suppose.
17:39Chousukesince it very much sounds like Java interop :P
17:39jcromartieyeah
17:39chouserwell, it's used for java interop
17:40chouserbut you could make something similarly unsafe using an atom.
17:41Chousukeeven then, it's at least atomically unsafe :P
17:42chouserheh
17:42arohneryou can always race if you try to do something stupid, like keep two unrelated atoms in sync
18:15lpetitis the clojure 'reader' page up to date according to the special literal characters : \newline, \space and \tab ? Any other that could miss ?
18:16Chousukelinefeed and... hm.
18:17hiredmanhttp://github.com/hiredman/clojure/blob/readerII/src/clj/clojure/reader.clj#L516
18:17hiredman"formfeed"
18:19Chousukeoh, right
18:19ChousukeI always forget them :P
18:23lpetitoh yes, so some are missing in the documentation. Thx hiredman
18:29MefachedWould copying the "contrib" directory in clojure-contrib/src/ to clojure's own src/ be an effective way to add clojure-contrib? I can't get it to work any other way.
18:32hiredmanMefached: because it would put everything in the same place on the classpath
18:43tcrayfordis there a function to cast a string to a regex?
18:44hiredmanthat is not a cast
18:44hiredmana string is not a regex
18:44tcrayford:/
18:44tcrayfordto turn a string into a regex then?
18:44hiredmanthere is a function to create a regex pattern from a regex
18:45hiredman(doc re-pattern)
18:45clojurebot"([s]); Returns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher."
18:45tcrayfordalready found
18:46tcrayfordneeded the right search term (find-doc "re") ain't exactly helpful
19:46tolstoyI wonder why schema validation in the JDK ain't thread safe. Seems kinda, well, unfortunate.
19:46tolstoyMaybe the thought is that if you have lots o threads, you're a transaction processor, and you shouldn't be validating (to slow) in the first place.
19:55ndimidukI have a dumb noob question: what undoes (str 'foo) ?
19:55ndimidukso, given a string, return that string as a symbol
19:55tcrayford,(str 'foo)
19:55clojurebot"foo"
19:55dabdwhat is the most widely used build tool for clojure? maven or leiningen?
19:55tcrayfordlein is built on top of maven
19:56ndimidukoh wait, there's (symbol "foo")
19:56tcrayford,(str (symbol "foo"))
19:56clojurebot"foo"
19:56tcrayfordI like lein, but depends what you want
19:58dabdleiningen seems easier to use but lacks detailed documentation. maven is harder to learn but has more documentation
19:59tcrayfordlein is so damn easy to use, there's barely any need for documentation
19:59tcrayfordjust make sure your dependancies are in project.clj, run lein deps before you do things and you're good
20:01dabdyes if i want to learn the syntax of defproject i have to look at the source code since the options are not fully documented
20:01tcrayfordwhat options do you need/care about?
20:02tcrayfordthey probably could be better
20:02dabdall the options for ex. :dependencies
20:04tcrayfordas far as I can see you just pass dependancies a vector that's configures in the right way and you'll get your deps (assuming their in the mvn repo or on clojars)
20:06alexykcan I break a list to pattern-match like, non-working: (let [[x:xs] [1 2 3]] (print x)) ?
20:07tcrayfordwhat are you wanting x to be out of that result?
20:07alexykx is (first s), xs is (rest s)
20:08alexykI wonder how can I mimic haskell/ocaml's breakup on LHS
20:08tcrayfordyou can probably get that from :as
20:08fanatico,(let [[x & xs] [1 2 3]] (print x xs))
20:08clojurebot1 (2 3)
20:08tcrayfordooh, hadn't realised that
20:08tcrayfordthat's nice
20:09alexykgreat! So when writing a defn which does something for x & xs, and something else for x, and still else-thing for [], can it be separated by arity using this trick?
20:10fanaticoyup
20:14alexykhow do we separate bodies for different arities?
20:15fanatico(defn f ([x] ...) ([x y] ...))
20:15powr-tocdoes anyone know how to get "lein repl" to accept arbitrary directories on the classpath, without mavenizing them?
20:16tcrayfordyou can probably hack ground with the lein script itself to get that
20:16tcrayford(the bash script)
20:17powr-toctcrayford: yeah... is that a great idea though?
20:17powr-tocI'd rather lein itself supported an arbitrary lib option
20:17fanaticoalexyk: I was wrong about pattern matching differentiating between x and []. You're going to want to start with an (if (seq x) ...)
20:17tcrayfordpor-toc: probably not. I've done it to customize java.library.path
20:18tcrayfordpowr-toc: put an issue on lein's repo then
20:18powr-toctcrayford: yeah, but java.library.path is pretty different to the classpath
20:19powr-toctcrayford: where's the bug tracker? github?
20:19tcrayfordyep
20:19tcrayfordat least that's where I'd put issues. Otherwise maybe the google group
20:20tcrayfordyeah looking at the lein source, you could pretty easily add a $CLASSPATH: onto the front of its classpath definition
20:20powr-toctcrayford: I know... but ideally would it not come from project.clj?
20:21tcrayfordor that
20:21alexykfanatico: alas, no ocaml emulation just yet :(
20:21tcrayfordsomething like a :classpath option
20:21powr-toctcrayford: because as far as I'm concerned project.clj should become the spec for building and running the project, with it's classpath...
20:22tcrayfordyeah agreed on that
20:22tcrayfordI'd like project.clj to support library path as well
20:22tcrayfordit feels pretty bad to be hacking around with a bash script (both for dev and deployment)
20:23powr-toctcrayford: that's my other issue with lein... it has a :library-path option, but I don't think it means java.library.path... but then it doesn't seem to work like classpath either...
20:24fanaticoalexyk: you might want to look at http://www.brool.com/index.php/pattern-matching-in-clojure
20:24tcrayfordI think its :library.path option is to change what you usually have under /lib/
20:25powr-toctcrayford: yeah... I know... i was hoping lien would support the various dev, deployment and staging environments you might need, within project.clj
20:26powr-toctcrayford: I think it is too... which seems analagous to a significant part of the runtime classpath.... but it doesn't seem to allow multiple options etc...
20:26alexykfanatico: yes, thankx!
20:26tcrayfordaye
20:26tcrayfordI think most of the things I'm doing can be done with swank-clojure from a directory anyway
20:27tcrayfordand swank-clojure has a set-java-library-path option
20:28powr-toctcrayford: I thought lien would solve my dilema of having to configure a different classpath/clj-shell-script for every project I run within slime and then deployment etc... sadly it doesn't seem to quite fill that hole :-(
20:28tcrayfordit can if you're doing simple stuff, or your dependancies are all found on clojars/mvn
20:31powr-toctcrayford: that's the problem though... my dependencies are proprietary... and I don't want to have to install them all with maven...
20:31tcrayfordaye :/
20:32powr-tocSadly I need very explicit control over the classpath :-(
20:32tcrayfordit's probably not that hard to write a patch for lein that supports :more-classes or summat
20:36powr-toctcrayford: true... except I think add-classpath is deprecated in clojure, and I wouldn't want to force startup of another JVM to kickstart the apps JVM (as commons launcher does)
20:36powr-tocand having it in the bash/bat script sucks
20:37tcrayfordjust patch lein and submit the patch then?
20:37tcrayfordbut yeah, java's build stuff is annoying
20:38powr-toctcrayford: I don't have any objection to submitting a patch... I just don't know *how* best to do what I want
20:38tcrayfordso try some ideas in git branches
20:41powr-toctcrayford: git branches smanches... my problem is I don't currently know how to go about extending the classpath for lein without screwing with either the bat/sh file (a crap inadequate solution) or getting into java classloader nonsense which is full of lots of wierd stuff...
20:42tcrayfordaye
20:42powr-tocI was hoping someone else, would be more familiar with this than me
20:42tcrayford(definitely not me)
20:42tcrayfordtalk to technomancy next time he's on
20:42powr-tocotherwise I would've just patched it...
20:42tcrayfordgotcha
20:42powr-tocanyway I've added an issue on github
20:44powr-tocit's not that I'm completely ignorant about classpath stuff... it's just I've heard mention that clojure does something odd with the classloaders... which I'm guessing is why (add-classpath was deprecated)... can anyone enlighten me here?
20:44powr-tocs/classpath/class-loader/
20:51alexykwhat's the shortest way to refer to + in (reduce ??? [1 2 3]) to sum the vector?
20:52tcrayford(reduce + [1 2 3]) ?
20:52tomojhard to get shorter than that
20:52alexykwow
20:52alexykI thought I need lambdaisms
20:52tomoj,+
20:52clojurebot#<core$_PLUS___4745 clojure.core$_PLUS___4745@16de797>
20:52alexykcrysta;-clear
20:52alexyk\
20:53alexykmeaning crystal-clear)
20:53tcrayfordI did that a lot a while back, using anonymous functions where I didn't actually need them at all
20:53tomojclojure is a lisp-1 oslt
20:53tomoji.e. you can refer to functions by their names just like any other value
20:53alexykhow does the same namespace for functions and values affect the ability to use + as itself?
20:54tcrayfordgive an example useage
20:54tomojin CL I believe it would be something like (reduce #'+ ...)
20:54alexykah, i.e. lisp-2 is something even more perverse
20:54tomoj(except with whatever they call reduce instead)
20:54alexyks/even more// :)
20:55tomojof course this means you have to use clever names sometimes
20:55tcrayfordadd :P
20:55tomoje.g. list is a bad name for a list variable
20:55tomojor seq for a seq
20:55tcrayfordso use coll for a seq
20:55tcrayfordiirc
20:56tcrayfordProgramming Clojure has a nice table of variable names
20:56fanaticolisp-2 is only really necessary with dynamic scope. if you screw up, it's prety easy to see.
20:56tomojyeah I was about to mention that
20:56jcromartieStuart's article featuring Liskov and CLU is a great read
20:56tomojI should dig that out and paste it somewhere
20:56tcrayfordalready on it
20:56tomojdon't we have dynamic scope, though? with vars
20:57jcromartieClojure really is speeding away from Java at an incredible rate.
20:57tomojjcromartie: you mean towards clojure-in-clojure?
20:57jcromartieheh
20:57jcromartieI mean it was leaps and bounds ahead when 1.0 was ready...
20:58jcromartiebut protocols and datatypes... wow
20:58tomojah, yeah
20:58tcrayfordhttp://gist.github.com/277709
20:58tomojtcrayford: thanks :)
20:58fanaticokinda. let (which is what you'll be using 99% of the time) uses locals, and binding (which uses vars) is only used when you want to affect dynamic scope.
20:58jcromartiecinc is interesting but I'm not so sure I'd be using Clojure on other platforms too often
20:58tomojhmm, val is a clobber
20:58devlinsftcrayford: don't forget pred
20:58tomojbut the val function is rarely used I guess
20:58tcrayforddevlinsf that's straight out of the pragprog book
20:59devlinsfoh, n/m
20:59tcrayfordbut I'll add that in as well
20:59jcromartieI mean Clojure on llvm or CLR would be cool, but Java just has so much stuff going on it's hard to give up the libraries
20:59tcrayford(mostly because I'll probably use that as a reference for myself)
20:59tomojjcromartie: yeah it seems like it would split the library community
20:59devlinsfjcromartie: ClojureCLR already is in progress
21:00tcrayfordthe thing that I like about cinc is that it means clojure can be written faster
21:00tomojbecause for any particular library that uses interop, it'd have to be written using your interop
21:00tcrayfordless farting about with java
21:00jcromartieyeah
21:00tcrayfordand probably more easily modifiable by some people
21:00tomojunless there is a good abstraction over the available interop? seems like a hard thing to do...
21:00tcrayfordaye
21:01tcrayfordI think things devved in clj will have to stay on their respective platforms
21:01jcromartiethat's too bad
21:01jcromartiealthough it might mean more pure-clojure libraries
21:01jcromartiewhich would be great
21:01tomojmaybe someday we will have enough of our own stuff that interop is unnecessary :)
21:01jcromartieheh maybe
21:01tomojbut that means for me writing whole new server libraries etc :/
21:01jcromartiethen cinc on llvm will be perfect
21:01tcrayfordmight be a loooong time coming them
21:01jcromartieyeah
21:02tcrayfordand I wouldn't be surprised if a better language came out before that point
21:02tomojjava's library is currently a great boon
21:02tomojI wonder, what is wrong with haskell? has rhickey ever commented on it? I guess the problem is bad same-process concurrency?
21:02tcrayfordit has stm
21:03tcrayfordand no proper mutable state
21:03tcrayfordiirc
21:03tomojyeah, that's what made be wonder
21:03tcrayfordnot a lisp though
21:03jcromartieThe problem with Haskell is that I don't know enough math.
21:03tomojah, yeah
21:03tomojI got the sense that rhickey didn't care a whole lot about static vs. dynamic typing
21:03tcrayfordthough writing a lisp interpreter in haskell is pitifully easy
21:03tcrayford~200 lines
21:03clojurebotexcusez-moi
21:03tomojexcept maybe haskell's type system is broken?
21:04jcromartiethe type system is great but it's just not a good environment to build things in
21:04jcromartieyou can build great rock-solid programs
21:04tcrayfordand haskell is focussed at not being a practical language
21:04jcromartiebut they are generally going to be pretty isolated
21:04jcromartieit's amazing how long Haskell has been around without catching on
21:04jcromartieit's as old as Java
21:04tcrayfordhey, how old is python
21:04tomojI think the math complaint is relevant
21:04tomojbut I like math :D
21:05tcrayfordmonads still confuse me (and many others)
21:05tomojstruggling to find a reason to stay with clojure for some work
21:05tcrayfordas opposed to haskell?
21:05tomojyeah
21:06tomojwell, and erlang, but I'd be using that anyway alongside clojure
21:06jcromartieHaskell 1.0 was defined in 1990
21:06tcrayfordyeah tis pretty old then
21:06jcromartietomoj: struggling?
21:06tcrayfordit depends on the problem space and your familiarity mostly
21:06powr-tocjcromartie: perhaps, but it's an academic language and community without a great interop story... clojure being on the JVM with awesome Java interop seems more likely to succeed, what with less maths and the easier sell
21:07jcromartieheh yes
21:07tomojI like lisps a lot and I particularly like clojure
21:07tomojbut haskell is recently making me very interested
21:07jcromartieClojure is the best. lisp. ever.
21:07jcromartieIf I may use an annoying typographic trend...
21:07tcrayfordits the best lisp I've used (so far)
21:08powr-tocand erlang... though a great language... again lacks enough library interop to be acceptable to industry beyond it's admitedly growing niche...
21:08jcromartieI've tried various CLs and Schemes
21:08jcromartiebut clojure is like rocket-powered lisp in terms of just getting shit working
21:09jcromartiethanks to interop
21:09tomojthat niche is right where I'm at :)
21:09powr-toctcrayford: I've been interested in lisp for many years... but clojures the first one I considered really learning and doing anything...
21:09powr-tocim
21:09powr-tocs/im/in
21:09tcrayfordyep
21:09tcrayfordabout the same here
21:09tomojsame here
21:10tomojexcept I don't have "many" years perhaps
21:10tcrayfordI've read the first chapter of sicp, and the first 15 chapters of on lisp
21:10tcrayfordand disliked common lisp enough to run away from it
21:10tomoj(since I only started programming 6 years ago or so.. :( )
21:10tcrayfordI started programming less than a year ago
21:10powr-toctcrayford: Common Lisp and Scheme always seemed impractical
21:11tomojI wonder if rhickey has commented anywhere on haskell's stm
21:11alexykwhere's the error here, it's checking that a sequence is increasing:
21:11tomojso we have 3 people at 3 different timescales making the same progress from general lispy interest to love of clojure ?
21:11tomoj:D
21:11alexyk,(let [[x & xs] [1 2 3]] (-> xs (reduce (fn [[r x] y] [(and r (< x y)) y]) [true x])))
21:11clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector$ChunkedSeq cannot be cast to clojure.lang.IFn
21:11powr-toctomoj: well I guess I don't have many years either... interest and "learning/doing" are very different
21:12tcrayfordconfirm that powr-toc
21:12jcromartiethe CL hyperspec is like stepping through a gateway into 1995 or something
21:12tcrayfordmore like 1987
21:12alexykthis works:
21:12jcromartieit's kind of awesome in that way
21:12alexyk,(let [[x & xs] [1 2 3] [r _ ] (reduce (fn [[r x] y] [(and r (< x y)) y]) [true x] xs)] r)
21:12clojurebottrue
21:12jcromartieI like the aliased two-color graphics
21:12tcrayfordI think common lisp is actually older than I am
21:12alexykbut I wonder what's wrong with the above -> form
21:13fanaticoalexyk: ->>
21:13alexykah! arrgh
21:13qbgThe hyperspec is part of the simpler, more refined web
21:13fanatico-> is thread-first, ->> is thread-last
21:13alexykit's been a few days
21:13tcrayford-> and ->> really confuse me
21:13tomojusing -> or ->> seems strange to me there
21:13tomojsince there's just the thing and one thing to do to it
21:13alexyktomoj: we need to extract the result from the tuple
21:14jcromartiewhat are people doing to set up Java and clojure stuff on OS X?
21:14alexykafter a long reduce, a first or (... 0)
21:14jcromartiei.e. where do you put it all?
21:14powr-tocclojure is my first commitment to lisp... except maybe a brief fling with emacs-lisp which was more out of a desire to use emacs, than learn lisp... though I have to admit, emacs being implemented in lisp was a factor in me choosing emacs over vim... as lisp felt like something worth knowing vim's config language didn't.
21:14jcromartieI have a ~/src
21:14alexykhence ->> seems useful for decluttering/suffixing
21:14tomojpowr-toc: exactly on emacs vs. vim for me as well
21:14tomojalexyk: ok, I'll take your word for it
21:14tomojI haven't understood your code yet :)
21:14alexyktomoj: :)
21:14qbg->> is a poor man's concatenative code
21:14jcromartieemacs is like Eclipse to me... it's an development-environment-development-environment
21:15alexykqbg: what's the rich man's?
21:15tomojlike eclipse, except usable (to me)
21:15qbgalexyk: I'm trying (key word there) to work on it
21:15tomojcan't haskell do that stuff fairly well?
21:15alexykqbg: ah!
21:15tomojconcatenative I mean
21:16alexykGuy Steele btw is doing some weird Fortress, in case folks think time goes back to Lisp
21:16tomojoh, I don't think I understood what "concatenative" means
21:16alexykand he got really cure math symbols a la Mathematica
21:16alexykcute
21:16tomojI saw his talk about that
21:16jcromartieForth :)
21:16powr-tocnot an eclipse fan either... I prefer netbeans... but even then despite being a java developer I've never bothered myself to build anything for either... java's too clunky to take home.
21:17tcrayfordalexyk, is that code just checking that a collection is increasing?
21:17tomojseems like it was targeted for scientific computing, right?
21:17alexyktomoj: exactly
21:17jcromartie"Java is too clunky to take home." great quote
21:17alexykwhat do you mean just? should it play a violin, too? :)
21:17alexykor is it too verbose? :)
21:18tcrayfordtrying to see if I can come up with a simpler way of doing it
21:18tcrayfordseems very complex
21:18jcromartieJava is just no fun, alexyk
21:18powr-tocalexyk: it's too clunky... verbosity I can live with... if it has utility
21:18jcromartieit's C in a polo and khakis
21:18alexyktcrayford: I do everyting with reduce's. Shorter versions welcome! :)
21:18jcromartieit's C++ with its balls cut off
21:18tcrayfordI dislike having to learn java at college :/
21:19tcrayford(let [sorted (sort < [1 2 3])]
21:19tcrayford(= sorted [1 2 3]))
21:19tomoj,(every? (fn [[x y]] (< x y)) (partition 2 1 [1 2 3 4 5]))
21:19clojurebottrue
21:20powr-tocjcromartie: alexyk: I personally don't like beating on Java too bad... It's too fasionable these days :-) ... Java's clunky, reliable and built to survive the next trillion years... just like everything Sun ever made!!!
21:20tcrayford,(let [sorted (sort < [1 2 3])] (= sorted [1 2 3]))
21:20clojurebottrue
21:20jcromartieyes, it's fine... it's just insipid
21:20jcromartieflavorless
21:20alexyktcrayford: no sorting. :)
21:20tomojI think I made a cute name for (partial partition 2 1)
21:20alexykthink 10000000 tweets' timestamps :)
21:20alexyk...000...
21:21tcrayfordoh ok
21:21alexykyou guys mostaken me for some Java advocate or something. I hate Java with a passion, FTR.
21:21tomojhmm, could also do (map vector (seq coll) (next coll))
21:22tomojis there a clearer way to write that, I wonder?
21:22alexykI prefer OCaml, but JVM lets me plug in into some libs :)
21:22alexykalthough it's damn slow, so I wanted to see if Haskell is a speedup :)
21:22jcromartieI'm not saying I hate Java or anything. The libs are great. It's just dull! That's why Clojure is great.
21:22powr-tocI guess I don't like bashing on Java, because half the developers I know only know .net, and somehow think it's massively better than java.... When I say Java, I mean the java language and c#... not the JVM or Java eco system :-)
21:23tomojalexyk: are you doing data mining on twitter?
21:23alexykjcromartie: well, I hate verbosity, and Blah someBlah = new BlahstyBlah(new BlashphetyBlah...)) is horrible, horrible abomination.
21:23alexyktomoj: yes
21:23jcromartieoh man
21:23jcromartiethen you'd hate Objective-C :)
21:23tcrayfordhaha
21:23fanaticohaha
21:23tcrayfordand cocoa
21:24jcromartieFoo *foo = [(Foo *)[Foo alloc] initWithBar:bar bat:bat]];
21:24alexykthere's MacRuby :)
21:24jcromartieyes, the cast is sometimes needed
21:24tomojalexyk: I'm interested in that problem
21:24tomojalexyk: for academia?
21:24tcrayfordpyobjc even more
21:24qbgGiven the horrible Java code I've seen, I'm just glad it's not C++ code.
21:24alexyktomoj: yes, for now :)
21:24powr-tocqbg: lol
21:24tomojalexyk: you got a firehose, right? how do you go about getting one of those?
21:25alexyktomoj: we don't get it, no need for it for now, gardenhose is ok
21:25tomojsome of the ideas I'm thinking about with haskell now tie into that sort of thing and I'd like to test them out
21:25tomojthanks, I'll look into the gardenhoses
21:25tcrayfordiirc the twitter people have done some data mining with clojure recently
21:26powr-tocI think after a lot more time with clojure, the next languages I want to dig into are Ocaml, Haskell and more Prolog.... oh and I'd like to return to factor.
21:26tcrayford(just for kicks)
21:26beutdeuceIf i have a list of strings ("clojure" "is" "cool") and a list of identifiers (:word :word: :word), how do i create a map {"clojure" :word "is" :word "cool" :word} ?
21:26tcrayford,(doc zipmap)
21:26clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
21:26tomojtwitter data mining will just be a demo application for what I'm working on, I don't think I can use clojure :(
21:26alexyktomoj: you mean data mining twitter in haskell?
21:27tcrayford,(zipmap ["clojure" "is" "cool"] (iterate :word))
21:27clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$iterate
21:27tomojalexyk: yeah
21:27beutdeucetcrayford: it ends up returning {("clojure" "is" "cool") :word}
21:27tomojwell, maybe with erlang's help
21:27tcrayfordwoops
21:27tomojbut the business logic in haskell
21:27jcromartieack
21:27jcromartieclojure + erlang + haskell, seriously?
21:27tomojno clojure, probably
21:27jcromartieyou should be fine with one of those
21:27tomojI like it but I don't think I can afford it
21:28tcrayford,(zipmap [ "clojure" "is" "cool" ] [:word :word :word])
21:28clojurebot{"cool" :word, "is" :word, "clojure" :word}
21:28tomojyeah erlang alone might be OK but I like what haskell can do for some stuff (which clojure, though more friendly, can't, I'm afraid) :)
21:28tcrayford,(zipmap [:word :word :word] ["clojure" "is" "cool"])
21:28clojurebot{:word "cool"}
21:29headiushey, how do you specify multiple overloads for a given method to be gen-class'ed
21:30powr-toctomoj: Curious, what can Haskell do that clojure can't?
21:30beutdeucetcrayford: doesnt work for me when i do (zipmap ("clojure" "is" "cool") (repeat :word)), cause i get {("clojure" "is" "cool") :word}
21:31powr-toctomoj: the type system?
21:31tomojpowr-toc: yeah
21:31fanaticobeutdeuce: quote the list
21:31tcrayfordor use a vector
21:31qbg,(zipmap ["clojure" "is" "cool"] (repeat 3 :word))
21:31clojurebot{"cool" :word, "is" :word, "clojure" :word}
21:31tomojpowr-toc: extra assurance imo about what _exactly_ the code is doing
21:31fanatico,(zipmap '("clojure" "is" "cool") (repeat :word))
21:31clojurebot{"cool" :word, "is" :word, "clojure" :word}
21:32tcrayfordiirc its a bit more idiomatic to use a vector
21:33powr-toctomoj: I've never used a language with such a damn-strong type system... is it just the scope for catching... I mean err proving the absence of certain errors that helps... or is it more?
21:33beutdeucewell, the thing is that i am actually doing (zipmap (list tokens) (repeat :word)) where tokens is a seq of split strings
21:34beutdeucenvm
21:34beutdeucegot it
21:34powr-tocand what problems are best solved by a language with a strong type system?
21:34fanaticoif tokens is already a seq, (zipmap tokens (repeat :word))
21:34beutdeuceseq is already encapsulated
21:34fanaticopowr-toc: parsers.
21:35tcrayforddoes clojure have anything like haskell's parser combinators?
21:35headiushmm
21:35headiusI'm not finding an examples of generating classes with overloaded methods
21:36powr-toctcrayford: http://github.com/joshua-choi/fnparse ??
21:36tomojsomeone should write a good tutorial for fnparse I think
21:37fanaticotcrayford: there are libraries (and it's easy enough to write one yourself using clojure.contrib/monads) but it doesn't feel as elegant.
21:37tomojmaybe I'm just too stupid, I couldn't understand it when I looked at it
21:38hiredmanheadius: I don't think there is a mechanism for that, you have to take care of it in the implementing functions
21:38headiusdang
21:38headiusI'm trying to find a way to avoid that situation in my class generation for jruby
21:38technomancyyeah, unfortunately I don't think that's hooked up in the compiler yet
21:38hiredmantechnomancy: eh?
21:38technomancyhiredman: I don't think it's been ruled out for the future, has it?
21:39headiusprobably via something like def_java "String foo2(String, int)" => :foo_string_int
21:39hiredmantomoj: actually fnparse is about to go through it's third big architectural change
21:39headiushiredman, technomancy: so currently, if you specify multiple signatures, they all generate but dispatch to the same function?
21:40tomojhiredman: oh, great, I thought it was dead
21:40hiredmanheadius: you only spec signatures for stuff you are extending
21:40technomancyheadius: maybe in gen-class; in regular fns I think it's an error to specify multiple signatures that have the same arity
21:41headiusI'm talking about gen-class
21:41hiredmansure
21:41powr-tocwhenever I read anything about monads I simultaneously come away feeling I've realised some fundamental property of programming... akin to maybe zen enlightenment... but I also feel like I'm more confused and don't understand anything...
21:41technomancyI suspect the way gen-class methods are fed functions means the same limitations apply there
21:41wiligugh, fighting swank-clojure but it's a losing battle at the moment. keep wondering if it really needs to be this complex. slime is a really simple protocol.
21:41hiredman:methods adds method signatures, you don't specify signatures for already existing methods
21:41technomancywilig: it's certainly accumulated over time
21:41fanaticotcrayford: I worked through http://www.cs.nott.ac.uk/~gmh/monparsing.pdf, translating the examples to clojure. I found it helped a lot.
21:41headiuslet me put it more simply
21:41hiredmanit just looks for vars in the current namespace
21:41technomancywilig: I've pondered a from-scratch rewrite, but I'm not currently brave enough
21:42headiusif I want to gen-class a new class that has multiple overloads, is it possible
21:42technomancywilig: the swank-clojure is a pretty literal port of the CL version though
21:42powr-tocUltimately I'm sure I don't grok monads at all...
21:43wiligtechnomancy: I understand. The from scratch rewrite sounds appealing and I'm sure it would be a decent way to learn clojure. But ugh, my head hurts.
21:43hiredmanheadius: gen-classed methods just distpach to the clojure function with that name
21:43hiredmanso (.foo bar) will look for -foo in hte namespace implemnting bar
21:44hiredmanand -foo is responsible from there on out
21:44technomancyso in the end it comes down to a limitation of fns
21:44headiusok, that doesn't really answer my question either
21:45headiusperhaps what I'm getting is that you can't do overloads
21:45technomancyyes
21:45hiredmanyou can, but not as a mechanism in gen-class
21:45wiligas far as I can tell, which isn't very far. In order to get read-line working I need to send emacs a read-string message, but I can't find that anywhere in the swank-clojure sources. /sigh
21:46technomancy,(fn ([#^String a]) ([#^Boolean a]))
21:46clojurebotjava.lang.Exception: Can't have 2 overloads with same arity
21:46headiusso putting it a different way: you can't generate a completely new class entirely from clojure code that presents multiple different overloads of the same method name
21:46hiredmanso if you actually want to do it in clojure, I can tell you how, but if you just are looking for a technique to apply else well, there isn't one
21:46hiredmanheadius: hmmm
21:46hiredmanah I understand
21:46headiusright
21:47hiredman"The generated class automatically defines all of the non-private
21:47hiredmanmethods of its superclasses/interfaces."
21:47hiredmanguess it can, just not how you want
21:47headiusthat's an intriguing decision in itself
21:47headiusI assume that means it generates them all with logic to call the fn of the same name if it exists, or super otherwise
21:48headiusI have considered a similar approach for jruby's generated java classes
21:48headiusbut yes, it doesn't sound like it's possible to create overloads unless they come from the parent class/interfaces
21:48chouserheadius: yes, that's what is generated. It means you can add, change, remove method defintions dynamically.
21:49hiredmanheadius: uh, if it;s not from the parent class/interface, how is it an overload?
21:49hiredmanyou can use :methods to add more method signatures
21:50headiusoverloads are not overrides
21:50headiusI think you are confusing the two
21:50headiusoverload = same name, different signature
21:50hiredmanok, then you can use :methods
21:50headiusoverride = same name and signature as parent class method, replacing it
21:50hiredmandefine a new signature
21:50headiusok
21:50hiredmanthe resolution to implmenting fn will be the same
21:51headiusso you can have multiple entries in :methods for the same fn name
21:51headiusand all overloads will dispatch to the same fn
21:51headiusno way to specify one overload goes one place and another goes another place?
21:51hiredmanor multifn or multimethod
21:52technomancyyeah, a multimethod would get the same functionality, but from a bytecode level has nothing to do with an overload
21:52hiredmanhmmm
21:52hiredmantechnomancy: sure, but the overload is there thanks to the signature in :methods
21:52headiusmultimethod still represents a single entry point but then chooses a different body based on the actual types/arity?
21:52headiusso all the overloads would dispatch to the multimethod, and it would re-branch
21:53technomancyheadius: based on an arbitrary dispatch function
21:53headiusok
21:53technomancyyes
21:53hiredmanheadius: yes
21:53headiusthat's closer, certainly
21:53headiusthat's how you'd do it in ruby as well, but not through any explicit mechanism
21:53headiuscase arg; when String; ... when Integer; ....
21:54chousergo go gadget protocol
21:54hiredmanchouser: :D
21:54headiusI'm hoping to provide a way to route different overloads *actually* to different methods
21:55headiusbut it's good to know clojure doesn't handle that yet either
21:56headiusif anyone's interested, I have this at the moment for a prototype class generator:
21:56headius(for jruby)
21:56tcrayfordchouser: liking that the joy of clojure has a style guide in it
21:57headiushttp://gist.github.com/277771
21:57headiusrough sketch
21:57chousertcrayford: great!
21:58technomancyheadius: interesting. so "signature" prepares the compiler for the next call to def? or is it for all further calls to def like private/public?
21:58headiustechnomancy: yes
21:59headiusthis is all pulled out of the code statically
21:59headiuspublic/private would work the same way, setting a flag at compile time
21:59technomancycool
21:59headiussignature would be a no-op at runtime
22:00headiusthe basic logic would be to generate a really slim stub class that loads the associated script code, ties itself to the ruby class, and then proceeds
22:00headiusthe logic for each Java method just does a dyncall to the ruby version
22:02alexykok what's the prettiest way to convert a list of pairs to a plain vector, filling blanks by 0? ([0 12] [1 23] [3 65]) => [12 23 0 65]
22:03alexykthe first elements are indices, 0-based
22:04hiredmanthat makes no sense
22:04hiredmanhow is there a blank?
22:04headiushmm
22:04alexykhiredman: the pairs is a sparse vector representation. sorry, blank means we have a gap
22:05alexyk[0 x] [1 y] [3 z] => [x y 0 z]
22:06technomancy,(let [l '([0 12] [1 23] [3 65]) m (into {} l)] (reduce #(conj %1 (m %2)) [] (range (inc (first (last m))))))
22:06clojurebot[12 23 nil 65]
22:06technomancyjust add an (or (m %2) 0) into the #() form
22:07hiredmanerm
22:07hiredmanwhat is with the into?
22:07qbgWouldn't (last l) be safer?
22:08technomancyqbg: yeah, that's what I meant; typo
22:08hiredmanand if there is a reason for the into, you should use a sorted-map
22:08alexykinteresting...
22:08hiredmanand still unconvinced of the need for the into
22:09qbghiredman: Big O?
22:09technomancyhiredman: you can't use nth to look up things in l because it's sparse, so I don't see how else you'd look up the value for a given index
22:09technomancyI mean, without traversing l every time
22:09technomancysure, it's an optimization
22:10technomancyalexyk: just don't ask for a lazy version =)
22:10hiredman,(let [l '([0 12] [1 23] [3 65]) v (repeat (count l) 0)] v)
22:10clojurebot(0 0 0)
22:10alexyktechnomancy: nothing lazy here :)
22:12hiredman,(let [l '([0 12] [1 23] [3 65]) v (repeat (count l) 0) f (fn [v [k v’]] (assoc v k v’))] (reduce f v l))
22:12clojurebotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.Associative
22:12hiredmanerm
22:12hiredman,(let [l '([0 12] [1 23] [3 65]) v (vec (repeat (count l) 0)) f (fn [v [k v’]] (assoc v k v’))] (reduce f v l))
22:12clojurebot[12 23 0 65]
22:13qbg,(let [l [[0 12] [1 23] [3 65]]] (reduce #(assoc %1 (first %2) (second %2)) (range (inc (first (last l)))) l))
22:13clojurebotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.Associative
22:13technomancyoh dang... I forgot assoc worked on vectors
22:13technomancywell-played
22:13qbg,(let [l [[0 12] [1 23] [3 65]]] (reduce #(assoc %1 (first %2) (second %2)) (vec (range (inc (first (last l)))))))
22:13clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
22:14hiredmanqbg: that assumes l is sorted
22:14hiredmantechnomancy: thank you
22:14qbghiredman: True
22:14alexykl is sorted in my data
22:15alexykindex is increasing, although may be sparse
22:15hiredmanactually
22:15hiredmanmine assumes the vector is not that sparse
22:16hiredmanugh
22:16hiredmanI hate to see last
22:17chouser,(let [v [[0 12] [1 23] [3 65]], m (apply max (map first v)), o (vec (repeat (inc m) 0))] (reduce (fn [o [k v]] (assoc o k v)) o v))
22:17clojurebot[12 23 0 65]
22:17hiredmanoooh, max
22:18alexykwow
22:19tcrayfordchouser: The start of page 70 about closing parens could use an example of good style (or a note that every other bit of code in the book puts its ending parens in the right place)
22:21alexykqbg: so any final working version for my collection? :)
22:22alexyk:)
22:29qbgAnyways, my solution would be similar to chouser's
22:33chouseralexyk: you said the keys are increasing?
22:34alexykchouser: yep
22:34hiredmanyou could concievably do a check and pad the vector out as you go
22:34chouseryeah, that's what I'm thinking
22:34hiredmaninstead of doing another seq traversal
22:39jcromartieholy crap how much does Maven download every time you run a command?
22:43chouser,(loop [[[k v] :as i] [[0 12] [1 23] [3 65]], o []] (cond (empty? i) o (== k (count o)) (recur (next i) (conj o v)) :else (recur i (conj o 0))))
22:43clojurebot[12 23 0 65]
22:46hiredman:(
22:46hiredmanloop
22:46chouseryeah
22:47alexykloop! recur! finally, real code! :)
22:47timothypratleyjcromartie: maven requires the whole internet as a dependency tree that needs to be refreshed every command,
22:47alexykI was writing similar with reduce, carrying tuples
22:47chousercan't think of how to pad or not in any of the high-level fns
22:47jcromartieseems that way
22:47jcromartiebut hey, at least it's not ant
22:49hiredman,(reduce conj [:a :b :c] (range 10))
22:49clojurebot[:a :b :c 0 1 2 3 4 5 6 7 8 9]
22:49hiredman,(reduce conj [:a :b :c] (repeat 10 0))
22:49clojurebot[:a :b :c 0 0 0 0 0 0 0 0 0 0]
22:49alexykjcromartie: it will download until it has it. if you installed manually and forgot to install the pom, it will try to download until you install the pom
22:50jcromartiehas what? and install what pom?
22:51hiredman,((comp (partial apply reduce conj) (juxt identity range)) [:a :b :c] 4)
22:51clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$identity
22:51hiredman,((comp (partial apply reduce conj) (juxt (comp first list) (comp range second))) [:a :b :c] 4)
22:51clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$second
22:51hiredman,((comp (partial apply reduce conj) (juxt (comp first list) (comp range second list))) [:a :b :c] 4)
22:51clojurebot[:a :b :c 0 1 2 3]
22:52hiredman:|
22:52timothypratleyHaving said that - Maven is really great at what it does. And I'm really impressed with leiningen, very slick.
22:55jcromartieok but still, what is the "it" and the pom in alexyk's comment?
22:55alexykjcromartie: depends what it wants in your case! study the [INFO] lines
22:56jcromartiek
22:56jcromartieit seemed to be all basically maven-related
22:57qbg,(let [a (into {} [[0 12] [1 23] [3 65]]) b (apply max (map first foo))] (map #(get a % 0) (range (inc b))))
22:57clojurebotjava.lang.Exception: Unable to resolve symbol: foo in this context
22:57qbg,(let [a (into {} [[0 12] [1 23] [3 65]]) b (apply max (map first a))] (map #(get a % 0) (range (inc b))))
22:57clojurebot(12 23 0 65)
22:58qbgFinally
22:59qbgalexyk: That should be a lazy solution to the problem
23:00alexykhah!
23:00alexykthx!
23:00hiredmanmax is not lazy
23:00chouserexcept max will realize the whole seq
23:00hiredmanneither is into
23:00alexyk:(
23:00qbgWell, the resulting sequence is lazy at least
23:07alexykI have a transform f for all values of a map; it should remain a map with same keys. How do I do that?
23:08hiredmanreduce
23:08hiredmanor map + into
23:09chouseror zipmap + map
23:10hiredmanis the order returned by keys and vals always going to be the same?
23:10hiredmanI don't trust zipmap
23:11chouser,((fn f [n [[k v] :as i]] (lazy-seq (when i (if (== k n) (cons v (f (inc n) (next i))) (cons 0 (f (inc n) i)))))) 0 [[0 12] [1 23] [3 65]])
23:12clojurebot(12 23 0 65)
23:12chouserfully lazy
23:12chouserhiredman: yes, the same order as a seq on the map itself
23:12chouserthe map doesn't change in the meantime of course
23:18qbg,(let [a [[0 12] [1 23] [3 65]] b (map #(- (first %1) (first %2) 1) a (cons [0] a))] (mapcat #(concat (repeat %1 0) [(second %2)]) b a))
23:18clojurebot(12 23 0 65)
23:19qbgShould be fully lazy, but messy
23:22chouserqbg: interesting!
23:29chouser,(let [a [[1 23] [3 65]] b (map #(- (first %1) (first %2) 1) a (cons [0] a))] (mapcat #(concat (repeat %1 0) [(second %2)]) b a))
23:29clojurebot(23 0 65)
23:30chouser,(let [a [[1 12] [2 23] [4 65]], ks (map first a), b (map - ks (cons -1 ks))] (apply concat (interleave (map #(repeat (dec %) 0) b) (map #(list (second %)) a))))
23:30clojurebot(0 12 23 0 65)
23:31chouserI guess that's not really any cleaner.
23:31qbg,(let [a [[1 23] [3 65]] b (map #(- (first %1) (first %2) 1) a (cons [-1] a))] (mapcat #(concat (repeat %1 0) [(second %2)]) b a))
23:31clojurebot(0 23 0 65)
23:31qbgNow even more horrible!
23:35chouser,(let [a [[1 12] [2 23] [5 65]], m (into (sorted-map) a)] (map m (-> a last first inc range) (repeat 0)))
23:35clojurebot(0 12 23 0 0 65)
23:35chouseroh.
23:35chouserthat's not using the sorted map at all.
23:36chouserqbg: I just reinveted yours. :-P
23:36tcrayfordchouser: there appear to be some rendering errors on page 79
23:39chousertcrayford: indeed, thanks.
23:45alexykchouser: for zipmap, are we guaranteed that (keys m) and (vals m) will return aligned lists?
23:45alexyk,(let [m {:a 1 :b 2}] (zipmap (keys m) (map inc (vals m))))
23:45clojurebot{:b 3, :a 2}
23:45chouseralexyk: yes
23:46chouserboth return items in the same order as (seq m)
23:46tcrayfordchouser: also much enjoying the book so far. Its taught me a couple of tricks that I didn't know (like :keys in map destructuring)
23:46chousertcrayford: great, thanks!
23:46chousertcrayford: have you read any of the other books?
23:46tcrayfordyep
23:47chouserHalloways?
23:47tcrayfordand in action
23:47chouseroh, ok. great.
23:47tcrayfordyours seems better as a second book
23:47tcrayfordor more advanced than the other two at least
23:47chouserexcellent! That's exactly what we're aiming for.
23:48tcrayfordand pretty much what I was looking for in a book as well
23:48tcrayfordI can read the language well enough, just don't use it quite as well as I'd like
23:48tcrayfordnice one.
23:48alexykhmm, I missed it -- where can I read chouser's book? :)
23:49chouseralexyk: http://joyofclojure.com/
23:49alexykthx!
23:50tcrayfordlooks like its going to be quite a long book
23:50tcrayfordif you stick to the current contents
23:51chouserwe really don't want it to be a giant tome. Hopefully we can shake out some of the less useful bits and extra wordiness, and get a nice succinct result.
23:51tcrayfordaye
23:52tomojchouser: looks awesome
23:52chouserThanks! I really hope it lives up to the high expectations. :-)
23:52tcrayfordmy only problem with meap is that I want to read certain parts of the rest of it now (the concurrency chapter and probably ch6-8)
23:53patrickdloganquestion... I'm returning to clojure after some time... tried leiningen early in its being...
23:53tomojwhen can I start reading it? already?
23:53tomojI will buy it right now
23:53patrickdloganis lein considered the place to start and use clojure projects now?
23:53chousertcrayford: yeah, I'd like to read those too. ...would help make the writing of them go faster.
23:53tomoj(I wonder if that book will talk about lein..)
23:54tcrayfordtomoj: you can read what's been written so far, with updates as they come
23:54chousertomoj: not currently planned, but that may change. lein didn't exist when the early outline were drawn up, and is rapidly becoming a defacto standard.
23:54chousertomoj: first chapter is free now, through 4 available now if you buy
23:54tcrayfordyou've got a bit about larger project design in there right?
23:55tcrayfordlein should probably go in there
23:55tcrayfordat least like a paragraph or summat
23:55tomojchouser: buying now
23:55tomoj:)
23:55chousertcrayford: possibly. or perhaps in an appendix.
23:55tomojI think as lein cleans up it would be good to have nicer docs for them too
23:56chousertomoj: great, thanks!
23:56tomoja tutorial or something maybe
23:56tcrayfordthe lein sample project and `lein new` worked pretty well for me
23:56tomojlast I tried it I still couldn't grok like I could rubygems
23:56tomojthough admittedly I never did much about setting up gems
23:56tcrayfordlein isn't really like rubygems though
23:57tomojwell, at least a tutorial would be nice
23:57tomojalso how to deal with projects which aren't in clojars yet and also have java dependencies
23:58tomojpossibly spread across multiple maven repos :(
23:58tcrayfordthose are pretty tricky with lein's current setup :(
23:58tomojI don't remember if I managed to get compojure working or not
23:58tomojand I had trouble with lein-swank and swank-clojure-mode
23:58tcrayfordI've had compojure working out of lein for donkeys years
23:58tcrayfordalso what trouble with lein swank?
23:59tomojchouser: I wonder, are some of the profits from your soon to be ridiculously popular book going to clojure? I'll still buy if not, but that would be cool. dunno how much money books actually make that the publisher won't claim