#clojure logs

2011-09-24

00:24amalloyjli: (into s1 s2)
00:36zippy314I'm finding that when I run single tests if I refer to the fully qualified name of a function, the test fails complaining that the class doesn't exist, but if I run all my tests this doesn't happen. How do I get those classes from other namespaces to compile for testing?
00:37zippy314(the fully quallified name is a of a function in a different namespace than in the test)
00:44ibdknox_jli: you there?
01:20brehautif i specify "[1.2.1],[1.3.0]" in a dependency's version number, that means it will work with either 1.2.1 or 1.3.0 right?
03:06Iceland_jackk
03:30jliibdknox_: now I am, but I'll guess you're not? :)
03:51bj0ernGood morning, gentlemen.
03:53bsteuberit's nice to wake up, switch on the computer and see clojure 1.3
03:53bsteubera bit like xmas :)
03:57angermanyea kinda.
04:31webusnixwhat's the difference between clojure.jar and clojure-slim.jar ?
04:34morphlingwebusnix: clojure-slim is smaller since it does not contain precompiled binaries, only the necessary (clojure) source files
04:35webusnixis clojure-slim or clojure better for use in REPL ?
04:36morphlingwebusnix: clojure should start faster
05:26mikera,(+ 6 7)
05:26clojurebot13
05:26mikera,(int 0xFF6080A0)
05:26clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for int: 4284514464>
05:28mikeraanyone know how to specify big hex literals in Clojure 1.3? I actually *want* to overflow the int because it is a hex colour value......
05:29brehautmikera: if you are asking how you get unsigned primitive ints in the jam, you can't
05:29brehautgoddamn autocorrect
05:29brehautin the jvm
05:30brehautmikera: the common answer is to use a larger number
05:30mikerabrehaut I know that, I want the result to be a negative signed int to pass into a Java library...... I just have the unsigned hex values as input :-)
05:31mikerait worked in Clojure 1.2.....
05:32Chousukemaybe you could make a macro that takes 4 numbers/symbols as parameters, parses them and returns a signed int :P No idea if macros can return primitives though
05:36mikera(defn hex-to-int [l] (if (> l 0x7FFFFFFF) (- l 0x100000000) l)) seems to work for my case but is ugly.....
05:40fliebelmikera: What are you trying to do?
05:42fliebelUgh, what is clojure.lang.ILookupHost supposed to be? I get ClassNotFoundException when I change my proj to 1.3
05:42mikerajust looking for a good way to convert unsigned hex literals into Java ints, when they are needed for a Java library
05:45fliebelmikera: Since when does Java have unsigned numbers?
05:47fliebelmikera: Oh, wait, I think I know what you mean. Have you seen bit-test?
05:48mikerait doesn't, but I want to coerce it into a 32-bit signed integer (i.e. I want it to overflow into negative numbers). This is what the Java library expects (it's a 32-bit ARGB colour so this is standard practice)
05:49mikerahmmm i think I have seen bit-test but how does that help?
05:50mikera,(bit-test 0xFF6080A0 31)
05:50clojurebottrue
05:50mikera,(bit-test 0xFF6080A0 0)
05:50clojurebotfalse
05:54mikeraOK I think I've got it:
05:54mikera(defmacro coerce-int [v] `(int ~(if (bit-test v 31) (- v 0x100000000) v)))
05:54mikerathanks!
05:55fliebelmikera: You're welcome. Though I still don't really get what you are doing.
05:59mikeraBasically I want to be able have an unsigned hex value (like 0xFF6080A0) as an input and get the equivalent java int value as an output (-10452832). Graphics libraries often expect colours to be handled this way, they need to fit in 32 bits for performance reasons so they "cheat" and use the same bit pattern in Java ints even though Java ints are technically signed..
05:59fliebelSolution to my ILookupHost question: Don't try 1.3 with a dep that depends on old contrib.
06:00fliebelmikera: Oh, right, so you're basically doing <<< iirc. That is like bit-shift without regarding the sign bit.
06:00mikera@fliebel - just spent an hour myself updating a load of dependencies. worth it for 1.3 though!
06:00bj0ernSweet, 'The Joy of Clojure' arrived.
06:03mikerayep that's right, it's something like <<< because you're effectively ignoring the sign. Clojure is still a bit tricky to use for bit-twiddling hacks :-)
06:03fliebelmikera: http://www.java-samples.com/showtutorial.php?tutorialid=60 < not available in Clojure
06:06mikeraIs now: (defn >>> [v bits] (bit-shift-right (bit-and 0xFFFFFFFF v) bits))
06:10mikerathough you do sometimes need to have the native JVM version for performance..... guess I'm still going to be stuck for a while using Java as my "assembly language" for Clojure
06:14fliebelmikera: How do you do this in java? Because 0xFFFFFFFF does not fit an integer.
07:22mikera@fliebel - you can assign 0xFFFFFFFF into an integer in Java, it interprets it as -1. I just wanted to do the same in Clojure.
07:23fliebelmikera: Oh, hm. So maybe unchecked math has something for you then?
07:29gkofor 1.3, what happen's for clojure.contrib? I read that it went to clojure repo in github... does it mean that now, only clojure.jar is needed and most useful things (of contrib) got into clojure?
07:30mikerafliebel - ah, that also seems to solve the issue - thanks! a(int 0xFFFFFFFF) => -1 now......
07:31mikeraafter (set! *unchecked-math* true) that is....
07:35mikera@gko - see http://dev.clojure.org/display/design/Contrib+Library+Names
07:36mikeracontrib got broken up into chunks.
07:41gkomikera: are these chunks in the standard clojure jar or they have to be retrieve separately?
07:44gkofor ex, command-line is in tools.cli, does tools.cli is in standard jar or ...?
07:45gkogrrr... is tools.cli in standard jar, i meant...
07:46mikerayou need to get them separately I think, there are in separate repositories. See https://github.com/clojure. I personally just use Maven to pull in all the dependencies needed from clojars.org
07:49gkook... thanks.
08:07cactuskidquit
08:45anildigitalAnyone know how to run projects main when you are connected with clojure-jack-in
09:13Netpilgr`Isn’t it an error that the doc string for = says “compares numbers … in a type-independent magger” but ##(= 1 1.0)?
09:13lazybot⇒ true
09:13Netpilgr`? In my REPL this yields false.
09:14Netpilgr`I’ve tested it first with Clojure 1.3.0 then again with 1.2.1 to make sure it wasn’t new behavior.
09:15michael_campbellfalse for me in 1.3-rc0 also. Getting 1.3 now; just saw the announcement
09:15michael_campbellAre the 2 hashes an indicator for the bot to evaluate the expr?
09:15Netpilgr`Yes.
09:18michael_campbellI'm brand spanking new to clojure so apologies for the newb question... in the repl, is there a canonical way to exit? ^D works, and I'm even a little proud of myself for thinking of (and looking up how) to (System/exit 0), but wondered if I'm overlooking something.
09:22Netpilgrimmichael_campbell: I use emacs with slime, but exiting a REPL with ^D should be fine. That’s how I exit unix shells.
09:22michael_campbellI'm an emacs guy too and thinking of getting slime set up this weekend.
09:26Netpilgrimmichael_campbell: It’s easy enough if you follow the instructions at https://github.com/technomancy/swank-clojure.
09:26anildigitalmichael_campbell: these steps might help you https://gist.github.com/1239262
09:27michael_campbellThanks, both. I heard this week someone at strangeloop noted that crafting ones .emacs is like building your own lightsaber.
09:27Netpilgrimmichael_campbell: Probably more like building your own spaceship. :)
09:28michael_campbellThere's enough moving parts; that's for sure. Looks like I'm going to have to tackle leiningen too.
09:29michael_campbellI've decided to go to clojure/conj. I at least want to be up on this enough to understand what's going on.
09:30michael_campbellhaving written about 15 lines of clojure in my entire career, and most of it in the repl, as I read what goes on here =)
09:30Netpilgrimmichael_campbell: For working on Clojure code in Emacs: If you’re not already using paredit-mode (http://www.emacswiki.org/emacs/ParEdit), install it now. It makes a world of difference!
09:31michael_campbellI'm not trying to instigate a holy war or anything, and I'm committed to learning clojure, but do you guys have any opinions on Scala? (if this subject is akin to C brace styles or emacs/vi, I'll leave it alone. Was curious as to your thoughts.)
09:31michael_campbellthanks Netpilgrim
09:32Netpilgrimmichael_campbell: And have a look at http://4clojure.com/. It’s a fantastic way to learn clojure.
09:33michael_campbellIt looks like I'm going to need a lazy infinite list of "thanks..."
09:34Netpilgrimmichael_campbell: I’m still very new to Clojure myself. So you’ll be able to give tips to newbies here in no time, too. Just help growing the community.
09:35michael_campbell<nod> gotcha. Community is very important. Some I gel with instantly (getting that impression here), and some I do not.
09:36michael_campbellI spent a lot of time on EFNet #unix years ago which was full of crazy smart people, but very polarizing.
09:37Netpilgrimmichael_campbell: I don’t know much about Scala but I guess the two languages are different enough to prevent a holy war. (type system, immutability, syntax, …)
09:38Netpilgrimmichael_campbell: On the other hand emacs and vi are two very different editors. :)
09:39michael_campbellthe differences are one reason I wanted to do clojure first; I know java pretty well, and from what I'm told it's easy (too easy) to fall into bad java habits with scala. Clojure is a "throw into the water to swim" kind of situation. I know a little lisp from emacs hacking, so I kind of "get it" with the syntax and evaluation semantics and such, but not the whiz-bang or thinking in the language yet.
09:40ChousukeClojure doesn't look much like Java so if you start writing Java in Clojure you will notice it :P
09:40Chousukeit looks ugly
09:41Netpilgrimmichael_campbell: Same for me, I wanted to learn a functional language (though nor purely functional, so I can get things done). I’ve worked with enough OOP languages, and they are all so similar.
09:44michael_campbellNetpilgrim: yeah, that's where I'm coming from. My company is financial services (yes, I know), so we're way behind even the *java* curve on tech. I had a very humbling job interview recently, and realized my 10-12 years experience is 2-3 years, repeated 3-4 times. So I'm on a tear now trying to both catch up, and to keep learning ... SOMETHING. FP seemed a good choice to stay relevant. (Wife calls; gotta run. Thanks
10:10rjacknewbie here: I installed counterclockwise on eclipse, and after updating to 1.3.0 I keep getting a 1.2.0 REPL
11:13licenserhi everyone :)
11:13jjidohi
11:15licenserHas anyone here used in canter for creating charts for the web and could get me a hint? I want to include the 'values' of the pie pieces in the image but I don't find anything about this, any hints where to look?
11:17kjeldahllicenser: I've only used it a tiny bit, but I think it uses jfreechart which definitively supports this. Usually, the clojure interfaces to java libraries mostly pass options etc right through to the underlying java libraries, so I think it should be doable.
11:18licenseroh my good I have to read jdoc? :P
11:27licenserOkay the jfreechart thing was a good hint, but it seems to require to creat a class and ugly things … :.(
11:40khaliGlicenser, it's kinda nicer if you use incanter
11:44khaliGoops i missed the earlier convo. licenser if you're doing web stuff, check out the google charts, it makes really nice charts!
13:22bsod1anyone knows how to fix indentation in counterclockwise eclipse plugin?
13:22fliebelbsod1: What's broken?
13:23bsod1fliebel: after wrapping some code with more parens I cant fix indentation(or removing some outer parens)
14:08cemerickbsod1: hit tab on the lines you want to re-indent
14:09bsod1is there a function for lazy seq of cartesian products of collections?
14:09bsod1cemerick: I've already tried that, it doesn't work on eclipse indigo(I'm using viPlugin, I don't know if it matters)
14:10cemerickbsod1: Not sure here, either.
14:13amalloybsod1: contrib.combinatorics has that, i think; and if you know the number of collections at compile time it's easy to do with just a (for)
14:29fliebelhttps://twitter.com/#!/abedra/status/117634999590727680 :) Who's using Clojure professionally as a primary language in Europe?
15:03khaliGare there people writing swing apps with clojure or am i the only one?
15:04ibdknoxkhaliG: there's also this guy: https://github.com/daveray/seesaw
15:05khaliGibdknox, excellent. I need to read some code :)
15:05khaliGif you know of any others please let me know
15:06khaliGwow mindblown, seesaw sounds really interesting
15:07ibdknoxahh the wonders of the internet :)
15:14khaliGdoesnt look like it handles any 'difficult' problems though :/
15:28amalloy~source delay
15:36fliebelamalloy: ?
15:37amalloyfliebel: just easier than looking in the repl, and there weren't any conversations i was butting into
15:38bsod1I'm getting "key must be an integer" error when I run this: (some #(% [1 1]) #{[1 1] [2 2]}) can anyone help me?
15:38amalloyyou're trying to call ([2 2] [1 1])
15:40fliebelWhich is actually short for (get [2 2] [1 1])
15:40bsod1amalloy: how? I've tried to wrap this set with (seq) but got same error
15:41amalloy&'#(% [1 1])
15:41lazybot⇒ (fn* [p1__8617#] (p1__8617# [1 1]))
15:41amalloyyou're mapping that function over the elements of the set
15:41fliebelbsod1: What do you want to do?
15:42bsod1fliebel: I have a vector with some sets in it, and I want to filter sets that contain a pair
15:44bsod1ah, found it..
15:44bsod1trying to implement an algorithm which has lots of state..
15:46amalloyfliebel: fortunately, making stuff look like a core part of clojure *is* a core part of clojure
15:47fliebelYou know, like (fn ([[[a a] & t]] true) ([nil] false) ([[f & r]] (recur r))
15:48amalloy(macrolet [(fn [& args] `(matching-fn ~@args))] ...)
15:48fliebelamalloy: Okay, it'll probably work to ad clojure.match to my cake template by default.
15:52fliebelamalloy: Is macrolet in clojure, or in amallow-utils?
15:52amalloyfliebel: tools.macro
15:53amalloyway too complicated for me to have written it :P
15:53fliebelamalloy: What? You just defmacro it privately, Python style, and then let the result :)
15:54amalloyi don't understand enough python to get the joke, i guess?
15:54fliebelPython style = __method = some_obfusctaed_method_name
15:55amalloyfliebel: that doesn't actually work, though, is the point. the compiler doesn't recognize lets of macros
15:57fliebelIt does, you just define a macro with a gensym, and the walk the let body to replace that with the actual symbol.
15:58amalloyfliebel: right, but walking the body is the complicated part
15:58amalloybecause you have to allow for the user writing (macrolet [(foo [] nil)] (let [foo +] (foo)))
15:58fliebel(let [foo (some macro)] (foo)) -> (do (defmacro G__310 (some macro)) (G__310))
15:59fliebelhm, maybe
15:59amalloyfliebel: macrolet in both clojure and CL does allow that, so i wouldn't really be happy with a half-solution
15:59fliebelIn that case, I'm just going to sleep. Good morning!
15:59amalloyheh, night
16:00fliebelOr does UGT include a clause where it allows you to have evening upon leaving?
16:01amalloyfliebel: that's the idea, yes
16:01amalloywhen you say hello, it's morning; when you say goodbye, it's evening/night
16:01fliebelah "and it is always late night when person leaves" okay, good night :)
16:03fliebelOr I'll just stick to Truman
16:08rata_hi
16:09rata_does anyone know how to put binary data in a mongo db using congomongo?
16:25patchworkhey all, stoked about 1.3! I tried to upgrade my project today and I got an error about the new "Can't dynamically bind non-dynamic var" thing. it is in the clojure.contrib/pprint module I believe, which actually I don't include directly. Is there a new version of this available?
16:26gfrederickspatchwork: can you use clojure.pprint instead?
16:27gfredericks(I suspect it's the same thing, but can't say that authoritatively)
16:27patchworkgfredericks: Sure, if I could find out what library requires it ; )
16:28patchworkpossibly json?
16:28patchworkso have things like this been moved into core?
16:28patchworkpossibly that is the problem
16:28gfredericksoh, I skipped over the "don't include directly" part
16:28amalloypatchwork: i think a better approach than this exists, but you can get an idea with $ mvn dependency:tree
16:28amalloy(after lein pom, of course)
16:30amalloyduck1123 recommended setting a global exclusion of contrib in your project.clj, and then seeing what happens
16:33patchworkamalloy: I don't see it in mvn dependency:tree
16:33patchworkamalloy: so just remove the dependency on clojure-contrib? or is exclusion another kind of thing?
16:33patchworkthat seems like it will break things : )
16:34amalloyyep, it will break things: "don't let any downstream library have contrib"
16:34amalloythen at least you will know who you need to fix
16:34patchworkamalloy: sorry, I must have missed something, are we not using contrib anymore?
16:35gfrederickspatchwork: sorta not
16:35amalloycontrib is not 1.3-compatible, and for months has been "trying to" break up into lots of smaller libs
16:35amalloythere will be no new releases of contrib, so it certainly won't become 1.3-compatible
16:36patchworkhmm... so is there another place I require things like json?
16:36patchworknot sure what else I use, I will have to check
16:36patchworkinteresting
16:37gfrederickspatchwork: e.g., https://github.com/clojure/data.json
16:37patchworkI see, so those libraries are still going to exist, they will just live on their own?
16:37patchworkI panicked for a second there
16:38gfrederickspatchwork: most of them yes. I think some of the lonelier libraries are in purgatory or something
16:38amalloypatchwork: they will exist iff someone does the work to make them exist
16:39patchworkAha. I am willing to bring some things up to date if I need them. any idea what has been left behind? anything significant?
16:40gfredericksI think I only hit up against one library, but it was a while ago and I don't remember what it was. I think combinatorics.
16:40gfredericksthat sounds like something nobody but me cares about
16:40patchworkhey! combinatorics are great, didn't realize we had a library for it
16:40patchworkOr had, I guess
16:40gfredericks:-D
16:41gfredericksI doubt it'd be hard to bring it up to date
16:42gfrederickslooks like the whole thing is barely 100 LOC: https://github.com/clojure/clojure-contrib/blob/master/modules/combinatorics/src/main/clojure/clojure/contrib/combinatorics.clj
16:42amalloymost things are easy to bring up to date. the clojure.core "machinery" of jira management, and contributor-only committers is the hard part
16:43gfredericksI'm a contributer now
16:43patchworkamalloy: sorry, what does this mean? contributor-only committers? jira management?
16:43gfredericksI'd be rather surprised if conmbinatorics had to be updated at all...
16:44patchworkexcuse my ignorance, I've only been using clojure heavily for the past two months
16:44ibdknoxthe problem for me is that I have no interest in maintaining them long term
16:44ibdknoxI'd be happy to update them
16:44ibdknoxlol
16:44duck1123sometimes that's all they need for now
16:45amalloy$google clojure jira
16:45lazybot[Clojure - Clojure JIRA] http://dev.clojure.org/jira/browse/CLJ
16:45gfredericksthe part I don't know about is who does/ought-to own it, how to distinguish between the 1.2 version and the 1.3 version, etc...
16:46amalloyibdknox: so don't try to make them part of new "contrib". make it your own clojar labeled "1.3 port of contrib.foo, never going to be maintained"
16:46gfredericksI need to make a new clojars account so I'm not locked out anymore
16:46patchworkyeah I don't see anything in this combinatorics library that should prevent it from running in 1.3
16:47patchworkjust change the namespace, right?
16:47patchworkamalloy: I know that jira is a bug tracker, I guess I don't see why jira management would be an issue for upgrading to 1.3?
16:48duck1123algo.combinatorics ?
16:48patchworkduck1123: that sounds good
16:49amalloyif you want your project ot be part of contrib, you can't take patches except from people with signed contributor agreements, and those patches have to be submitted via jira and attached to a ticket
16:49duck1123Is that for all history of it?
16:50patchworksigned contributor agreements? odd, why would that be necessary?
16:50gfrederickslawyers?
16:50duck1123It's so they can be free to relicense as needed
16:50patchworksorry, should I be fearing lawyers by contributing to clojure?
16:51ibdknoxyou can't contribute to Clojure without signing the agreement
16:51ibdknoxlol
16:51ibdknoxyes
16:51duck1123basically you say that anything you give to clojure, is clojure's
16:51amalloyduck1123: were you asking me? yes. when dnolen's match got promoted to contrib, they had to ask everyone who'd contributed any code to officially give away their code
16:51duck1123amalloy: good to know.
16:51ibdknoxyou have to be explicit about who owns the IP
16:52patchworkwho does own it? are some of these things not an open source license to begin with??
16:52lazybotpatchwork: Uh, no. Why would you even ask?
16:52amalloyheh
16:52patchworkheh
16:52patchworkthanks lazybot
16:53gfredericksI guess we have AI now
16:53amalloypatchwork: rich owns it
16:53patchworkclojure is open source right?
16:53amalloyyes
16:53gfrederickscertainly in the most plain literal sense
16:53duck1123Clojure and Contrib and ilk are CPL
16:53ibdknoxOpen source does not mean without ownership
16:54duck1123At one point it was all EPL, Rich was able to change that in part because of the CA's
16:55patchworkinteresting, this is far more complicated than I thought.
16:55duck1123This is only if you want to contribute to an official library. If you want to make your own library in clojure, you're free to do whatever you want
16:56gfredericksunless you accept contributions from another person without having him sign your own CA, in which case a lawyer will shoot you while you sleep.
16:56duck1123well... there is that
16:58patchworkgfredericks: really? is this something I should worry about? great. So the fact that the project already has a license when the person contributes, that license does not apply to their code?
16:58patchworkthat is kind of insane
16:59gfrederickspatchwork: actually I have no idea what I'm talking about.
16:59patchworkgfredericks: that would make github a very dangerous place
16:59amalloypatchwork: gfredericks is just causing trouble
16:59amalloyyou can do whatever you want with your own library
17:00patchwork: ) alright, got nervous for a second
17:00gfredericksamalloy: it's an interesting question though -- what danger is clojure avoiding that somebody who doesn't do similarly is exposing themselves to?
17:00gfredericksI certainly don't know
17:00patchworkSo, rich owns contrib as well?
17:00patchworkthat makes sense
17:01gfredericksI should also add that I would like to know, if anybody would like to share :)
17:01amalloygfredericks: i write a bunch of code, clojure accepts my pull request, and then a year later when clojure is a million-dollar industry, they notice that i used a sneaky license
17:02amalloyi imagine this is what rich is worried about
17:02patchworkamalloy: so a pull request can have a different license from the project that pulls it?
17:02patchworkhow does that work?
17:02gfredericksby "used a sneaky license" you mean that you stuck a different license at the top of...your file?
17:03amalloygfredericks: or something like that
17:03patchworkinteresting
17:03amalloy*shrug*
17:03amalloyi'm certainly not an IP lawyer, but situations kinda like this could conceivably arise
17:03duck1123That's why you always read the pull request
17:03gfredericksat least the commit message.
17:04gfredericksmaybe just review the sha.
17:04patchworkWell, I would hope you would read the pull request anyway : )
17:04amalloyduck1123: or, years later, "I emailed them that patch in confidence, I had no idea they would incorporate my private code into their public project"
17:04amalloyetc etc
17:04patchworkjust pulling arbitrary stuff into your project seems sketchy
17:05patchworkamalloy: something like github which mediates these exchanges could prevent that possibly?
17:05duck1123Rich has a piece of paper somewhere with my name on it that says I won't try to pull that
17:06amalloy*shrug* github won't want to get their lawyers involved in this dispute, and i can rewrite the commit message someone sends me. they can claim i did that
17:06amalloy(assuming i'm rich, in this case)
17:06dtvannyThis is about the GPL, but the general comments on enforcing the license seem generally applicable to the discussion: http://www.gnu.org/licenses/why-assign.html
17:07amalloya piece of paper giving away all rights to any of my code that appears in clojure obviates the problem
17:07amalloyi think, personally, that it's a huge pain, and it causes me to contribute less to clojure than i'd like. but i can see why rich wants it anyway
17:07duck1123amalloy: You can't rewrite the message without changing the hash of the tree. Although you certainly can before a push
17:08gfredericksdo lawyers trust hashes?
17:08amalloygfredericks: it doesn't matter if they do
17:08patchworkamalloy: Yes, that sounds like a pain. I think I will release my libraries separately ; )
17:08amalloyeither side of the transaction could change *their* half of the commit, and the hashes would differ. but you can't tell who did it
17:08patchworkI see why everything is moving out of contrib
17:09duck1123perhaps we need bitcoin for git commits
17:12gfredericksI've thought that a global timestamp server would be nice.
17:13nappingShould I be able to (use) libraries from lein repl?
17:13patchworknapping: yes
17:14patchworkthough you have to quote them
17:14gfredericksnapping: yes, generally with the (use 'foo.bar) syntax
17:14patchworkSo okay, where did str-join go?
17:14patchworkit was in clojure.contrib.str-utils
17:14amalloyclojure.string/join
17:14gfredericksclojure.string
17:14patchworkawesome
17:16patchworkI'm glad they upgraded that one
17:16amalloywell, that got promoted a long time ago
17:16amalloylast august, i think?
17:16patchworkdid it? my sources must be out of date
17:16duck1123still a lot of code to fix
17:16amalloypatchwork: stuff got moved into core, but not deleted from contrib
17:17duck1123I've patched so many libs for that one
17:17patchworkthat is one thing I've found, clojure changes so fast it is hard to know what the authoritative source for information is
17:17patchworkgoogle hits from 2010 are sometimes misleading
17:17gfredericksirc
17:18patchworkyeah, well good thing I'm here! : )
17:18duck1123hopefully with the new structure, that'll stabilize a bit
17:18nappingthe standalone form works better with the quote, but tools.cli is still not working
17:19nappinglein accepts a [org.clojure/tools.cli "0.1.0"] dependency, I see tools.cli-0.1.0.jar in libs next to other dependencies
17:19gfredericksnapping: what's the error?
17:20amalloynapping: you're probably using the wrong namespace
17:20duck1123the file names don't tell the whole story
17:20amalloyhttps://github.com/clojure/tools.cli/blob/master/src/main/clojure/clojure/tools/cli.clj#L1
17:20duck1123you can always open up the jar and look at the pom to see what version it really is
17:21nappingjust realized the names might not match and took a look in the jar,
17:21nappinguser=> (use 'tools.cli)
17:21nappingFileNotFoundException Could not locate tools/cli__init.class or tools/cli.clj on classpath: clojure.lang.RT.load (RT.java:430)
17:21amalloynapping: please follow my link
17:22patchworkthanks all for helping out by the way. I just got into clojure recently but I love it. I'm using it for a larger project now so I'm grateful this channel is so friendly : )
17:22patchworksome channels, not so much
17:23gfredericksfriendlier topic?
17:23nappingthanks, clojure.tools.cli works. Now, how should I have already known this?
17:24gfredericksnapping: where did you find out about the lib?
17:24duck1123always look at the code or docs of a lib you want to use
17:24nappinghttp://dev.clojure.org/display/doc/Clojure+Contrib
17:25gfredericksnapping: I don't see the ns noted anywhere prominently. I always look for it in the readme. Not seeing it there I would check the source, rather than guess that it's the same as the repo name.
17:27nappingis it based off the namespace, or the path to the file?
17:27gfredericksnapping: (from your link I simply had to click on the library name to get to the github repo)
17:27gfredericksnapping: they generally coincide, but the ns is usually declared at the top of the file, so check that to be sure
17:27nappingyeah, I was looking at the github page also, but not into the source
17:27gfredericksthus amalloy's link
17:30kjeldahlSo any shortcuts for removing the outer part of an s expression in Emacs clojure mode, i.e. a simple keystroke to make "(dbg (my-func 1 2 3))" become "(my-func 1 2 3)", by pressing some magic key at the first parens or anywhere inside the outermost scope?
17:30patchworkfound another one: clojure.contrib.prxml
17:30patchworkthis one still alive?
17:31amalloykjeldahl: M-UP, M-s, or M-r, depending on exactly what you want
17:31duck1123prxml makes me mad, it causes all of my dynamic warnings
17:31duck1123kjeldahl: usually M-s
17:31amalloynot M-s, i guess
17:31amalloyheh
17:32amalloypatchwork, duck1123: prxml is now part of data.xml, but that's not released
17:32duck1123I've been living dangerously and am using data.xml
17:32amalloy(dbg |(my-func 1 2 3)), M-s => |(my-func 1 2 3)
17:33duck1123but one of my older libraries used prxml, so it's still a dependency
17:33patchworknot released? yet you can still use it?
17:33clojurebotNo entiendo
17:33amalloyduck1123: you published your own release of it, or what? i know ninjudd did that
17:33duck1123you have to build it
17:33kjeldahlamalloy: Nothing happening at my end unfortunately.
17:33amalloydangit, i typed M-s but meant M-r
17:33amalloytry that
17:33duck1123I think I have a copy in my maven repo
17:34nappingafter reading "Compilation and Class Generation" carefully, it makes some sense
17:34patchworkduck1123: put it on clojars? : )
17:34patchworkis there a reason it is not released yet?
17:35amalloyone of the tests fails, even though it passes when i run it locally
17:35duck1123I haven't done that. build.jiksnu.com
17:35kjeldahlamalloy: M-r here toggles cursor position from middle of screen, bottom of screen, top of screen etc. I'm on Emacs 24. Any custom bindings in your .emacs?
17:35amalloykjeldahl: do you have paredit mode enabled?
17:35nappingI guess I'm confused by lein's name for the package. Do I have to learn Maven to understand those?
17:35kjeldahlamalloy: Ah, no.
17:35patchworkgotta have paredit
17:36amalloykjeldahl: dooooo it. paredit is king
17:36duck1123napping: They're maven names, so you have to at least know how maven names stuff
17:37duck1123I would have to change the group id to push it to clojars, right?
17:37amalloy*nod*
17:38amalloyduck1123: but you can just use the one ninjudd already pushed
17:38amalloyhttp://clojars.org/org.clojars.ninjudd/data.xml
17:39patchworkhey look at that! I'll give it a spin
17:39gfredericksdon't change the group id to be your clojars user id
17:40duck1123That's why I just host my own Archiva repo for stuff like this
17:41kjeldahlamalloy: Got it, thanks for the hint.
17:41amalloygfredericks: what would you change it to?
17:41gfredericksamalloy: don't know, I just know there's a bug in clojars that locks your profile if you ever do that
17:42amalloyhah
17:45nappingduck1123: thanks, I guess I'll check out a bit
17:45nappingMaven looks like a huge confusing mess. Is it worth understanding it all if I don't really care about Java?
17:46gfredericksnapping: I don't understand it all and I've gotten by
17:46napping"low power to weight ratio", is the impression I get
17:46gfredericksI don't know if those who _do_ understand it have some kind of hidden bliss that I'll never know...
17:46duck1123You need to know the basics, but there's a LOT to Maven
17:47nappingYeah, I think I need to know enough to understand lein
17:47duck1123I just recently made the switch from Maven back to Lein
17:49patchworkhmm... so this new data.xml does not work the same as prxml
17:49patchworkI just want to make xml out of arbitrary nested maps
17:50amalloypatchwork: it has the same features prxml does
17:50nappingthanks. That should be enough for a while, and I need to be off
17:50amalloy(or it should; i added them for just that reason) what are the inputs and outputs you want?
17:50duck1123patchwork: If your xml needs are simple, you may also want to check out hiccup
17:51patchworkamalloy: how does emit relate to the old prxml function?
17:51patchworkamalloy: or is it another function I am missing?
17:51amalloy(emit (sexp-as-element (some-data))) should be roughly the same as (prxml (some-data))
17:52patchworkamalloy: {:thing {:b 33}} => <thing><b>33</b></thing>
17:52patchworkamalloy: aha, I was missing the sexp-as-element
17:52amalloypatchwork: i don't think prxml ever worked like that. you're thinking of vectors, not maps
17:52amalloyanyway, data.xml works in a more formalized tree of :tag/:attrs/:content nodes; sexp-as-element is the hook i added to convert prxml/hiccup-style data to that format
17:53patchworkamalloy: aha, you are correct
17:53patchworkI see this whole to-xml conversion function I wrote to turn maps into prxml vectors
17:53patchworkthat I forgot I wrote
17:53amalloythat's dreadful
17:53patchworknice! this looks perfect
17:53patchworkamalloy: yeah
17:54gfrederickspatchwork: always maps with single keys?
17:54patchworkamalloy: this new situation is way better
17:54patchworkgfredericks: nope, they can have multiple keys
17:54patchworkI was just banging out a quick example
17:54gfrederickspatchwork: what does {:foo {}, :bar {}} generate?
17:55patchwork<foo></foo><bar></bar>
17:55amalloygfredericks: teaching the world what a bad idea it is to write your own xml library
17:55gfrederickswhat if I wanted <bar></bar><foo></foo>?
17:56gfredericksamalloy: how else will we store the data that we encrypted with our custom algorithm?
17:57rata_does anyone know how to put binary data in a mongo db using congomongo?
17:57patchworkgfredericks: hence the vectors of prxml, yet I had a bunch of maps
17:57amalloypatchwork: his point is that maps aren't ordered
17:57amalloyi'm not sure from your response whether he made that clear
17:58rata_do I just do (insert! :collection (java.io.InputFile. ...))?
17:58patchworkamalloy: yeah I got that, I see why prxml uses vectors, but I already had maps I wanted to output
17:58amalloymkay
17:58patchworkI didn't care about ordering really
17:59patchworkare you saying that there is a better way to output maps as xml I overlooked, or that I should only output ordered things in xml?
17:59gfredericksI guess if it's not a true xml library and is just an ad-hoc function to transform your data...
18:01amalloyif you don't care about ordering, then maps are a fine way to do it
18:01amalloywell
18:01amalloyif you don't care about ordering *or* being able to repeat elements
18:05rata_sorry, (insert! :collection (java.io.FileInputStream. ...))
18:05rata_but it doesn't work
18:05rata_anyone know how to do it?
18:36technomancyamalloy: I submitted a patch to do aot-less -main namespaces for clojure 1.2, but it was ignored until 1.3
18:36technomancyre: the issue you were having with 4clojure
18:36amalloytechnomancy: thanks. so it's actually in 1.3?
18:36technomancyamalloy: yeah, you can do java -cp myjar.jar clojure.main -m my.main
18:37technomancyso there's a little more boilerplate in the java invocation, but it's usually worth the tradeoff
18:37amalloyheh. i remember seeing that in the source, and was actually trying the -m option, but it didn't work on the 1.2 jar, of course
18:37amalloyso now i know whose fault it is that i expected it to work!
18:38technomancyindeed
18:41ZolrathI'm having an issue with lazy-cat as I'm trying to make a vector of maps but let's say I take 4 from it
18:41ZolrathThe first entry is the seed entry and it correctly pulls the data for making the second entry
18:42Zolrathbut instead of adding the map as a whole to the list it's adding each key/value pair of the map as its own vector
18:42Zolrathso take 3 takes the first entry and the first two keys from the second entry
18:47ZolrathOh I guess thats totally what lazy-cat should do.. hm
18:50ZolrathGuess I'll just wrap the results in a list
18:52shintakuis this the right vimclojure: https://bitbucket.org/kotarak/vimclojure/ ?? if you look at the src, all the vim stuff is in vim/ and i'm not sure that will work with pathogen, or at least it isn't for me. any ideas?
19:02zakwilsonUsing drop forces evalutation of the items being dropped, doesn't it?
19:03amalloyyes
19:04zakwilsonIs there a way to get a range from a lazyseq without evaluating the front of it?
19:04amalloyno. given the definition of a lazy seq, it's not possible
19:12amalloyzakwilson: you can do...some similar things, given some constraints that your application might or might not meet
19:16zakwilsonamalloy: it's a one-off thing. Not important enough.
19:19amalloy,(binding [*print-dup* true] (pr 1180591620717411303423))
19:19clojurebot1180591620717411303423N
19:20gfredericks,(type 7N)
19:20clojurebotclojure.lang.BigInt
19:22ZolrathOkay I definitely have a fundamental misunderstanding on how lazy-cat works as in my head (def go-up (lazy-cat [1] (inc (last go-up)))) would concat incrementing numbers as far as you take from it
19:23gfredericksZolrath: what do you expect (inc (last go-up)) to do?
19:23gfredericksoh I think I see what you're doing
19:23ZolrathI was thinking it would get the current result of (last go-up), increment it, and add that to the end
19:24ZolrathBut I am incredibly wrong
19:24gfredericksZolrath: one way of thinking of it is that if go-up is supposed to be an infinite sequence, then last would never return
19:24gfredericksor rather, that's one reason that won't work
19:25amalloyno, it looks like he's trying to do something that almost works but isn't very idiomatic clojure
19:25gfredericksamalloy: he could use last in that manner?
19:26amalloymaybe not
19:26ZolrathI'm not actually planning on using that function I just have another function where the next result relies on a key from the result prior to it
19:26ZolrathAnd I'm trying to figure out how to actually get that information
19:26gfredericksZolrath: not sure what you're wanting to learn here, but you might be interested in clojure.core/iterate
19:27amalloyyes, iterate, or a recursive function. *not* a recursively-defined var
19:31ZolrathHm I'll look into doing it another way I suppose, thanks!
19:32ZolrathOdd that you can't really extract information directly from entries prior though
19:33gfredericksZolrath: that's what iterate gives you
19:33pcerratoIt would seem that unless go-up is defined already in an enclosing or dynamic scope that def would not be able to eval it ... unless I'm missing something here ...
19:33gfrederickspcerrato: recursively defined vars work fine, it's just the 'last' that breaks it
19:33gfrederickstry (def jake (lazy-cat [5] jake))
19:34gfrederickspcerrato: it's because lazy-cat delays evaluation until later, at which point the def has already happened
19:40pcerratogot it .. thanks !
19:41amalloyZolrath: two easy ways to do this would be (defn go-up [n] (lazy-seq (cons n (go-up (inc n))))), or (defn go-up [n] (iterate inc n))
19:42gfredericksnoting that in amalloy's versions go-up is now a function returning the seq instead of the seq itself
19:49Zolrathamalloy: Thanks!
19:50ZolrathMy actual function is using enlive to pull data from a page and put it in a map, and in order to get the next page I have to use the key :prev as the url arguement in the next iteration
19:50Zolrathand I want to end up with a list of all the maps, n pages deep
19:51gfredericksthis implies that you could easily create a lazy seq of the entire internet.
19:51gfredericksI think that's a more compelling lazy-seq example than just "all the numbers" :)
19:51gfredericks(defn internet [] ...)
19:51Zolrathhaha
19:52ZolrathYeah my actual issue is grander than the go-up example that was just the most simple way of trying to use data from a previous iteration that I could think of
19:52ZolrathWhich I still couldnt do hah
20:33kd4joaSorry to bother you all with something that is probably right in front of my eyes, but I'm not seeing it.
20:33kd4joaSince clojure-contrib is gone, how does one write a line to a file? I have a java.io.writer but can't seem to locate the function that will actually write to it.
20:34gfrederickskd4joa: spit is too specific for you?
20:35gfrederickskd4joa: also do you know about clojure.java.io?
20:35kd4joayeah, that's what I meant instead of java.io.writer
20:35kd4joaI was using clojure.java.io to setup the writer
20:36gfredericksthe java docs say that if you have a writer you can (.write writer s)
20:36kd4joalet me look at spit again.
20:36kd4joaI thought I tried that and it complained. let me try it again
20:37gfrederickskd4joa: I'm looking at this specifically: http://download.oracle.com/javase/6/docs/api/java/io/Writer.html#write(java.lang.String)
20:38kd4joaCan I use a clojure.java.io/writer with that?
20:39gfredericksclojure.java.io/writer is a function that should return a writer
20:39gfredericksonce you have that writer, you can call .write on it
20:39gfredericksI didn't quite understand your question, so I just summarized
20:41kd4joaI have a list of maps that I want to write to a file in json format with a newline between each of the maps
20:41gfrederickskd4joa: if there aren't too many and you don't care about efficiency, you can assemble the output in a string and just spit it
20:42gfredericksthough actually using the writer is probably just as easy
20:42gfrederickswhat part are you hung up on?
20:43kd4joafinding a function that will actually write a string to a file. using .write on the clojure.java.io/writer throws an exception
20:43gfrederickswhat exception?
20:43kd4joaNo matching method found: write for class java.io.BufferedWriter
20:43gfrederickswhat are you passing it?
20:44kd4joaright now just a single string
20:44kd4joahmm. ok. I'll try closing everything down and starting up again
20:45gfrederickskd4joa: https://gist.github.com/1240064
20:45gfredericksyou're doing something like that?
20:47kd4joayes. at least I thought so. when I simplify it down to a string instead of my function that's returning a string it's working like you said
20:48kd4joaso something in the string that's getting generated through the function I wrote is making it puke
20:48gfrederickskd4joa: I suspect your function isn't returning a string
20:48kd4joaat least that's some progress. I know what it's not
20:48gfredericksas the method lookup is failing
20:49kd4joamust not be. it sure looks like a string though
20:49kd4joaunless it's in a list. aha
20:49gfredericks:)
20:49gfredericksit's always the damn little details
20:50kd4joayep. that was the problem.
20:50kd4joadamn. forgot that map returned a list
20:51kd4joathanks for the help
20:51gfredericksnp
20:51alandipertkd4joa: there's also spit, which might meet your need
20:52alandipertkd4joa: nevermind, scrolled up
20:53kd4joaultimately what I want to do is output all these maps as json through a web service continuously until the client breaks the connection
20:54gfredericksthat's sounds like a use case for not spit if I've ever heard one
21:01amalloythis is the first programming problem gfredericks has ever heard of that's not solved by spit
21:02gfredericksspit: who knew it wasn't turing-complete?
21:11patchworkso I have tracked an error down in some library code to what seems to be a type hint for an int-array, ^ints
21:11patchworkUnable to resolve classname: clojure.core/ints
21:11patchworkit's in a macro
21:11patchwork [~'img ~'x ~'y ~'w ~'h ^ints ~'arr]
21:11patchworkarr is an int-array
21:11patchworkis this something to do with the 1.3 upgrade?
21:12patchworksomething about it being a type hint in a macro?
21:14shep-homeWhile trying to run my tests, I get this error: `No matching field found: getRoot for class clojure.lang.Var`
21:14shep-homeThis is with emacs / clojure-test-mode / swank
21:15shep-homeA quick Google doesn't seem to have anything relevant
21:16shep-homeAnd I am trying to run my tests with C-c ,
21:19sridwhere is the new "substring?"? (from clojure.contrib.string)
21:20sridand where is to-byte-array?
21:20sridI cannot find them at http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
21:21amalloysubs
21:22amalloyand to-byte-array sounds like a bad thing to have anyway; what's it supposed to do?
21:22sridread from an input stream into array of bytes
21:22sridhttp://dpaste.com/620476/
21:26sridi then slurp the return value
21:26ibdknoxyou can slurp streams directly
21:27sridah, right.
21:29shep-homeWith the move away from monolithic contrib, where should I get contrib.test from if I'm starting a new project?
21:29shep-homeI think my error might be caused by incompatibilities with contrib and 1.3
21:44jlishep-home: hm, isn't it just clojure.test?
21:45shep-homejli: yes, I realized that just a second ago :-)
21:45jli:)
21:45shep-homeno wonder I can't find it in contrib!
21:45jliyeah
21:45shep-homedownside is, that doesn't solve my problem :-\
21:45jliwhy?
21:45clojurebotwhy not?
21:46shep-homeMy original problem is that *something* blows up when I try to run my tests from inside emacs
21:47shep-homeand I found some random pages that point to it being a contrib 1.2 / clojure 1.3 issue
21:50shep-homeand I found some random pages that point to it being a contrib 1.2 / clojure 1.3 issue
21:50shep-homedoh
21:50shep-homeslipped key
21:53jliblows up because it can't find test?
23:43andar__is there a clean way to reload dependencies from lein when using lein-swank in emacs? I've just been running sayoonara in slime repl, then killing the *swank* buffer (since there seems to be a bug re-running clojure-jack-in if that buffer exists)
23:44andar__er when using clojure-swank and clojure mode's 'clojure-jack-in' to be more precise