#clojure logs

2011-06-03

00:02jean-philippeyou can check for common elements between 2 sets with their intersection (using clojure.set.intersection). If the intersection is not empty, the 2 sets have elements in common
00:06bdeshamjean-philippe: the problem is that I've got a vector and I want to see if any elements are duplicated in the vector, including in sets within the vector
00:09jean-philippebdesham: the quick trick would be to see if the sum of the counts of the individual sets is equal to the count of the union of all the sets
00:09bdesham,(count #{})
00:09clojurebot0
00:10bdesham,(count #{#{}})
00:10clojurebot1
00:10bdeshamjean-philippe: I might be able to make that work
00:11jean-philippebdesham: this should flatten deeply nested sets as long as there are no duplicate elements: https://gist.github.com/1005858
00:13jean-philippebdesham: it's quite rough, and you need to (use 'clojure.set) to get union and intersection, but it should give you a starting point
00:15bdeshamjean-philippe: thanks!
00:18rcfoxHey guys, I have a rather newbie question. I'm trying to extend a Java class, and the .class is in the 'classes' directory, which is in my classpath. However, when I try to compile my new class, I get java.lang.ClassNotFoundException.
00:20rcfoxIs there anything I might be missing? Both classes are in the default namespace, if that makes a difference.
00:23rcfoxDoh, I just realized that the classes should go under classes/java/lang.
04:39newbnumber1hi there, I'm new to clojure, and I've been looking around for a guide to getting started with clojure web programming. It's a bit confusing. Most links seem to point to compojure, but it seems to be a fast-moving target. Is there a de-facto "this is the starting point for newbs" concerning clojure web development?
04:44Vinzentnewbnumber1, checkout wiki on the github page of compojure
04:45thorwilnewbnumber1: there's no de-facto starting point. common choices are compojure or moustache, enlive and/or hiccup
04:47gkoRegarding SLIME with CL and Clojure: is it still either or? (CVS for CL, ELPA for Clojure
04:47gko)
04:49apsvxnewbnumber1: i think this: http://brehaut.net/blog/2011/ring_introduction is very good introduction
04:54ordnungswidrigHow can I determine which protocols an instance extends? "extenders" goes the other way round.
04:55fceknewbnumber1: i started with http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html
04:55fcekbut apsvx link looks good
05:08raeknewbnumber1: I would recommend the official readme for Ring - the underlying library of most clojure web apps - and its spec: https://github.com/mmcgrana/ring and https://github.com/mmcgrana/ring/blob/master/SPEC
05:15raekon top of Ring, you use a routing library (Compojure or Moustache) to choose among handlers based on URL and HTTP method and HTML generating libraries (Hiccup or Enlive) to generate the bodies of the responses
05:16raekbe aware that Compojure has changed quite a lot, so if you look at an example, make sure you check which version it is for
05:18newbnumber1reading through these links now, thanks guys :) yes, some tutorials I've seen confused me greatly, but it was compojure that had changed
05:19raeknewbnumber1: the compojure wiki is probably the most up to date tutorial: https://github.com/weavejester/compojure/wiki
07:07bendlashey
07:08bendlasdoes anybody use eshell with zsh here?
07:23LeNsTRbendlas: use 'M-x ansi-term' instead esheel
07:23LeNsTRworks with zsh pretty well
07:54bendlasLeNsTR: thanks
07:54LeNsTR^^
07:55bendlasI know, but I like the feel of eshell a bit better
07:56bendlaszsh works pretty fine with it too, except it doesn't read my .zshrc
08:18mecIs it possible to memoize a local recursive function?
08:18fliebelmec: local?
08:18mecinside a let
08:19fliebelmec: I see no reason you can't do (let [f (memoize (fn [])))?
08:21ilyakhttps://github.com/alamar/clojure-xml-stream Here is my "stateless" stream XML parser
08:21ilyakto declaratively parse huge XML files (larger than memory) into a lazy sequence of entities
08:22mecfliebel: something like (let [f (memoize (fn f [] (f ...)))), it wont memoize the inner calls
08:27opqdonut(fn f [] ...) ?
08:27opqdonut(let [f (memoize (fn [arg] (foo (f ...))))) will actually work
08:27opqdonutusing recur inside the fn won't
08:27opqdonut(s/work/memoize/g)
08:29mec,(let [fib (memoize (fn [n] (if (<= n 1) n (+ (fib (dec n)) (fib (- n 2))))))] (fib 10))
08:29clojurebotjava.lang.Exception: Unable to resolve symbol: fib in this context
08:29mecopqdonut: doesnt allow that
08:30mecand this way isnt actually memoized: #(let [fib (memoize (fn fib [n] (if (<= n 1) n (+ (fib (dec n)) (fib (- n 2))))))] (fib 20))
08:32fliebelmec: I see no reason you can do##(let [fib (memoize (fn [n] (if (<= n 1) n (+ (#'fib (dec n)) (#'fib (- n 2))))))] (fib 10))
08:32sexpbotjava.lang.Exception: Unable to resolve var: fib in this context
08:33fliebel... need a break
08:33opqdonutmec: hmm, letfn should work, right?
08:34opqdonut(my bad)
08:34fliebelopqdonut: But then you can;t memoize
08:34opqdonutah, right
08:34opqdonutgah
08:34Dranikhi all
08:34mecI'm not sure this is possible
08:34mecmaybe i'll have to memoize by hand
08:34fliebelmec: wait, I have an idea!
08:36DranikI have a macro defaction (https://gist.github.com/1006270). It expands to a runnable code -- but only if I run that expanded code manually. When I try it running using this macro -- it fails
08:36Dranikcan anyone have a look at it?
08:37Dranik(macroexpand-1 '(defaction myaction [id post] (println "abc"))) expands to
08:37Dranik(clojure.core/defn myaction [{session :session, {post :post, id :id} :params}] (println "abc"))
08:37Dranikwhich is runnable if u jast paste it and run
08:37fliebel&(let [fib (fn [f n] (if (<= n 1) n (+ (f f (dec n)) (f f (- n 2)))))] (fib (memoize fib) 10))
08:37sexpbot⟹ 55
08:37Dranikbut calling (clojure.core/defn myaction [{session :session, {post :post, id :id} :params}] (println "abc")) doesn't work
08:38fliebelDranik: Error message?
08:39mecfliebel: ah nice
08:39fliebelmec: No, but-ugly, but it works :)
08:39mecsmells like Y combinator
08:39Dranikfliebel: Unable to resolve symbol: :post in this context
08:40Dranikwhich is really weird bcs :post is just a keyword
08:40chouserheh
08:40fliebelmec: Y combinator? I suck at understanding, or wikipedia sucks at explaining.
08:40chouserDranik: ues (keyword p) instead of (symbol ":" p)
08:41chouserwe need to do something about that
08:41chousera keyword is not the same as a symbol that starts with :
08:41fliebelchouser: About what? Ruby guys who confuse keyword and symbol?
08:41Dranikchouser: thanks, that was helpful
08:43chouserfliebel: no, about keywords and symbols that when printed and then read end up different than when they started
08:43chouserperhaps (symbol ":foo") should print as |:foo|, for example.
08:44fliebelchouser: Maybe invalid and unreadable symbols should throw an error?
08:44chouserright, another fine option.
08:44fliebel&(symbol "(")
08:44sexpbot⟹ (
08:45chouserJavaScript doesn't have problems distinguishing between keywords and symbols.
08:46fliebelchouser: Does it even distinguish between anything?
08:46chousernope! :-D
08:50chouser1 + "2" == "12" // just what I wanted!
08:53cemerickmy favorite is:
08:53ChousukeIt's most fun is when you do something silly like window["foo"] = 5; foo + 5 :P
08:53cemerickvar a = {}; a[{c:5}] = 10; a[{d:6}] == 10 // whee!
08:54fliebelcemerick: How does that work?
08:55cemerickfliebel: javascript objects look up values based on the .toString() value of the key provided. Objects' .toString defaults to "[object Object]", so they all hash to the same entry.
08:56cemerickIIRC
08:56bhenryi need the best way to pad a single digit number with a 0. begins as int ends as string.
08:56bhenryi.e. 9 => 09 but 10 => 10
08:57cemerick,(format "%02d" 9) ;<< bhenry
08:57clojurebot"09"
08:58fliebel&(format "%02d" 100)
08:58sexpbot⟹ "100"
08:58bhenrycemerick: thank you
08:58bhenryperfect
09:09mecfliebel: think theres any good way to abstract out this method of memoization?
09:11VinzentI have a problem with vision (https://github.com/nakkaya/vision). When calling query-frame (e.g. (query-frame (capture-from-cap 0))), java process "exited abnormally with code 134". Any ideas how to overcome it?
09:27ordnungswidrigI try to extend a procotol at runtime. However reify is a macro, any ideas besides "eval"?
09:28clgvmec: just skip using that anonymous function and use defn since fib has enough logic to be standalone
09:28Vinzentordnungswidrig, you can use extend to extend the protocol
09:29ordnungswidrigVinzent: correct. I want to reify an existing instance not a type.
09:35stuartsierraYou can't add or change methods of an instance on the JVM.
09:37ordnungswidrigstuartsierra: I'm fine with a new instance that implement another protocol "on top", say like (reify instance-of-A B (method-in-b [arg] )) which will return an instance that implements A and B
09:38stuartsierraLike a wrapper.
09:40ordnungswidrigexactly, in the end I want to build a delegate which takes list of delegates implementing an number of protocols. the wrapper shall then implement all of the procotols and delegate the method invokations to all delegates which implement the invoked method. the results shall be collected into a seq. i.e. the wrapper shall "map" the invokation over the handlers
09:46ordnungswidrighmm, extending an instance at runtime is hard. however, at the time when I want to extend the instance I know all method implementations. So I can relax to problem to "given a list of instances,build a instancen implementing all protocols implemented by all instances where the invokation of any method m defined in any protocol is (fn [_ & args] (map #(apply m % args) instances))
09:47ordnungswidrigSo I can reduce that to applying reify at runtime...
10:46clgvI have a map of maps that might refer to each other via keys and I want to update the map by replacing the keys with the reference to the map belonging to the key. in general this means building a directed acyclic graph
10:48clgvthe only way to accomplish this goal seems to be to perform a topological sorting with respect to the referencing relation
10:56gfrlogcould you do duck-typing in a static language by having every object implicitely implement an interface for each method it defines, and allow function arguments to specify a list of interfaces, one for each method it plans to call?
10:57TimMcgfrlog: ew
10:57gfrlogTimMc: whyso?
10:57gfrlogTimMc: I'm assuming all this happens under the covers
10:58TimMcgfrlog: What's to say that Foo.grovel() and Bar.grovel() are semantically interchangeable?
10:59gfrlogTimMc: nothing, that's the downside to duck-typing generally. I'm trying to get some static-checking out of it, so at least you know that your object can grovel
11:02stuartsierraDoesn't Java allow something like that? e.g. public foo(List<? implements Bar> bars)
11:03gfrlogstuartsierra: I'm not following :/ you have an argument bars of type List?
11:04stuartsierranevermind
11:05gfrlogokay.
11:07stuartsierra"Structural" type systems, where the type of a thing is defined by its capabilities, are sort of like that.
11:07stuartsierraAs opposed to "Nominal" type systems like in Java.
11:08gfrlogAh hah -- something to google. Just what I wanted. @unironic
11:16bendlastechnomancy: is it possible, that slamhound chokes on clojure.contrib.core/-?>
11:16bendlasspecifically on the \?
11:33technomancybendlas: totally possible; maybe open an issue?
11:40bendlastechnomancy: can do that
11:49bendlastechnomancy: https://github.com/technomancy/slamhound/issues/8
11:49technomancythanks
11:50technomancyshame; I just cut a release yestorday
11:50bendlason another note: is it intended, that when i do `lein plugin install marginalia 0.5.1` e.g. from my home dir
11:50bendlasthat it installs its deps in ~/lib/dev/*.jar
11:51technomancyhmm; no that's also a bug; could you report another issue?
11:51bendlask
11:57chewbrancatechnomancy: hey man, sorry I didn't make it back last night, got caught up on some stuff and didn't have time to drive back down south
11:58offby1we ate your brownie.
11:58chewbrancaI missed out on brownies? doh..
11:58bendlashttps://github.com/technomancy/leiningen/issues/209
12:04technomancychewbranca: ah no worries
12:05chewbrancatechnomancy: yeah was bad timing, had that meeting scheduled for weds originally but had to reschedule due to my car being in the shop on weds :/
12:05chewbrancatechnomancy: did I miss anything interesting?
12:06technomancychewbranca: it was pretty low-key, but we had a cool demo of hiredman's pattern matching lib
12:06TimMctechnomancy: What part of the country are you in?
12:07chewbrancatechnomancy: ahhh interesting
12:07technomancyTimMc: seattle
12:07TimMcAh, OK.
12:07TimMcOh right, seajure.
12:10offby1ah, "hiredman". I meant to ask what his real name was :)
12:33timvisherhey all
12:33seancorfield__mornin'
12:34technomancyoffby1: is this your friend you mentioned? https://github.com/paxan
12:34technomancy~guards
12:34clojurebotSEIZE HIM!
12:34timvisheri'm trying to figure out how to use destructuring to get at the keys of a map inside a map, i.e. {:foo {:bar "bar" :biz "biz"}}
12:34dnolenseancorfield__: cool, what's he talking about?
12:34seancorfield__dnolen: all flavors of parallelism, from hardware to explicit concurrent ADTs
12:35hiredmantimvisher: you can't, destructure needs to know the keys to bind the values to names, you cannot do the reverse
12:35dnolenseancorfield__: interesting, got a favorite talk thus far?
12:36seancorfield__nah, lots of academic stuff... interesting from a theory p.o.v. but nothing really grabbed me yesterday
12:36timvisherunless i'm misunderstanding you, i might have worded myself wrong. I'm looking for something like {:keys [bar biz] {:keys [foo]}}
12:36timvisheri don't mind having to specify the names explicitly
12:36timvisheri just can't figure out the nesting
12:36seancorfield__my take away was "implicit (type conversion) is very very powerful but introduces all sorts of problems"
12:36timvishersomeone told me how to do this before
12:36timvisheri just can't remember how
12:37hiredmanseancorfield__: shocking
12:37timvisheri could always use multiple lets
12:38hiredmanseancorfield__: you should grab the mic and call on the people of scaladays to rise as one and throw off the shackles of complexity
12:39raektimvisher: (let [m {:a {:b 1}}, {{b :b} :a} m] b)
12:39raekthe inner destructuring can be written with the {:keys [b]} shortcut (well, in this case it wasn't much shorter...)
12:40timvisherthat! exactly. :)
12:40raekbinding form (symbol or destructuring) to the left and key to the right...
12:40seancorfield__hiredman: lol... i feel like i'm back at university doing CS264
12:41seancorfield__in fact, one talk yesterday specifically referred to CS264
12:41seancorfield__(but i'm british and we don't label courses like that)
12:42seancorfield__doug's talking about concurrent collection libraries using CAS under the hood and self-healing algorithms to maintain internal consistency
12:42dnolenseancorfield__: hammurabi seemed interesting, but I find it humorous that writing 2X-4X the Scala to is improvement over the Jess Lisp syntax.
12:43seancorfield__dnolen: yeah, mario showed the jess example in his talk and complained about duplication of rules in the lisp code
12:43seancorfield__his preso was pretty good tho' but reinforced what i don't like about scala :)
12:46seancorfield__there's definitely some phenomenal work being done in the scala community but there's so much complexity behind the scenes... these two days are making me much more comfortable with choosing clojure for most of our future work at World Singles
12:47rlbThe empty? docs request (seq x) rather than (not (empty? x)). What about the converse? i.e. (if (empty? x) ...)
12:49seancorfield__rlb: not sure what you're asking...?
12:49seancorfield__,(doc empty?)
12:49clojurebot"([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"
12:49rlbIs (if (empty? ) ...) considered idomatic?
12:50rlb(if (empty? x) ...)
12:50seancorfield__ah, because the docs indicate (not (empty? x)) is not idiomatic?
12:50rlbright
12:50rlbjust curious -- trying to adjust to clojure's seq semantics...
12:50seancorfield__i think it's just indicating the complement pair is (empty? x) and (seq x) so you should avoid (not ...)
12:51rlbmakes sense -- just wanted to check.
12:51rlbthx
13:02seancorfield__keynote is over... off to sessions now... may be back on and off during the day
13:05astoddard,(clojure-version)
13:05clojurebot"1.2.0"
13:06astoddard,(sort [5.0 2.0 Double/NaN 3.0])
13:06clojurebot(2.0 5.0 NaN 3.0)
13:10dnolenin a time when people thump the ground about static types yet don't understand the theory of Prolog are sad times indeed ...
13:17astoddard,(sort [5.0 2.0 Double/NaN 3.0])
13:17clojurebot(2.0 5.0 NaN 3.0)
13:18astoddardIs the above behavior of sort with NaNs present likely to remain in 1.3?
13:22rlbCouldn't figure out why things weren't working -- took a while to notice that I'd typed `(foo ,bar) rather than `(foo ~bar).
13:23ataggartThrdb: http://dev.clojure.org/jira/browse/CLJ-738
13:24ataggartrlb: ^
13:24ataggartok, Im gonna stop typing until I've had my coffee
13:36Dranikis there any tutorial on writing a leiningen plugin?
13:37seancorfield__Dranik: https://github.com/technomancy/leiningen/blob/master/PLUGINS.md
13:37Dranikthanks
13:50aaelonyhi - I realize a few things have moved around in contrib. Where are the most up to date docs for the most stable contrib API ?
13:51ataggartold clojure-contrib is stable for 1.2
13:51aaelonylink ?
13:51ataggartto what?
13:51aaelonyI'm looking for contrib that works with clojure 1.2.1
13:52aaelonya doc link
13:52manutteraaelony: have you looked at clojuredocs.org?
13:52ataggarthttp://clojure.github.com/clojure-contrib/
13:52ataggarthttps://github.com/clojure/clojure-contrib/commits/master
13:52manutter(um, or the official site too, I guess ... )
13:53aaelonyyes, I am confused because there is assembla, clojure.org, and there is github, but they are diffs
13:53stuartsierraAssembla is dead and gone.
13:53aaelonyok
13:53aaelonyi guess its not always clear (to me) which doc links are stale (dead or gone)...
13:54TimMcstuartsierra: Dead, but not gone. :-(
13:54stuartsierraclojure.org has conceptual documentation. clojure.github.com has full API docs for every core function/macro.
13:54TimMcIt is still there to confuse newcomers.
13:54stuartsierraNoted. Will raise with Core.
13:54aaelonyI'll check out clojure.github.com for the full API
13:54ataggartaaelony: contrib readme is here https://github.com/clojure/clojure-contrib/blob/master/README.md
13:54aaelonythanks
13:55TimMcstuartsierra: Wait, maybe not... I can't find the old stuff anymore.
13:56stuartsierraYeah, http://www.assembla.com/spaces/clojure/wiki is still there but points to dev.clojure.org on every page.
13:56aaelonyfor example, if I want to use something that reads json files with clojure 1.2.1, do I use clojure.data.json or do i use clojure.contrib.json?
13:57stuartsierraBoth will work. Only clojure.data.json will be continued in the future.
13:57aaelonythnks
13:58aaelonyif I choose clojure.data.json, do I put [org.clojure/data.json "0.1.0"] in my project.clj ?
13:59ataggartaaelony: bear in mind the new contrib stuff may be dependent on features of 1.3, and the old contrib stuff may be dependent on deprecatd features in 1.3
13:59aaelonyataggart: yes, this is what I am getting at
13:59stuartsierraaaelony: yes
13:59aaelonythanks
13:59stuartsierraataggart: Most of new contrib should still work in 1.2, though there are a couple exceptions.
14:00ataggartstuartsierra: true, just wanted to put out that caveat.
14:00stuartsierrayes
14:00ataggartit's an awkward time for someone to begin working with contrib
14:01stuartsierracontrib has always been awkward, but I think we're finally on the right track now
14:01ataggartyes, once 1.3 is released things will be smoother
14:01ataggartthough with the number of breaking changes, calling it 1.3 is a bit of a misnomer
14:02stuartsierraThere's still a possibility it will be called 2.0.
14:02aaelonywell, for example, I have been using contrib for some while but things are changing and I need to update some code. It would be nice to know the things that need to change and how they relate to explicit versions of clojure and contrib
14:03ataggartread the readme I linked to
14:03ilyakIs there something like a catalog of clojure libraries? How does one discover libraries for his needs? Is there a place where this topic is discussed?
14:04aaelonyataggart: saw that
14:04ilyakclojure maillist seems to be about everything and nothing
14:04technomancystuartsierra: it's interesting to me that 1.3 closely follows scala 2.8, which caused much bemoaning of the fact that they didn't name it 3.0.
14:04ataggartsemantic versioning is a Good Thing
14:04stuartsierratechnomancy: People will complain in either case. We did a poll and it was a perfectly even split.
14:04ataggartilyak: same way people find most libs: google
14:05ataggartilyak: clojuredocs might be a good plac to search too
14:05ataggarthttp://clojuredocs.org/libs
14:05ataggarthmm, thought there were more libs there
14:05technomancystuartsierra: well in the case of scala 2.8 is was the maintainers who were the most regretful
14:05manutterclojure toolbox?
14:06manutterhttp://www.clojure-toolbox.com/
14:06manutterilyak: ^
14:06stuartsierraI personally want to call it 2.0, but it's not my decision.
14:07hiredmanthis is how I look for libraries: 1. clojure libraries are generally crappy wrappers around java libs 2. look for java libs 3. write my own
14:07ilyakOkay, thanks
14:07ataggarthiredman: and then release them to compete in the marketplace of libs, right? ;)
14:07hiredmanataggart: depends
14:08stuartsierraI agree with hiredman.
14:08ataggartwriting good libraries for other people's possible usecases is Hard
14:09ataggartsays the guy whose crappy api tiggered the contrib modularity
14:10technomancyataggart: well writing good libraries is especially hard if you don't control the version number.
14:10ataggarttrue dat
14:10technomancyit's easy enough to bump the major version and move on with life =)
14:11hiredmanataggart: it is, but, for example, some of the existing pattern matching libraries for clojure do things like wrap bodies in fns which breaks recur, obviously a non-starter
14:11ataggartwhich I think was also an issue in clojure itself somewhere
14:12hiredmanataggart: oh, sure, very easy for macros to do
14:13hiredmanbut if you have pattern matching you want it to be foundational, which it cannot be if it breaks fundamental parts of the language
14:15ataggartIt'd be nice if there was a better way to froment peer review of code other than just putting up a message in google groups
14:15ataggarts/froment/foment
14:15sexpbot<ataggart> It'd be nice if there was a better way to foment peer review of code other than just putting up a message in google groups
14:16hiredmanthere is some arg parsing library we were looking at to use at work, which generates a nice help message, and then if you ask for help unconditionally calls System/exit
14:16hiredmanwhich is useless for long running processes
14:17hiredmanso we rolled our own, and ours is pretty nice, but part of our closed code base unfortunately
14:17astoddardataggart: I looked at the jira link for the NaN <= bug. The issue with sort is very related but still different to me. Unless the comparator is NaN aware (not just ultimately using <) a NaN containing collection is unsortable.
14:17hiredman(you can specify a set of valid sets of args, and seperately a map of validator functions for each flag)
14:18ataggartastoddard: Double NaNs are sorted as largest Double.
14:18ataggarthiredman: what lib is that?
14:18ataggartthe one that sucks, I mean
14:18hiredmanclargon maybe
14:20dnolenhiredman: yeah wrapping bodies in fns is about structure sharing, it's something I'll have to deal w/ eventually as well ... supporting recur will be tricky.
14:21hiredmanwe have a long running process, and a shell script that acts as a dumb client, the shell script just passes args to the long running process, so calling System/exit is no good
14:43rlbIs there anything like __LINE__ to parallel *file*?
14:43rlbi.e. like __FILE__ __LINE__ in C?
14:44stuartsierraThere's a LINE var in the compiler somewhere. It's not directly exposed but you can get at it.
14:44hiredman,@clojure.lang.Compiler/LINE
14:44clojurebot0
14:44stuartsierrathat
14:44hiredmanwell, it is public
14:45rlbOK, thanks -- just wanted something for some quick, temporary debug messages.
14:59rlbIs it acceptable to use defmacro to create a local macro within a function?
15:00stuartsierrano
15:00stuartsierraClojure doesn't have local macros (yet).
15:00rlbso is macrolet the right thing to use?
15:00stuartsierraIf there were a macrolet, yes.
15:01rlb(via clojure-contrib.macro-utils)
15:01mrBlissor tools.macro: https://github.com/clojure/tools.macro/blob/master/src/main/clojure/clojure/tools/macro.clj#L202
15:01stuartsierraThat will work in most cases, but it's not a complete solution.
15:01rlbok, thanks -- I don't have to have it, of course. I'll probably just leave it off for now.
15:02stuartsierrahttp://dev.clojure.org/display/design/letmacro
15:05mrBliss,(letfn [(f [& args] (if (zero? (first args)) (second args) (recur (dec (first args)) (inc (second args)))))] (f 3 4))
15:05clojurebotjava.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 1 args, got: 2
15:05mrBlissIt seems that one cannot recur when using a variable number of arguments
15:06hiredmanyou can, you have to box your args though
15:06hiredmanargs is a seq, so if you recur to args you have to pass something seq-like (list or vector or seq)
15:07mrBlisshiredman: thanks
15:19rlbIs there a way to stop ` from qualifying symbol names? I just want the list (= x y), not (clojure.core/= x y).
15:20rlbThe context is wrt a test assertion, i.e. `(... (pprint-str '(= ~x ~y)))
15:20stuartsierra~'x will do it
15:20clojurebot2009:Jan:29:16:03:17 <hiredman> I call Xiphojura
15:21rlbAh, of course; thanks.
15:25aav_away$seen lpetit
15:25sexpbotlpetit was last seen quitting 1 week and 2 days ago.
16:17Dranikhow to check the equality of strings?
16:18manutter,(.compareToIgnoreCase "foo" "bar")
16:18clojurebot4
16:18manutterok, that's a bit different than I expected
16:18ataggart,(= "foo" "bar")
16:18clojurebotfalse
16:18manutter,(= "foo" "foo")
16:18clojurebottrue
16:19manutter,(> "foo" "bar")
16:19clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
16:19manutter,(.compareTo "bar" "foo")
16:19clojurebot-4
16:20Dranikmanutter: thanks
16:20manutterSo plain old = works for equality, but you have to use .compareTo or .compareToIgnoreCase for > or <
16:20manutterDranik: anytime
16:20Dranikmanutter: does the = call native java "equal" method?
16:20manutterI just did this for one of the 4clojure probs :)
16:20manutterNot sure what the = does
16:21dnolen,(doc =)
16:21clojurebot"([x] [x y] [x y & more]); Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) as a value, not an identity, comparison."
16:21manutter~botsnack
16:21clojurebotThanks, but I prefer chocolate
16:21manutter~chocolate
16:22clojurebotTitim gan éirí ort.
16:22manutterHa!
16:22dnolen~pizza
16:22clojurebotNo entiendo
17:33arohneris there a good way to determine how much memory an object is using?
17:33stuartsierraarohner: Only with a JVM profiler.
17:54arohnerstuartsierra: http://sizeof.sourceforge.net/
17:56stuartsierracool
19:24duck1123can anyone tell me where clojure.contrib.duck-streams/pwd went?
19:24duck1123I hate trying to track down the new locations of missing functions
19:25hiredmanduck1123: it was most like decided to be junk and not promoted to other places when the rest of duckstreams was
19:26hiredmanhttps://github.com/richhickey/clojure-contrib/blob/061f3d5b45657a89faa335ffa2bb80819f2e6918/src/main/clojure/clojure/contrib/duck_streams.clj#L270
19:26hiredmanit's not really 'pwd'
19:26technomancyduck1123: (System/getProperty "user.dir")
19:26hiredmanit is "the value of the mutable system property 'user.dir'"
19:27aavramyes, i think the refactorings are good, but there is a real sense of "who moved my cheese?
19:27aavram"
19:27duck1123Okay. I'm trying to fix up aleph for 1.3 and couldn't find that one. Glad I don't need another dep
19:28technomancyaavram: well the whole point of contrib was "we don't know if this is good yet."
19:28aavrami understand
19:28TimMctechnomancy: reminds me of javax.*
19:28technomancythe problem was there was a genuine need for a standard library, and contrib was used as that even though that wasn't what it was intended for
19:29duck1123I definitely believe that when it's all done and moved it'll be good. It's just a pain right now
19:30duck1123I went through all of the dependencies in my project last weekend and removed every trace of c.c 1.2
19:30TimMcI'm not familiar with the details of this refactoring -- has there been any effort to make a consistent API for code that needs to be compatible with both 1.2 and 1.3?
19:31aavrammaybe it would be good to have lein give warnings like: "you are using libs a and b. if you use lib-a version 1.0 you need to use lib-b version 1.1" or something
19:31hiredmanclojure.core is largely the same, contrib is the big change
19:32duck1123also minor issues like dynamics, and potemkin doesn't work when you pass it a symbol
19:32hiredmanpotemkin?
19:33duck1123it's a lib that is used in aleph and lamina. It's essentially compojure's old immegrate
19:33hiredmanugh
19:33duck1123but on a fn by fn level
19:33hiredmandigusting, glad it's broken
19:33duck1123never been a fan myself honestly
20:45lpetithello
20:47scottjque pachuca por toluca
20:47lpetitI've a very basic ring question : based on some handler logic, I'd like to serve a success file or a failure file. Those files would be in my webapp, for example at <webappContextProvidedByTomcat>/someSubdir/success and <webappContextProvidedByTomcat>/someSubdir/error
20:49lpetitIn "basic" JEE, I know how to do this: I call request.getContext() to get the "http://&lt;server&gt;:&lt;port&gt;/&lt;webappContextProvidedByTomcat&gt;&quot; part of the URL (parts on which my webapp will have, of course, no control). And my handler can just add the webapp-relative part: /someSubdir/succes
20:49lpetitI don't know how to do this with Ring :-(
20:55scottjdoes this work (-> request :servlet-request .getContextPath)
20:56scottjring ml thread "Accessing HttpServletRequest object in the request-map" idk
20:58lpetitscottj: I'll see, thanks. I was working right from the SPEC document, and didn't know about these specific keys added by the adapter
21:01Guest2285is there a way to ignore a line break in multiline strings in clojure
21:02scottjGuest2285: don't think so
21:03Guest2285such as in python if you have a newline immediately following the \ character in a multiline string the newline gets ignored?
21:25rahulkmrWhat's the idiomatic way to do byte io in clojure? I can wrap Java streams for one
21:26brehautrahulkmr: have you looked at the clojure.java.io module?
21:27rahulkmrWhat are the IOFactory docs it talks about?
21:28rahulkmrUsage: (input-stream x & opts)
21:28rahulkmrAnd I can't find explanation for & opts
21:28rahulkmroh got it
21:28rahulkmr:append and :encoding
21:31rahulkmrIn clojure.java.io make-* and * function seem to be saying the same thing. For eg. output-stream and make-output-stream. Just that output-stream has bigger docs
21:33brehautrahulkmr: im no expert but i think you probably use the non-make versions most of the time
21:35brehautrahulkmr: basicly the idiomatic way is to use the io utilities where possible, but otherwise you just do java IO
21:35rahulkmrYep. got it output-stream uses make-output-stream https://gist.github.com/1007447
21:36rahulkmrgotta love clojure.repl.source
21:36offby1do I _gotta_?
21:37brehautsource is pretty great but apropos still wins for my favorite repl util
21:38rahulkmrYes. apropos is great but I do a lot of (use..) in repl. My ns are polluted like anything
21:40quizmeif I do a (doseq) on a clojurql query that operates on millions of rows, will that put the whole seq into memory? I want to just work the seq one item at a time, then have the jvm garbage collect along the way. how do i do that?
21:40brehautquizme: look at dorun: it doesnt hold the head and returns nil
21:41brehautactually, doseq also doesnt hold the head and returns nil
21:43quizmebrehaut ok so doseq should do the trick i guess, thanks.