#clojure logs

2010-03-31

00:00hiredman(vector (rand-int 10) (rand-int 10)) is not a function
00:00cemerickmcburton: (defn random-vectors [] (repeatedly #(vector (rand-int 100) (rand-int 100)))
00:00mcburtonoh yea, I forgot the #
00:00mcburtonwas typing too fast :)
00:00cemerickthe notion of a wrapper fn that takes a count that's provided to take, drop, et al. is bad IMO
00:01cemerickcertainly not idiomatic. Implement the base case, and then slice and dice as needed using core fns.
00:02carkhthere once was a re-split function in c.c.str-utils, does it still exist ?
00:02carkhwith some other name maybe ?
00:02mcburtoncamerick: so how exactly would that work?
00:02hiredmanstr-utils no longer exists
00:03cemerickmcburton: (take 10 (random-vectors))
00:03cemerickor whatever
00:03carkhhiredman:right =/
00:03hiredmancarkh: renamed to strings
00:04carkhhum c.c.strings/partition seems like it
00:04mcburtoncamerick: that doesn't work "Don't know how to create ISeq from: user$random_vectors__2351"
00:04hiredmanyou are missing parens
00:05mcburtoni fixed that
00:05woobyhttp://gist.github.com/349922 maybe
00:05woobymcburton,
00:05woobymaybe lazy-seq is overkill? i just was under the impression repeatedly was for side effects
00:06hiredmanwooby: rand-inisn't a pure function
00:07woobyahh
00:07cemerickyeah, that docstring is slightly off
00:08hiredmanif you find yourself thinking of calling lazy-seq directly you may want to re-think
00:09cemerickwooby: the no-args part is what distinguishes cases where repeatedly is sufficient
00:10woobyso perhaps
00:10wooby,(take 3 (map #(apply vector %) (partition 2 (repeatedly #(rand-int 100)))))
00:10clojurebot([4 12] [30 68] [89 60])
00:11mcburtonhey thats handy
00:11cemerickwooby: of course, that's not worth if it you're not parameterizing the partition, but sure
00:11cemerickalthough use (map vec ...)
00:12woobyoh right
00:12woobythanks for the tips cemerick, hiredman
00:12woobyand gl mcburton i'm headed out
00:12cemericknp
00:13wooby:) clojure rocks so hard
00:13cemerickwooby: make sure you pass it along :-)
00:13woobyi am! giving presentation this weekend
00:13cemerickExcellent! Make some gentle noise about it in the world.
00:14woobyplanning on it, g'night
00:14mcburtonthanks for the tips!
00:14mcburtonnite
00:14mcburtoni'm off to
00:14woobywhich reminds me, if anyone is in rochester NY / western NY, rochester barcamp is on saturday
00:15woobyfeel free to drop in on my clojure talk and correct me on stuff :)
00:15cemerickbit of a hike for me, but good luck anyway
00:15woobythank you sir, adios
00:52Crowb4rcemerick: Yeah
00:52cemerickCrowb4r: I've never used it. Compojure + enlive is more my style.
00:52Crowb4rahh
00:52cemericksexprs for html generation doesn't make any sense to me.
00:53Crowb4rconjure seems like rails.
00:53cemerickand I don't generally use RDBMS, so the ORM bit never attracted me
00:54cemerickSee, I always like pylons, which was far closer to the metal, as it were.
00:54cemericks/like/liked
00:56woobyhm, having a problem here with midi interaction: http://paste.lisp.org/display/97119#1
00:56woobyi found an irc log where rhickey mentions this particular problem, but not the fix
00:57woobyor at least, his explanation of why is beyond me
00:59cemerickwooby: clojure generally respects the access restrictions of methods and fields, though you can work around them with reflection.
01:01woobycemerick, i see
01:02hiredmanwooby: you have to find something public higher up the class hierarchy that exposes what you want and hint with that
01:02woobygot it
01:02woobydoes the java compiler do that kind of thing automatically?
01:03hiredmanI doubt the "equivalent java code" is equivalent
01:05cemerickwooby: if you hint synth with #^Synthesizer, that code should work
01:05woobyMidiChannel[] channels = synth.getChannels();
01:06hiredmanwooby: in what package?
01:06woobyjavax.sound.midi
01:06hiredmanwooby: exactly
01:07hiredmanthe java code is in the same package
01:07cemerickright, so (.getChannels #^Synthesizer synth) works fine
01:07woobyaha
01:07cemerickthe java code is only aware of the statically-declared interface, whereas clojure gets "thrown off" by the runtime type.
01:08woobythat is interesting
01:14Crowb4rwhat si the code to show which version of clojure you are using in the repl?
01:14Crowb4ror in a script in general
01:14woobyhiredman, thanks, we're in business now
01:23kencauseyCrowb4r: *clojure-version*, by the way a quick search of the api page...
01:47dnolenis there a function which returns the _last_ logical true value?
01:50noidimaybe (last (filter identity foo)) ?
01:52noidi,(last (filter identity [1 false nil 3 true nil 2 nil]))
01:52clojurebot2
01:52dnolennice turns I don't need anything that fancy anyway :) (fn [a b] (if b b a)) is good enuf for me, I'm using it with merge-with.
01:53noidiok
01:54noidiyou can do that with #(or %2 %1)
01:54noidi...I think
01:56noidihmm... that's odd
01:56noidi,(#(or %2 %1) false nil)
01:56clojurebotfalse
01:56noidi,(doc or)
01:56clojurebot"([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns a logical true value, or returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expression. (or) returns nil."
01:56noidi,(#(or %2 %1) false :truthy)
01:56clojurebot:truthy
01:57noidishouldn't it return nil in the first case?
01:57dnolenhuh, it seems like it should to me.
01:57noidi,(or false nil)
01:57clojurebotnil
01:58dnolener noidi: you're reversing the args
01:58dnolen%2 %1
01:59dnolenanyways: #(or %2 %1) does what I want thx.
01:59noidiah that's right, I forgot that I started with your snippet :D
01:59dnolenI did too :D
02:25naeuI came across the following example macro which I'm still struggling to understand: (defmacro outer [& body] `(let [~'x 5] (do ~@body)))
02:26naeucould anyone explain why we need ~'x rather than just x?
02:26RaynesI know why, but I don't know how to put it into words. :|
02:26_ato,(macroexpand `x)
02:26clojurebotsandbox/x
02:27_ato,(macroexpand `~'x)
02:27clojurebotx
02:27RaynesAh, yes.
02:27_atosyntax-quote (`) resolves symbols to their full namespace
02:27_atothe reason for this is you might use a macro from one namespace in another
02:28naeuok, so ~' resolves symbols to the current lexical scope unamespaced?
02:28_atoin this case you actually want to do symbol capture, which most of the time is usually not what you want a macro to do, so you have to override it with ~'
02:28_ato,(let [x 1] `x)
02:28clojurebotsandbox/x
02:28_ato,(let [x 1] `~x)
02:28clojurebot1
02:28_ato,(let [x 1] `~'x)
02:28clojurebotx
02:30_atoso yes, by unquoting and then requoting with a normal quote instead of syntax quote it leaves it unamespaced
02:30naeuhmm, i'll still have to give that a bit of time to seep into my conscious
02:31naeualso, why do we need to deref body?
02:31_atoah
02:31naeuis that because its in a do form?
02:32_ato~@ is splicing unquote
02:32clojurebotAck. Ack.
02:32_ato,(let [x [1 2 3]] `(foo ~@x bar))
02:32clojurebot(sandbox/foo 1 2 3 sandbox/bar)
02:32_ato,(let [x [1 2 3]] `(foo ~x bar))
02:32clojurebot(sandbox/foo [1 2 3] sandbox/bar)
02:33_atosee the difference?
02:33_atobecause if you pass in (something) (something-else)
02:33naeuah ok
02:33naeuit's like Ruby's splat
02:33_atoyou want the macro to look like (do (something) (something-else)) not (do ((something) (something-else)))
02:34naeucool
02:35naeui believe i get that :-)
02:53naeuthanks everyone for your help :-)
02:53naeuLauJensen: hey there
02:54LauJensenMorning :)
02:56naeuLauJensen: just thought I'd make a connection in your head - I'm Sam Aaron the chap that you've been kindly helping out in your blog recently
02:56naeuthanks to _ato I believe I understand your latest macro example :-)
02:59LauJensennaeu: Ah okay - Nice to meet you. What did the trick for you, in terms of understanding?
03:00naeufor your implementation of diffuse-board you're essentially assuming the presence of a context-setting macro
03:00Raynesnaeu: Oh! You're Sam Aaron!?
03:00RaynesHai, Sam!
03:00naeuLauJensen: nothing in particular actually - the problem was that I was missing a few key notions which combined
03:00naeuRaynes: hey there :-)
03:00LauJensennaeu: Ah ok - But yes 'context-setting macro' is the more concise way to put it I think :)
03:00RaynesLauJensen: He and I are both Ioke guys (he more than I, but still). :D
03:01RaynesI get around.
03:01naeu:-)
03:01LauJensenRaynes: Yea I remember being very impressed by the Ioke version of the Transient News Reader I did
03:01RaynesI remember finding 2 huge bugs in 2 weeks with 2 small programs. :D
03:01RaynesAfter that, smooooth sailing. ;)
03:01naeuI recently wrote Conway's Game of Life in Ioke - not sure if you've seen it
03:02Raynesnaeu: I was the one who told you to put it on rosettacode.
03:02LauJensenAlso caught that, yea
03:02RaynesDon't know if you did or not.
03:02naeuRaynes: ah, yes, that makes sense
03:02naeuI should do that
03:02naeuhttp://sam.aaron.name/2010/03/29/conway-s-game-of-life-in-ioke.html
03:03RaynesI've put a bunch of examples there. As a matter of fact, last time I checked, I had written all of the Ioke examples. I figure someday someone smarter than I will come through and make them all better.
03:03LauJensennaeu: Its hard to read source with the formatting you use on your blog though
03:03RaynesUntil then, I put some examples in which I tried my best on to try to give the language a bit more exposure.
03:03naeuLauJensen: what do you suggest?
03:03LauJensendarker color for the background, than used for the text :)
03:04LauJensenOn my screen your variable names like nextGrid are almost the same color as the background
03:04naeuah, that sucks
03:04RaynesSame here.
03:04RaynesAnd with a headache, it isn't pretty.
03:04naeuhahaha
03:05naeuI'll look into it and hook back with you to see if it's any better
03:05naeuI typically program with a dark background, but for the blog i'm happy with a light background
03:05naeuhowever contrast issues on other screens are something I didn't consider
03:05naeu(on my screen it looks fine)
03:06naeuright, i'd better head to work
03:06naeunice chatting with you :-)
03:07LauJensenYea - Can we expect you to be spending a little more time in #clojure henceforth? :)
03:07RaynesWe'd miss you otherwise.
03:07naeuLauJensen: you certainly can :-)
03:07Raynes<3
03:07LauJensenGreat
03:07naeuIoke is fun, but Clojure is useful
03:07Rayneso/
03:07LauJensenIoke isn't useful?
03:08naeuand wait till I tell you my plans for next year
03:08RaynesIt's useful, but meh.
03:08noidiis there a version of doto that allows references to the object itself?
03:08naeuI've not yet found a use for Ioke. I'm assuming it will be great for internal DSLs and creating data structures that can be interpreted by Clojure
03:08Raynes,(clojure.contrib.duck-streams/slurp* "www.google.com")
03:08clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission www.google.com read)
03:08noidie.g. (doto (JSpinner. (SpinnerNumberModel. default min max step)) (.setEditor (JSpinner$NumberEditor. % "#")))
03:09RaynesAnyways.
03:09LauJensennaeu: I have to say though, that despite me not sharing your facination with pink in any way, you've done an amazing job at designing your website, quite unique
03:09naeuIoke isn't yet good (and may never be) for implementing process, but is good for describing it
03:09noidiwhere the % would be the "doto object"
03:09naeuLauJensen: thanks very much
03:09naeuLauJensen: I'm no designer, so that's a big compliment!
03:10naeuLauJensen: if you have any tips on how to improve it I'm always listening
03:10naeuright i should dash
03:10naeuchat later :-)
03:10LauJensennaeu: No tips, but I would change pink to dark blue - but I'm biased for hating that color :)
03:10LauJensenBye bye :)
03:11RaynesI <3 JSON.
03:15LauJensenRaynes: I think I'll make a Ioke vs Clojure
03:15RaynesLauJensen: You're my hero, you know that right?
03:15LauJensenIt'll just be a Venn diagram though.. ( Useful language ) ( Useless languages )
03:15LauJensen:D Thanks
03:15RaynesBiased, or just plain wrong, it's absolutely exhilarating to read your comparisons.
03:16LauJensenwr0ng?!
03:24noidiis there a version of replace that recurses into subcolls?
03:27woobynoidi, in clojure.walk
03:29noidiwooby, thanks!
03:29woobynoidi, no trubs
04:04RaynesHow can I create an empty file somewhere?
04:06RaynesScratch that, missed the method in File
04:32woobyman, fill-queue is ingenious
04:42esjwooby: yeah, this one too: http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/
04:44woobywow
05:00Fossihiredman: i'll fork lein-gae tomorrow and update it, just so you know
05:39cgrandesj & wooby, for your eyes only: it's a stunt don't use that in production code!
05:43woobycgrand, it's ok, it's good enough for academic work :)
05:43esjcgrand: rats! I was about to do just that, its a perfect fit. What do you suggest to fill a blocking queue from a callback function ?
05:43esji'm a bit confused with all the options right now
05:45cgrandesj: a java queue :-) (beware of nils though)
05:46esjcgrand: bummer ! Thanks for the advice though.
05:48woobyfill-queue is workin' nicely for me
05:49pao#linux
05:49Fossino
05:50Fossior, yes, actually
05:50Fossiboth
05:58cgrandesj: http://gist.github.com/350146 -- a replacement for pipe using a java queue
05:58esjcgrand: merci, merci !
05:59cgrandesj: eer, posted too quickly
06:00bsteuberce n'est pas une pipe! :)
06:01cgrandesj ok, the 3rd revision seems ok
06:02cgrandbsteuber, actually I considered "Ceci n'est pas une pipe" as a potential title for http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/
06:02esjlol
06:02woobyhttp://gist.github.com/350150 yay
06:02bsteubercgrand: sorry for my bad repitition, culture is not my strengh :)
06:03esjwooby: nice !
06:03woobythank you!
06:04woobyi enjoy it so much more than my java version
06:04woobyi think it even sounds better ;)
06:05esjclojure has more soul
06:16esjIs this insane: I have a concrete datatype over which I can get a seq. It lives in a reference type and is added to by another thread frequently. I want to return a seq over this data such that the seq blocks when it reaches the end, until new data has been added at which point it moves forward. Is there a suggestion on how to do that ?
06:18cgrandesj will you deref you reference type anywhere except in the seq producing code?
06:18esjyes. I'm hoping to have multiples of this seq
06:20cgrandmultiple different seqs by instance of this reference type?
06:21esjyes
06:22esji want to use the data as the basis for multiple different calculations. I'm hoping to do so in a dataflow way.
06:24LauJensenEmacs users, if you dont have this in .emacs, please insert (add-hook 'before-save-hook 'delete-trailing-whitespace)
06:24cgrandesj: try to add a watch to the ref type, watch which enqueues in a pipe then compute the derived seqs by mapping/mapcatting the seq view of the pipe
06:25esjcgrand: that's brilliant !
06:26esjLauJensen: will do.
06:30hiredman:(
06:30hiredmanesj: you should repeatedly [romise
06:30hiredmanesj: you should repeatedly promise
06:36esjhiredman: i was trying to figure out how to do that without spinning, but couldn't figure it.
06:37esjhiredman: do you mean a seq of promises, into which I then deliver ?
06:37hiredmanright
06:38esjbecause that looks like cgrand's code, which he warned me not to use :)
06:41hiredmanesj: promises block until delivered to, no need to spin
06:42esjhiredman: yeah, I get what you're saying. A seq of promises, on the callback deliver the promise. No spinning.
06:42esjthanks
06:44noidibtw, I wrote the version of doto that I asked about a few hours ago http://gist.github.com/350177
06:44noidialong with an example of the kind of code I wanted it for
06:44woobyhttp://gist.github.com/350182
06:45woobywould anyone happen to know why that's throwing "unexpected param type?"
06:48LauJensennoidi: I would prefer (doto [obj (JSpinner.)] (.setSomething obj x y z))
06:58esjhiredman: FTAOD, would you suggest using a watch on the reference type to trigger the deliver, as per cgrand's suggestion ?
06:59noidiLauJensen, so a let-like marker definition instead of the fixed "$" marker?
06:59LauJensenexactly
07:00LauJensen(defmacro unto [bindings & body] ..) just like everything else in Clojure :)
07:00noidithat makes sense. I'll update the macro. Thanks for the mini code review! :)
07:02LauJensennp
07:11patrkrisdoes anyone know what happened to decorators in compojure 0.4.0?
07:20noidiLauJensen, I gave it a go, but there was really no benefit over nesting a let and a doto
07:21noidiso I'll stick with doto$, which is brief when I don't care about the object's name
07:22noidiit's a bit like #(+ % 2) vs. #([x] (+ x 2)) vs. (fn [x] (+ x 2))
07:23noidithe middle ground does not bring much benefit over the long form
07:23noidibut it was worth a try!
07:34LauJensennoidi: alright :)
08:00carkhis anybody aware of a compojure version that will work with clojure master 1.2.0 ?
08:04esjIs it a REPL artifact (first (map prn [1 2 3 4 5 6])) that all of these get printed ?
08:05_atonope
08:05_atoit's chunked sequences!
08:05_atohttp://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/
08:05esjaaaaaaaaaaah ! thanks, I forgot about that
08:08Fossioh, i missed the new book
08:13caljunior,(char 1)
08:13clojurebot\
08:16raek,(char 7)
08:16clojurebot\
08:17fogus,(map char [1 2 3 4 5 6 7])
08:17clojurebot(\ \ \ \ \ \)
08:20raek,(str \return \newline "PRIVMSG #clojure :hello world")
08:20clojurebot"\r\nPRIVMSG #clojure :hello world"
08:20_ato,(println \return \newline "PRIVMSG #clojure :hello world")
08:20clojurebot PRIVMSG #clojure :hello world
08:20fogusSomeone should write a function that plays "Sunday Bloody Sunday" using (char 7)
08:22wooby,(apply str (map char [0x67 0x6F 0x6F 0x64 0x20 0x6D 0x6F 0x72 0x6E 0x69 0x6E 0x67]))
08:22clojurebot"good morning"
08:46esjwhen is the cached value in a lazy-seq eligible for GC ? For instance: A lazy-seq claims to cache values for future use, yet something like (nth (range 1 a-huge-number) a-huge-number) shouldn't consume the heap ? So when does the cached value get released ?
08:54raekI guess the cached value get released when the lazy-seq object and all other objects that has a reference to that value have been released
08:55esji thought so at first, but now think otherwise
08:55esjex 1: (def a (range big-num)); (nth a big-num) --- will exceed the heap and blow up, as expected
08:56esjbut ex2: (nth (range a-big-num) a-big-num) does not, so it can't be keeping the entire cache live
08:57rhickeydeftype and defrecord - objections?
08:57esjso nth must be 'letting go' of values as it goes
08:59bsteuberrhickey: sounds okay to me
09:00bsteuberesj: I guess because a stores the head of your sequence, it will get realized when processing
09:01bsteuberwhat will (nth (seq a)) do?
09:04esjbsteuber: that blew up too
09:06esjI completely understand why ex 1 explodes and if lazy seq didn't do any caching how ex 2 wouldn't, but if it does cache then ex 2 not blowing up confuses me. Sigh.
09:06raekrhickey: sounds good to me
09:07raekso, record doesn't sound to DB-ish?
09:07rhickeyraek: like many CS words, it's overloaded
09:08raekyeah
09:08esjjust like many CS'tist
09:09raekin Ada, record is simply the name for structs
09:09hoeckstructs in pascal are called records too
09:10raekwhich, IMHO, is the static languages' equivalent of maps
09:10raekso for me, "record" sounds natural
09:11Borkdude,(defn foo [n] (+ n 1))
09:11clojurebotDENIED
09:11raekI guess it depends on what background one has
09:11BorkdudeI was wondering if clojurebot keeps track of previously defined stuff like a REPL does
09:12Borkdude,(def test 1)
09:12clojurebotDENIED
09:12raekrhickey: is the possible keys of a defrecord limited to those declared, or can one have more keys, as in defstructs?
09:12Borkdudebut apparently defining stuff is forbidden
09:12rhickeyraek: they are extensible
09:13fogusBorkdude: Use let
09:13fogus,(let [foo #(+ % 1)] (foo 100))
09:13clojurebot101
09:14raekok, so they're just like ordinary maps, but have some field-backed entries?
09:21cgrandraek: and you can implement protocols on them
09:23Borkdudefogus, ok
09:25djpowelldeftype and defrecord sound ok. i didn't like the full map-y construct having a name that is based on the minimal construct, but longer, cause it makes the minimal one sound more important
09:26djpowelleg defmaptype
09:26dnolencgrand: btw, I really like the middleware syntax in moustache. does it always affect all handlers after it?
09:26dnolen(app mw1 h1 mw2 h2), will mw1 be applied to h2?
09:27djpowelli wonder whether deftype should have a lamer sounding name though?
09:27djpowellsquatting the noun 'type', for something mostly used for low-level interop stuff might be regrettable?
09:28Licenserhmm what is defrecord?
09:28Licenser,(doc defrecord)
09:28clojurebotI don't understand.
09:29djpowellit is a proposed new name for deftype with full support for metadata and extensible keys
09:29chouserdeftype is not for interop, it's for building datastructures, particularly ones that should act like maps
09:29Licenserah
09:30chouserdeftype is not for interop, it's for building datastructures, particularly ones that should act like maps
09:31chouserthe things you'd need for interop (extending concrete classes, adding annotations, etc.) will never be there
09:32raekso, if I wanted to implement hash-bag and sorted-bag, I would do it with deftype?
09:32chousersure
09:32cgranddnolen: (app mw1 h1 mw2 h2) is not supposed to work
09:32djpowellso that deftype is for building things that implement their own map lookup
09:33chouserraek: you couldn't use defrecord because you'd want (:user-key my-hash-bag) to work, but with defrecord that key would be looking up a field of your bag data structure node
09:33chouserright
09:34chouserand is probably appropriate for other constructs at that level, like a vector- or list-like thing that users probably won't be doing key lookups on anyway, but you still don't really want to expose your internal fields as keywords to be looked up
09:34djpowellyeah
09:36chouserbut as soon as your keys are app-level fields, and your methods are domain-specific logic, you want defrecord to be handling all the key/field access stuff so your code can consentrarte on the application task.
09:36dnolencgrand: I see wasn't looking closely enough.
09:36djpowelli like defrecord as a name for the full map thing
09:36chouserwhich is an interesting separation of concerns. Most languages work hard to unify those two, don't they?
09:38chouserYour application-level C++ classes still have the powers granted to low-level types. You might want to override operators for your linked-list type, but do you really want to on your Person or CustomerContact class?
09:38cgranddnolen: but middlewares affect all nested handlers
09:39chouserrhickey: so "def" can work with more than Vars?
09:40dnolencgrand: yeah I got that bit. middleware + enlive could be interesting. I understand your idea from before. An app can just deliver data and be customizable with templates as middle.
09:40dnolenmiddle -> middelware
09:41cgranddnolen: exactly!
09:44dnolenmoustache's design make it easy to come to this realization :)
09:46djpowellis it perl that calls things that look like builtin datastructures, but with custom implementations 'ties'? copying perl might not be a great idea though, and i realise that deftypes can do more than that...
09:48stuartsierradjpowell: yes, Perl has Tie::File and other Tie::*s
10:09powr-tocDoes anyone know why I'm getting this stacktrace when running lein test? http://gist.github.com/350350
10:14hugodcgrand: would you have a moustache example for servlets?
10:15esjcgrand: your pipe gist this morning is exactly the medicine I needed, much thanks.
10:17cgrandesj: you're welcome
10:19raekfogus: awesome!
10:19neotykHi Everyone
10:20neotykis it possible to compile java code with leiningen?
10:21powr-tocfogus: congratulations... can you say what it is?
10:21powr-tocneotyk: I think you can just use the javac ant task from lancet
10:22foguspowr-toc: At the moment its only support tools. Tree walking/manip stuff
10:22Borkdudeah support tools, that's how I tried to use F# when I was a .NET developer
10:22powr-tocCan anyone else confirm that lein test works with lein 1.1.0?
10:23Borkdudeit's probably the easiest way to sneak in some code from your favorite language, a friend fo mine uses Common Lisp tools
10:23cgrandhugod: nothing specific to Moustache here since it works on top of Ring (and I can't find an example of a genclassed servlet adapter for Ring. Anyone has such a thing handy?)
10:24hugodcgrand: thanks for checking - I couldn't find one either
10:24powr-tocfor me even running lein test from within the lein project generates the stacktrace I pasted above :-\
10:25stuartsierrachouser: is deftype distinct from defrecord in 1.2 currently?
10:25chouserdefrecord will be like (deftype ... clojure.lang.IPersistentMap) is now, I think
10:25Borkdudefogus, you managed to write a book on clojure but not having written work-related code in it beofre?
10:26fogusBorkdude: right. All previous work was free-time stuff.
10:27Borkdudeok
10:27BorkdudeI posted some corrections on the forum
10:27Borkdudeonly typo's
10:27Borkdudehttp://www.manning-sandbox.com/thread.jspa?threadID=37212&amp;tstart=0
10:28fogusThanks for that. Every typo is a dagger in my heart, but you've helped to alleviate that pain.
10:28cgrandhugod: nearly found it: http://github.com/mmcgrana/ring/blob/master/ring-servlet/src/ring/util/servlet.clj#L128
10:28powr-tocahh its ok... I've fixed it
10:28Borkdudesome you can easily prevent with a spelling checker ;)
10:28Borkdudebut I'm glad to help
10:28powr-tocI'd forgotten I'd been hacking with lein, and had tried updating the dependency inside it to a newer version... needless to say thats why it wasnt working!
10:29cgrandhugod: so you simply write you ns decl with :genclass [HttpServlet] and add a (defservice my-app) to implement the service method.
10:29neotykpowr-toc: there is javac for lein http://github.com/antoniogarrote/lein-javac
10:30powr-tocneotyk: ahh cool... even better!
10:30hugodcgrand: that's what I have, but keep getting class not found exceptions when I try running it..
10:31cgrandwhich class is not found?
10:31hugodmy genclassed servlet
10:32powr-tocfogus: btw... you listed me in your thanks section at: http://blog.fogus.me/2010/01/11/writing-the-next-clojure-book/ but I'm not sure why! :-) What did I do to help?! :-)
10:32hugodI am assuming that the ns is the classname to put into the web.xml
10:33cp2powr-toc: moral support!
10:33powr-toccp2: lol...
10:33fogusI don't see the name powr-toc in my thanks list. ;-)
10:33powr-toccp2: but then I think every active clojure programmer is providing that :-)
10:34powr-toc<-- Rick Moynihan
10:34cp2powr-toc: i don't give myself too much credit, i just idle most of the time :)
10:35cp2fogus: incase you weren't aware already, your purchase link is broken
10:35cp2well, broken in the sense of valid url, broken page
10:35foguspowr-toc: You reviewed an early proposal. Thanks for that. Very nice feedback
10:35Drakesonhow can I generate an object that pretends to be subclass of some java class?
10:36Drakesondo I have to use proxy?
10:36foguscp2: I thought we had fixed it. Are you still having issues?
10:36powr-tocAhh... I thought that was for Clojure in Action though
10:36foguspowr-toc: Nope. "The Clojure Way" (early working title)
10:36cp2fogus: "Site error: the file /affiliate/idevaffiliate.php requires the ionCube PHP Loader ioncube_loader_fre_4.3.so to be installed by the site administrator."
10:36cp2via the tinyurl
10:37foguscp2: Ahhhh. I see.
10:38cgrandhugod: do you find your .class in the war?
10:38hugodcgrand: yes
10:38foguscp2: Fixed. Thanks
10:39gstrattonDrakeson: I believe you can use proxy if you only want to override methods, not add new ones.
10:39cp2fogus: sure thing
10:39powr-tocfogus: ahhh... that rings a few bells... odd that I can't find any email records of it though
10:40Drakesongstratton: how about reify?
10:40foguspowr-toc: My favorite part of your review: "Immutability is key, and caused me to learn Erlang in anger" ;-)
10:40cp2hehe
10:40gstrattonDrakeson: I figured out the class generation stuff mainly courtesy of this blog: http://kotka.de/blog/2010/03/proxy_gen-class_little_brother.html
10:40gstratton(I presume the author's round here somewhere!)
10:41powr-tocfogus: sounds like something I'd say... any chance you can email me back the review? :-)
10:41Drakesongstratton: interesting, thanks
10:41BorkdudeIsn't that what Erlang is all about, passing messages back and forth? ;0
10:42gstrattonDrakeson: Haven't looked at reify, sorry
10:42cp2kotarak's blog has pretty rainbow parens :)
10:43foguspowr-toc: Sure. But I do not have your email address.
10:46hugodcgrand: thanks for the help. I found an example http://github.com/sethtrain/beget
10:46Drakesoncp2: how does he generate those? are they from an emacs color-theme?
10:47cgrandhugod: thanks for the link
10:48cp2Drakeson: im assuming he just ported a rainbow parens script (probably for vim) to whatever his blog runs
10:48cp2can always ask him though =P
11:08Drakesonassume that some java class A has a constructor that takes java class B as input. How can I persuade A to accept my generated class (via proxy or gen-class, etc.) that extends B?
11:09hiredmanit should just work
11:11gstrattonDrakeson: I don't think it can work with proxy; what is the problem with gen-class?
11:13Drakesonhttp://paste.lisp.org/+22Y5
11:14cp2Drakeson: PushbackReader takes a Reader in the constructor
11:14Drakesongstratton: gen-class is far more inconvenient, and I am not sure if that is the problem
11:14cp2wrap your proxy with InputStreamReader
11:14hiredmangstratton: how would it not work with proxy?
11:14hiredman,(doc isa?)
11:14clojurebot"([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"
11:15stuartsierraDrakeson: what cp2 said; you've got the wrong types
11:15powr-tocIs there anyway from a clojure.test run via lein to know that the code should execute under a test environment?
11:15hiredman,(isa? (class (proxy [CharSequence] [])) Object)
11:15clojurebotjava.lang.RuntimeException: java.lang.IllegalStateException: Var null/null is unbound.
11:15hiredmanbleh
11:16hiredmananyway, proxies extend classes so they have the same isa relationship as a java class that extends B
11:16powr-tocOr am I best just relying on the execution or definition of a function in my test file?
11:16Drakesonthanks. somehow I got the wrong type after looking at the its javadoc!
11:16powr-tochmm...
11:16powr-tocmaybe fixtures
11:17Drakesonbtw, can that done with reify or deftype?
11:17hiredmanyes
11:17hiredmanreify is like proxy, but better in most respects, infact proxy may be implemented using reify these days
11:19paois 1.2 planned anytime soon?
11:26stuartsierrapowr-toc: if your functions behave differently in a "test environment" then you're not really testing them
11:26Drakesonwell, how can I make (instance? java.io.Reader (reify ...)) true ?
11:26stuartsierrapao: "when it's ready"
11:27paostuartsierra: thanks
11:27paoIn fact the only valid statuses are "almost reading / polishing" vs "unknown" :-)
11:29stuartsierrapao: "unknown" I think
11:29paostuartsierra: thanks again
11:39rhickeychouser: yes, def more than vars now. Nothing else works as well, and toplevel implications are good
11:40JohnnyLhttp://www.youtube.com/watch?v=IKM07drEMRw
11:47cemerickrhickey: +1 on defrecord FWIW
11:47drewrdefrecord ftw!
11:48chouserI still prefer defmaptype but defrecord is nothing to complain about.
11:50drewrlove bites, chouser, love bites
11:52drewrsorry, "defrecord" put a few songs in my head from childhood
11:54lpetitI once thought defrecord was not possible. I like it's brevity over defmaptype.
11:54cgrandit may be a good thing that defrecord doesn't have "type" in it
11:55chouserI actually think it's bad -- the name you give to defrecord is exactly the same kind of name you give to deftype, and interacts with extend* in exactly the same way
11:55gfodorwhere is this defrecord discussed?
11:56chousergfodor: right here. :-/ you can skim through the IRC logs if you want.
11:56drewrgfodor: http://clojure-log.n01se.net/date/2010-03-25.html & http://clojure-log.n01se.net/date/2010-03-30.html
11:56cgrandchouser: but their usecases are pretty distinct
11:56lpetitchouser: you mean defrecord implies that we create an instance, not a new type
11:57gfodorah, thx, didn't realize it wasn't in wiki somewhere or something
11:57powr-tocstuartsierra: true... it's not that they behave differently though... it's more that I want to load a test-database in the test environment.
11:57powr-tocI think fixtures are what I need
11:57drewrgfodor: you can search for defmaptype, defmap, etc. to find the discussion
11:57stuartsierrapowr-toc: yes, sounds like a job for fixtures
11:57stuartsierraOr "contexts" in lazytest
11:57powr-tocbut right now my tests seem to be being executed twice :-\
11:58lpetitSo now, we will be able to create new types with deftype on one hand, and *veerry
11:58powr-tocstuartsierra: what are contexts?
11:58lpetit * easily create new map-like types on the other hand
11:58chouserlpetit: no, I'm not too worried about that in this case. more that while classes, interfaces, and datatypes are not exactly the same thing, datatypes and records *are*
11:58stuartsierrapowr-toc: fixtures in my new testing framework, called lazytest
11:58stuartsierranot yet finished
11:58powr-tocstuartsierra: ahh... I'm currently using clojure.test, because its there already
11:59cemerickclojure.test has fixtures too, though they're a little odd
11:59gfodori like entity and defent
11:59gfodormy 2c
11:59lpetitI see defrecord as a language provided way to place a tag on a map, so that protocols can behave differently with these kinds of tagged map. A replacement for :type, if you will
11:59powr-tocstuartsierra: though I was considering using circumspec... and I saw you were rewriting test-is with protocols...
11:59cgrandchouser: I think it's easier to explain that defrecord is a glorified deftype than to explain there are two types of types: one for data, one for structure
11:59lpetitAt least, it's my "current mental model"
12:00powr-tocbut I really want something thats stable just now
12:00drewrcgrand: I tend to agree
12:00lpetitrun cgrand, run
12:00drewralthough chouser's point is why I liked something like deftypem
12:00gfodordefent seems shorter and speakable since its 2 syllables
12:00drewrno need to rehash all that; defrecord is a good compromise
12:00cgrandlpetit: go home!
12:01powr-tocstuartsierra: I have three deftests in my namespace, and I want to execute them all once, but in a specific order... how do I do it? Defining a test-ns-hook seems to mean they get executed twice
12:01lpetitI tend to agree with chouser: there's still an underlying problem lurking around
12:01powr-toc(via lein test)
12:01stuartsierrapowr-toc: Halloway and I are collaborating to merge features of lazytest and circumspec.
12:01powr-tocstuartsierra: ahhh nice
12:02stuartsierrapowr-toc: as I recall, there's a bug related to fixtures and test-ns-hook, don't know if that's what you're seeing
12:02lpetitQuestion: how easily could a clojurist create a vector-like type, just like he will be able to create a map-like type.
12:02technomancypowr-toc: your tests should be independent and able to run in any order
12:03lpetitSeems hardcoded, and not recursive enough, to me.
12:03powr-toctechnomancy: yeah I know :-) and they are... I'm just curious about clojure.test feature that says you can order them
12:03technomancyoh, gotcha; didn't know about that
12:03cemerickpowr-toc: why not define a single test that calls three fns?
12:03lpetitSeems like it will only be possible to have types (other than ones created by defrecord) be composed into other types, and a special case of "derivation" for map-like types
12:05powr-toccemerick: good point... seems like the clojure.test docs were leading me astray a little... it implies that you (deftest addition) (deftest subtraction) and then (detest arithmetic (addition) (subtraction))... I'm guessing it means what you said though
12:06lpetitchouser: is it something along the lines I just described that makes you unhappy too ?
12:07chouserlpetit: I'm not quite sure what you're getting at. Nothing about the behavior of deftype or defrecord makes me unhappy.
12:07powr-toctechnomancy: ordering seems like it might be handy if you have a database with state that is built up between tests... I guess that'd be more kinda integration test, than unit testing though.
12:07chouserrhickey: will your work on some kind of mix-in capability show up anywhere?
12:08lpetitchouser: yes, it's difficult to be precise, it's more a feeling right now.
12:11chouserlpetit: I've used deftype quite a bit, mostly in the deftype way but also in the defrecord way. Both seem clean and natural.
12:15lpetitchouser: time will tell. I have to use it more myself. My thoughts are "how can I reuse a raw type RT defined with deftype in a higher level construct made with defrecord ? Only by composition I imagine. So a map is the only raw type on which one can easily place a new 'tag' by creating a new record with nothing more than a name"
12:16powr-tocout of curiosity, what does RT stand for btw? Runtime?
12:17chouserlpetit: well, both types are concrete, so "reuse" in the way I think you're describing is somewhere between discouraged and impossible.
12:18lpetitchouser: I see defrecord as "reusing" most of the code from a lower level construct which will define the map type, is that it ?
12:19chouserthe weakest spot for deftype/defrecord currently is that if you want methods implemented inside the form (I think this gives slightly better performance than 'extend'), the only way currently is to use a macro that tends to end up with a lot of non-macroy code in it.
12:19chouserwhich works but seems clumsy. rhickey was looking at a mixin capability to mitigate that.
12:20chouserlpetit: oh, defrecord itself will yes, but I think so does reify.
12:20Borkdudechouser, are you one of the authors of TJOC?
12:20chouserBorkdude: yes
12:21BorkdudeI knew it when you said 'mitigate'
12:21Borkdude:)
12:21chouserha
12:23powr-tocWhat's the easiest way to reset a namespace again?
12:23lpetitchouser: thanks for the chat, must go home, cu
12:23powr-tocI want to nuke all its vars, and re-eval them
12:23chouserlpetit: bye!
12:23powr-tocI guess I'm looking for (ns-clean)
12:24stuartsierrapowr-toc: remove-ns then ns
12:25powr-tocstuartsierra: ahh cheers
12:29powr-tocseems like a slime/swank-clean-namespace might be handy...
12:30tulsihello! how can I specify in gen-class :methods that a method will return a (java) List<T>? for example:
12:30tulsi:methods [[getUsers [] List<User>]]
12:31chousertulsi: just leave out the <...> bits
12:32tulsiand return a generic List?
12:32chouseryep
12:33chouserJava's generic types are used only at Java compile time and mostly to avoid manual casting.
12:33tulsithanks!
12:34chouserBy the time the JVM is running those type parameters have been "erased", a technique confusingly described as "type erasure" :-)
12:34chouserClojure avoids manual casting in other ways.
12:35KirinDaveI read that amazing blog post on using macros to get a clojure-based fluid dynamics sim working.
12:36KirinDaveMy mind was totally blown
12:36KirinDaveBut it also made me sad, because the primitive support is so weird and some of the macros were pretty tortured.
12:36raekah, so java collections really holds Objetcs?
12:38stuartsierrarake: yes
12:39stuartsierraraek, sorry
12:41KirinDavehttp://blog.ksplice.com/2010/03/null-pointers-part-i/ makes me laugh.
12:41KirinDaveIt also makes me wonder if people understand what virtual memory is.
12:42raekcan two protocols have methods with the same name and be implemented by the same type with different implementations?
12:42stuartsierrayes
12:42KirinDaveGod damnit
12:42raekthat's nice!
12:42KirinDaveEvery time, I paste to the wrong channel.
12:42KirinDaveEv
12:42KirinDaveevery time.
12:42KirinDaveI just gotta close #clojure when i am not using it. :\
12:42stuartsierraraek: The two protocols would have to be in different namespaces.
12:43raekok, so methods names are simply namespace resolved symbols?
12:44powr-tocThis might be handy for clojure slime users: http://gist.github.com/350555
12:46chouserraek: they're just functions in the same namespace as the protocol that defined them.
12:46powr-toctechnomancy: any comments on the above gist's utility?
12:47raekpowr-toc: yes, indeed
12:47astoddardI want to be able to monitor progress of a future. Here is my idea: http://paste.lisp.org/display/97137
12:48astoddardAny comments or criticisms?
12:49chouserastoddard: the only thread sending to that agent is the one created by (future ...), so you might consider an atom instead of an agent
12:49chouseror an AtomicInteger
12:50powr-tocraek: any comments on what the function should be called? It really feels like its more part of swank-clojure than slime, but I think as a command its name should be similar to slime-eval-buffer
12:51astoddardchouser: Thanks. My initial thought was to make the agent metadata for the future, but it seems futures can't have metadata. Hence the map.
12:51raeksomething-reset-clojure-namespace sounds resonable to me
12:53astoddardIf work done by the future was pmap'ed would I then prefer an agent over an atom?
12:53powr-tocraek: but is that something slime-... or swank-... or perhaps clojure-reset-namespace?
12:54raekwell, I think it's closer to slime than swank
12:55chouserastoddard: hard to say without testing, but for something as simple as inc'ing an integer, I'd start with atom (or AtomicInteger) until is was shown to be undesirable.
12:55raekand it depends on slime, so "slime-" sounds good
12:57powr-tocraek: true... but it's also clojure specific... so it'd be a patch to either clojure-mode or swank-clojure rather than slime, would it not?
12:57astoddardchouser: fair enough, thanks for the feedback. Any idea if it a design choice that futures can't have metadata or just an unhappy (for me) coincidence?
12:58raekah, I see. maybe clojure mode then
12:59raekor maybe something like "slime-clojure-"
12:59chouserastoddard: I suspect it's a coincidence. 'future' is implemented as a reify which could support metadata but by default does not.
12:59powr-tocraek: but then, clojure-mode doesn't require slime/swank... you can use it with inferior-lisp-mode... arhgghghghghghg
13:10LauJensenEmacs crowd, if you haven't pull the latest swank-clojure from technomancys repo, with the added swank/break and debug-repl I highly recommend you do so now, insanely helpful stuff!
13:11LauJensenxb
13:11powr-tocLauJensen: Agreed... it's very, very good
13:15duncanmdoes a clojure map implement the java Map interface?
13:15carkha slime question : when i C-c C-k a function which (println "coucou") , the output goes to *inferior-lisp* instead of slime repl, is there a way to fix that ?
13:15drewrduncanm: yes
13:16duncanmdrewr: and a clojure set implements Set?
13:16powr-toccarkh: yes there is...
13:17duncanmsigh, the java Map interface is not iterable
13:17carkhpowr-toc : ah how so ?
13:17carkhmaybe have a link ?
13:17astoddardcarkh: call slime-redirect-inferior-output
13:17drewr,(.size #{:foo :bar :baz})
13:17powr-toccarkh: gimme a minute... just looking
13:17clojurebot3
13:18powr-toccarkh: I think this does it... http://gist.github.com/350588
13:18carkhyes it is ! thanks both of you
13:19drewrI actually like output going into my *inferior-lisp*
13:19joshua-choiOn defrecord and deftype: when would you ever want a type that cannot act like a map?
13:19drewrI keep a separate frame open so I can monitor it
13:20carkhdrewr : i have too many frames open already =P
13:20astoddardcarkh: the problem is that swank/slime rebinds *out* (the per-thread default outputstream for clojure) only on the repl thread. Once you run something on another thread default output goes to *inferior-lisp*
13:21carkhso when i compile it's on a different thread ?
13:23astoddardcarkh: That I don't know. It is quite easy to have stuff running off the repl thread though. I consider it a swank "gotcha".
13:24astoddardAny sort of javaland logging or interactive testing of concurrency stuff will often have expected output go to *inferior-lisp*.
13:25astoddardIf your println output appeared in *inferior-lisp* it wasn't called on the repl thread.
13:25carkhyes i can live with that, but i like to sometimes sprinkle my functions with quick and dirty println debug statements
13:25carkhi don't want to have to change buffer to see these
13:26carkhanyways i'm happy now =P
13:27astoddardYeah, I would prefer slime-redirect-inferior-output to be the default for clojure slime.
13:27powr-tocastoddard: yeah me too
13:28astoddardOne could always turn it off. But knowing to turn it one requires relatively obscure knowledge of both clojure and slime/swank.
13:29carkhyes that's a whole days work to get slime working the first time
13:29powr-tocLauJensen: You mentioned debug-repl when you told us about swank.core/break... Is that included in swank too?
13:30LauJensenYep
13:30powr-tochows it different from break?
13:30powr-tocand how do you use it?
13:41Licensergreetings my lispy friends
13:45nteonLicenser: good day
13:46Licenserhi nteon how are things going?
13:47nteonLicenser: would be better if I was writing clojure code at the moment :)
13:47Licenserheh hmm chatting directly in clojure code, that might be interesting
13:48Licenser(to "#clojure" "It might look like this.")
13:48LauJensenpowr-toc: You'll have to ask hugod or technomancy for all the specifics, but so far what I've found is that from a swank/break you can switch to the REPL and play around with all the locals
13:48kotaraksounds like the debug-repl
13:49hugodpowr-toc: you can also inspect the locals from the first frame of the stack trace
13:49LauJensenkotarak: it is
13:50powr-toccool... i didn't know you could switch to debug-repl
13:50kotarakLauJensen: beh, that is not possible from Vim due to the UDP-style connection. :/
13:50LauJensenpowr-toc: Just dont close the stack-trace
13:50LauJensenkotarak: Wow, then that would make a great opportunity for you to switch sides and help out with swank-clojure a little bit :)
13:50nteonhaha
13:51kotarakLauJensen: don't think so...
13:51kotarak;)
13:51hugodinitially there is no new prompt in the repl - just press return
13:51nteonperhaps I was too imprecise when I used the term 'at the moment'
13:53powr-tocahh wow... that is cool... I'd assumed the repl was blocked
13:54powr-toca note would be nice indicating that that's available
13:54hugodpowr-toc: I have a blog post lined up - just need to persuade my slime to run sbcl again...
13:55powr-tochugod: I look forward to reading it... whats your blogs url?
13:55Licenserhmm what was that rails like thing named again?
13:56hugodpowr-toc: hugoduncan.org
13:56kotarakIs shelling out from Java slow?
13:57LauJensenhugod: Ah you beat me to it :)
13:57powr-tochugod: the mimetype on your feed.xml is wrong
13:57LauJensenkotarak: Not in my experience
13:57kotarakk
13:58hugodcgrand: for reference - my problem was a (:require [ring.adapter.jetty :as jetty]) - once removed, everything worked
13:58hugodLauJensen: don't let me stop you
13:58LauJensenhugod: Send me a picture where you're smiling and I'll gimpshop a little medal around your neck, that'll be my post :)
13:58hugodpowr-toc: it is? thanks, I'll investigate
13:59powr-tocn/p :-)
13:59cgrandhugod: ok, thanks
13:59hugodLauJensen: :-)
14:06Licensergrrgrr
14:08licoresseif I have a map {:fn (fn [x] (+ x x) :arg 123) how can I utilize the fn at :fn with the arg at :arg ?
14:09LauJensen,(let [m {:fn (fn [x] (+ x x)) :arg 5}] ((:fn m) (:arg m)))
14:09clojurebot10
14:10LauJensenlicoresse: You mean like that?
14:10licoresseI would think like this: ((my-map :fn) (my-map :args))
14:10licoresseLauJensen: ^
14:10Borkdude,(reduce #(if (or (= 0 (rem %2 3)) (= 0 (rem %2 5))) (+ %1 %2) %1) 0 (range 1 999))
14:11clojurebot232169
14:11kotarak,(apply (map {:fn #(+ % %) :arg 5} [:fn :arg]))
14:11clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$apply
14:11LauJensenlicoresse: no diff
14:11kotarak,(apply apply (map {:fn #(+ % %) :arg 5} [:fn :arg]))
14:11clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
14:11kotarakpfff
14:11licoressehmm
14:12chouserthere's no 'invoke' fn
14:13licoresseLauJensen: I get it
14:13LauJensenk
14:13fogus,(eval (let [f {:fn (fn [x] (+ x x)) :arg 123}] (map second (seq f))))
14:13clojurebotDENIED
14:13fogusGRRR
14:13fogusOh well
14:13LauJensenDENIED
14:14fogusI always forget that clojurebot dislikes me and my tricks
14:14LauJensenAnd I think rightfully so in that case, should have been a macro :)
14:14fogusWe need macrolet
14:18ipostelniklicoresse, what about (defn af [v] (apply (:fn v) (vector (:arg v))))
14:19cgrandwhat is invoke? #(apply % %&)?
14:19Borkdudeany improvents on Euler #1? (reduce #(if (or (zero? (rem %2 3)) (zero? (rem %2 5))) (+ %1 %2) %1) 0 (range 999))
14:19fogus,(.invoke #(+ % %) 2)
14:19clojurebot4
14:19fogus:p
14:20licoresseipostelnik: I like that one
14:20kotarak,(apply #(apply % %&) (map {:fn #(+ % %) :arg 5} [:fn :arg]))
14:20clojurebot10
14:20kotarakcgrand: yup
14:21licoressekotarak: cheers
14:21ipostelnikcan you get away without inner apply?
14:21kotarakcheers?
14:21clojurebothip hip, hooray! hip hip, hooray! hip hip, hooray!
14:22kotarakclojurebot: horrido joho
14:22clojurebotIt's greek to me.
14:22kotarakclojurebot: No. It's german.
14:22clojurebotexcusez-moi
14:23ipostelnik,(apply #(apply % %&) (map {:fn #(+ % %) :arg 5} [:fn :arg]))
14:23clojurebot10
14:23ipostelnik,(#((:fn %) (:arg %)) {:fn #(+ % %) :arg 5})
14:23clojurebot10
14:25fogus,((fn [{f :fn a :arg}] (f a)) {:fn #(+ % %) :arg 5})
14:25clojurebot10
14:26licoressethanks for all input!
14:29joshua-choiHey, could people give me an example of when you'd want to use deftype to create a type that *cannot* act like a map?
14:30chouserjoshua-choi: if you're implementing PersistentHashMap in Clojure
14:31chouserthat is, you'd want it to act like a map, but not with keys of :count, :root, :meta, etc.
14:31joshua-choichouser: What do you mean by that last part?
14:32chouserjoshua-choi: maybe this is a better example: http://github.com/richhickey/clojure/blob/master/src/clj/clojure/gvec.clj
14:32joshua-choiOkay, I see.
14:34LauJensenjoshua-choi: you do?! :)
14:35joshua-choiLauJensen: :)
14:56RaynesHow is this causing a stackoverflow? http://gist.github.com/350721 it overflows when I try to evaluate the function, not when I call it.
14:58chouserneat
14:59Raynes:o
14:59chouser,(fn [] (->> :a :b (->> :c :d)))
14:59clojurebotEval-in-box threw an exception:java.lang.StackOverflowError
15:00RaynesI can't nest them? :(
15:00RaynesIt felt all warm and fuzzy inside.
15:00chouserwell, first of all it's a bit weird to nest them like that
15:01RaynesI know, but it was really fun. :|
15:01chouserI guess that should expand to (:b :a (:d :c))
15:02chouseris that really what you wanted?
15:03RaynesYeah, I believe so.
15:04chouser,(-> '(->> :a :b (->> :c :d)) macroexpand-1)
15:04clojurebotEval-in-box threw an exception:java.lang.StackOverflowError
15:04chouserhuh. that works for me.
15:10kotarakAnd another recur-try ...
15:11hugoda quick explanation of the new swank.core/break in swank-clojure http://bit.ly/bcRUSM
15:18hoeckhugod: great!
15:19patrkris_kotarak: a question about vimclojure - what's the best way of defining per-project lispwords?
15:19kotarakpatrkris_: this is an unsolved problem. You can check Luc Hermite's per-directory-vimrc
15:20kotarakpatrkris_: \aw is a rather unfulfilling workaround
15:20patrkris_kotarak: Ok. Just out of curiosity, do you know how the Emacs folks do it?
15:21kotarakpatrkris_: I think they have some heuristic (with-*). I don't think we can use metadata (the arglists). I'm probably going the same route with the heuristics...
15:21patrkris_ok sounds good
15:34cemerick /join #tomcat
15:34cemerickfooey :-|
15:35hiredmanhah! now we know
15:35cemerickgood thing I wasn't typing something more risque, like /join #php or something :-P
15:35lancepantzhahah
15:35kotarak:)))
15:35cemerickhiredman: it's crazy, I know. The remote hot deployment is pretty hard to beat tho.
15:36cemerickit's amazing how much longevity there is in the jvm world. I first used tomcat ~2001
15:36cemerick...and haven't since ~2004, but there it is still, waiting for me.
15:36chousernow with annotation support
15:38cemerickI've come to quite adore the intransigence of Java-the-language, and the knots it ties itself up in. Makes things comfortable for the big guys (for bad reasons, but whatever), which leaves a huge, stable platform for people like us to play around in.
15:38kotarakboah, "longevity" and I know the epoch BJ... I'm old. :|
15:39cemerickIf Sun had pushed out something like groovy in 2002 or whatever, fully reified generics, etc. etc., I'm not sure things would be better, net-net.
15:42TakeVSo, no different between compile time, run time, and the development time basically means that one can modify running code without rebooting?
15:42cemerickWithin some constraints, if you want to take it that far, yes.
15:43TakeVAh, what would those constraints be?
15:44cemerickThe biggest one is that you can't (easily) change your classpath at runtime. There are workarounds, but they're not pretty.
15:47TakeVThat's a pretty big one. Though, if classpath doesn't need to change, then that is an incredibly useful feature of the language...
15:49cemerickTakeV: The workaround is to add a directory to your classpath, and then unzip jars you want to add into that directory. Definitely hacky.
15:49cemerickThere are other limitations -- like, most jvm configuration (heap size, vm type, the whole array of tuning parameters) are static, and set once at startup.
15:49TakeVHuh.
15:50cemerickYou can't readily reload statically-defined classes, without some magic like rebol (or whatever it's called these days).
15:50cemerick But these are all very minor edge conditions IMO.
15:51cemerickThe biggest difference in this area compared to systems like some CLs and smalltalks is that there's no notion of an image -- you can't dump, and then deploy that somewhere else.
15:52cemerickBut then, that's a plus in my book.
15:53hiredmanclojurebot: clojure?
15:53clojurebotclojure > scheme
15:53hiredmanbleh
15:53hiredmanclojurebot: clojure?
15:53clojurebotclojure is the bestest programming language available.
15:53hiredmanI am looking for the one about trades offs
15:53TakeVclojurebot is smart.
15:53hiredmanclojurebot: clojure?
15:53clojurebotclojure is the brand
15:53Licensergreetings my clojurey friends, is there a way to supress, capture, eat, destroy, anihilate, warnings?
15:54hiredmanwarnnings like reflection warnings?
15:54hiredmanor exceptions?
15:54Licenserlike: WARNING: reader macro ^ is deprecated; use meta instead
15:54Licenserthey get printed to the shell and that is right now very annoying
15:54hiredmanthose warnings should be compile time only
15:54Licenserah
15:54hiredmanif you aot you should not see them
15:55Licenseryes but the problem is they are run in a sadnbox so compiled realtime
15:55chouserno difference between compile time and run time also means you have access to at least the entire language at compile time, which makes certain behaviors and performance tweaks possible
15:55LicenserI trind to rebind *out* and *err* but nothing seems to work
15:56kotarakOne could also drop ^. That should make the warning go away... ;)
15:56hiredmanLicenser: you can try re-binding various *whatever* things
15:57Licenserkotarak: if it were my code, yes I'd do that, but the problem is it isn't my code :P
15:58Licenserkotarak: we're working on defn's waltom
15:58kotarakwaltom?
15:58carkhis there a way to "dechunk" a sequence ?
15:58Licenserwalton
15:59chousercarkh: yes. while I'm looking, could you explain why you want to dechunk?
15:59Licenserkotarak: it is a very neat idea, it looks for code examples in the logs from #clojure to give people a hint how to use code
15:59kotarakoh. ah.
16:00Licenserso to extract more usefull code examples we push them through a sandbox, executing them to see if they are running OK.
16:00Licenserso some of the logs from clojure contain the ^ opperator
16:00carkhchouser : i have a serie of predicates in a sequence, they need to be executed until one is false, they might have side effect and throw an exception if the one executing before wasn't returning true
16:01carkhthe old way was : use some
16:01chousercarkh: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/
16:02carkhcan't use reify =/
16:03carkhi'm trying to get out of compojure right now, but i still have dependencies to it, and it's not working with head
16:03chousercarkh: so perforance isn't too huge an issue here?
16:03carkhmhhh i guess not
16:03carkhproxy ?
16:03chouseryeah, or lazy-seq
16:03chouserlazy-seq would be easire
16:04chousereasier
16:04carkhlazy-seq isn't chunked ?
16:04chousernot automatically, no
16:04carkhmhhh that means that my actual use case (as opposed to test case) wouldn't be chunked
16:05carkhanyways i think this issue is code smell
16:05carkhi might go and rethink the whole thing
16:05carkhthanks for your input chouser
16:05chouseruntested: (defn seq1 [s] (lazy-seq (let [[x & xs] s] (cons s (seq1 xs)))))
16:06chouseroh, I see. well, using something like seq1 just for a test case doesn't sound too bad.
16:06natesbrainhi, I am seeing weird behavior from load
16:06chouserthough I suppose having your app code break on unchunked seqs feels a bit fragile.
16:07carkhindeed =P
16:07natesbrainI'm trying to set a context classloader in one file
16:07natesbrainand then load a second that requires the classloader
16:08chousercarkh: wait, you're using 'some'?
16:08natesbrainI can do it when I call load separately, but put both files together and it throws a ClassNotFound exception
16:08carkhyes
16:09chouseroh, probably (some identity (map #(% x) preds))
16:10chouserwhich might call a pred past a false one
16:10carkhyes but i have a negation as well
16:10chouseroh right, you said that. :-) sorry.
16:10carkhhehe don't be sorry !
16:10chouser(some #(not (% x)) preds) should work
16:12carkhhum yes it does =/
16:25Crowb4rohh wow, so netbeans is super nice for clojure
16:25Crowb4rheh
16:25cemerickUh-huh. :-)
16:28Licenserhmm is clojure.lang.Var.deref the @ deref or another one?
16:28chouserthe same
16:28Licenserokay thanks :)
16:28chouser,'@foo
16:28clojurebot(clojure.core/deref foo)
16:29chouserand (deref foo) is just (.deref #^IDeref foo)
16:30raekwhat clojure.contrib versions are available with leiningen?
16:34technomancyraek: all of them, pretty much
16:35Licenseryea you just have to roll your dice and hope you find the right combination of prefixes, suffixes, version numbers group id's
16:35raekexactly...
16:35Licenserbut mvn/leinigen are so great for dependency management :P you don't need easy when you can have XML ;)
16:35Licenser</sarcasm>
16:36LicenserXML is enterprise!
16:36raekso, which combos work?
16:36LicenserI've no clue, I gave up
16:36bsteuber raek: just use the latest one from http://build.clojure.org/releases/ or http://build.clojure.org/snapshots/
16:36RaynesI want a JSON build system.
16:36Raynes:D
16:37Licensergreetings Raynes
16:37RaynesGreetings.
16:37LicenserI want something that is as simple as rubygems :(
16:37LicenserI know everyone will hate me again for bringing it up
16:37raekalso, is there any fix for the lein repl always uses 1.1.0 problem?
16:37LicenserRaynes: I've an idea for sexpbot!
16:38RaynesLicenser: Shoot. :D
16:38Licenseradd walton to it
16:39Licenserit extract code examples from irc logs and gives you hints on functions
16:39Licenseralso it uses clj-sandbox too :P
16:39RaynesCool.
16:39Licenserwhich of cause in itself is a reason to use it ;)
16:40RaynesI'll see about that. I'm working on figuring out how to do a privilege system with IRC being such a horrible protocol and such.
16:40Licenser*G*
16:40Licenseralso then we connect sexpbot and clicki and epic and walton and we'Ve a huge fuzzy program that can do everything
16:40RaynesHehe.
16:43raekbsteuber: thanks! now I can finally run lein deps
16:43bsteuberur welcome :)
16:43raekis there any way of doing what lein repl or swank-clojure-project does, but with another clojure version?
16:46patrkris_kotarak: what's the easiest way of using clojureql in its current state? I guess I have to compile it myself and include it in the classpath?
16:46kotarakpatrkris_: use master and avoid frontend-2.0 branch
16:46kotarakIt's the "old" cql.
16:47patrkris_kotarak: ah
16:47patrkris_ok
16:48patrkris_kotarak: but I was actually hoping to start using the new frontend-2.0 stuff - it looks really promising :)
16:48kotarakpatrkris_: yes. But it is incomplete.
16:48kotarakpatrkris_: incomplete to the point of unusability.
16:49patrkris_kotarak: Ok. I think I'll just wait then. I was just looking to play around with it.
16:49kotarakpatrkris_: playing around is possible. But I doubt you get a working query. :/
16:50patrkris_kotarak: heh, ok :) will it at some point be possible to avoid excluding the clojure.core functions like the standard operators when clojureql is used? I'm thinking about your blogpost about cql-frontend-2.0 where you do that.
16:50patrkris_could it possibly be avoided by constructing a macro inside which they are bound to the cql specific versions or something?
16:51kotarakpatrkris_: that would be possible, but it is a rather voodoo thing.
16:51kotarakMy current approach is rather to use an alias.
16:52kotarak(require '[clojureql.query :as q]) ... (q/= ...) ..
16:52patrkris_yeah, that probably wouldn't be too bad
16:52Borkdudehello Associat0r
16:53Associat0rhey Borkdude
16:53kotarakpatrkris_: what also works quite well is (use '[clojure.query :as q :exclude (= <= ...)])
16:53BorkdudeI see you're also from NL
16:53kotarakpatrkris_: then you just have to prefix the core symbols.
16:53kotarakpatrkris_: ymmv
16:53Associat0rBorkdude: yes
16:53patrkris_kotarak: yeah, cool
17:00BorkdudeAssociat0r, are you in a Clojure user group?
17:02Associat0rBorkdude: no
17:02Associat0rBorkdude: you?
17:02BorkdudeMe neither
17:04BorkdudeThere is a group in Amsterdam that meets regularly
17:05Borkdudeanyone here got some experience with Eclipse + Counter Clockwise?
17:05BorkdudeHow do I get a repl without having to run a file
17:09Associat0rBorkdude: I just started learning Clojure but have no plans to use it for real
17:09Borkdudeok
17:11Associat0rBorkdude: what are you doing with it?
17:14BorkdudeUntil now just exploring it
17:16Associat0rBorkdude: what other languages do you use?
17:16licoresseIs there add-watch for atoms?
17:17licoresseor would I just use a ref instead
17:17BorkdudeAssociat0r: I used Common Lisp, Java, C#, F#, SAS if you can call that a lang
17:18Borkdudecurrently mostly java, because I have to adapt to my environment ;-)
17:19Associat0rBorkdude: we have ##fsharp channel
17:19Borkdudeok, that's cool
17:20Borkdudebut I think Clojure is more what I need
17:20Chousukelicoresse: shouldn't add-watch work on atoms just as well as on refs? :/
17:20hoecklicoresse: add-watch works on all ref types, including atoms
17:20licoresseI was not aware of that
17:21licoresse,(doc add-watch)
17:21clojurebot"([reference key fn]); Experimental. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent or ref. Note that
17:21licoressesilly me
17:21polypusi would like to (derive X ::sequential) for use in a multimethod, such that it dispatches for any object which is (sequential? obj). is there such a beast? else how should i go about it?
17:22polypusbtw, i am using clojure.contrib.generic stuff, so i have to dispatch on type
17:24polypusi.e. i'd like to write (defmethod * [::sequential ::sequential] [x y] ...), and have it catch all objects for which (sequential? obj) is true.
17:26technomancyso what's the deal with persistent HTTP connections in the JDK?
17:26technomancyaccording to http://java.sun.com/j2se/1.5.0/docs/guide/net/http-keepalive.html HTTP connections are persistent by default, but we did some perf tests that indicate there's no difference between the default and explicitly setting Connection: close
17:29polypusthe above is why i often think isa? should be able to take predicate functions
17:31polypus(isa? (type 5) number?)
17:41cemericktechnomancy: the JDK will often ignore Connection: close
17:41cemerickthe keepalive impl has some faults :-(
17:41lancepantzhow can i get a string into an inputstream?
17:42cemerickPeople generally go to httpclient if they really want to know what's going on, but that's not a lot of fun.
17:43kotarak,::foo
17:43clojurebot:sandbox/foo
17:43kotarak,(= ::foo :sandbox/foo)
17:43clojurebottrue
17:43licoresseso :: belongs in the namespace
17:43kotarakyup
17:43licoresseand can therefore never conflict with a similar :
17:44kotarak(require '[foo.bar.baz :as baz]) ::baz/frob => :foo.bar.baz/frob
17:44licoresseah
17:45licoressemy global namespace is way poluted
17:45licoressepolluted
17:48technomancycemerick: yikes. good to know; thanks.
17:49cemericktechnomancy: that's not to say that it's not usable; in general, you can let it do its thing and ignore it. The price to pay is that (esp. when interacting with servers that have less-than-stellar keepalive impls), things can go sideways in odd ways.
17:53cemericktechnomancy: See http://stackoverflow.com/questions/1440957/httpurlconnection-getresponsecode-returns-1-on-second-invocation/1441491#1441491 and http://stackoverflow.com/questions/1936872/how-to-keep-multiple-java-httpconnections-open-to-same-destination/1936965#1936965
17:54raekwhat is the simplest way of getting a seq of n values of x?
17:54polypus(take n (repeat x))
17:55polypusunless you mean that x is a seq and you only want n of those, in which case, it's just (take n x)
17:55ska2342,(replicate 3 \a)
17:55clojurebot(\a \a \a)
17:57raekah, replicate, there it is!
17:57kotarak,(repeat 3 \a)
17:57clojurebot(\a \a \a)
17:58ska2342raek don't ask me why replicate exists, when repeat has just the same form...
17:58Raynes(doc replicate)
17:58clojurebot"([n x]); Returns a lazy seq of n xs."
17:58Raynes(doc repeat)
17:58clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
17:58kotarakska2342: once upon a time repeat did only infinite things
17:59kotarakska2342: replicate will be go away eventually...
17:59ska2342kotarak: good to know.
18:00raekah, ok
18:00naeuI'm trying to get my head around the combination of the functional style and java interop
18:01naeucould anyone shed some light in my direction. How do I call the Java instance method getName on each of the File objects in a seq
18:01ska2342naeu: use map ?
18:01naeufor example, I want to make the following print out less noise info:
18:01raek(map #(.getName %) files)
18:02boojum(for [f files] (.getName f))
18:02naeu(map println (seq (. (new File "/Users/sam/") listFiles)))
18:02kotaraknaeu: map is not a loop
18:02ska2342naeu: when printing for side effects use doseq
18:02naeuah, thanks - I'm still trying to break out of Ruby-thoughts
18:03ska2342all the credit to kotarak ;-)
18:04kotarakska2342: I'm a nit-picker. :P
18:04tomojthat's what I was thinking about the blog post someone linked to a while ago
18:04tomojhttp://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/
18:04tomojthat one
18:05tomojis there a reason we need seq1 other than so that we can use map with side effects?
18:05tomojoh, wait
18:05tomojyes, of course :)
18:06tomojthe printing was there just to demonstrate the problem chunking causes
18:06boojumtomoj, i think the argument was exploding computations
18:06tomojyeah, I was just not thinking straight
18:23polypushow do i define a new function with the name / (forward slash). i did it once, and there was something special i had to do because / is special, but just can't remember
18:23polypusbtw, i've already :refer-clojure :exludeded it
18:24raekthen I think it should work...
18:24raekwhat error do you get?
18:33polypusraek: thanks, it does actually work. i just tried it in a minimal file w/o a problem. not sure yet why it isn't working in my real code
18:34raekI've made an implementation of "hash-bag", a bag/multiset based on a hash-map: http://gist.github.com/350986
18:34raek(def b (hash-bag :a :b :c :a :b :c))
18:35raek(count b) => 6
18:35raek(seq b) => (:c :c :b :b :a :a)
18:36raek(seq (conj b :a)) => (:c :c :b :b :a :a :a)
18:36raek(seq (disj b :a)) => (:c :c :b :b :a)
18:37raekwhat do you think?
18:37Chousukehuh
18:37Chousukeah, hm, never mind
18:38ChousukeI misread you and was thinking of hashmaps. that behaviour then thoroughly confused me :P
18:39Chousukeis disjoining nonexistent keys an error? :/
18:39Chousuke,(disj #{} :a)
18:39clojurebot#{}
18:42raekys
18:43raek(disj b :f) => IllegalStateException: Can't disjoin non-existing key
18:44raekcount should be constant time and seq lazy
18:44raekis there any other expectations I should be aware of?
18:45arohnerraek: count is not always constant time
18:45raekI've noticed that it is for a lot of clojure's data types
18:46raekeven PersistentList
18:46arohnerraek: yeah, for the ones that implement ICountable or whatever it is
18:46raekIPersistentSet extends Counted
18:47raekI really love that adding one such detail (constant time count) is really trivial in persistent data structures
18:51raekbtw, is (new TypeDefinedWithDefType field1 field2) the right way to make a new instance inside a method implementation?
18:52raekin the methods, the type name seems to refer to the class rather than the generated factory function
19:02RaynesIt isn't bad to use slurp* to get a webpage, is it? :o
19:03RaynesI tend to use it for simple API calls for stuff like bit.ly.
19:06raekI guess it depends on how much data it slurps
19:07raekthe point of streams is to not be required to have everything in memory at once
19:08raekif having the whole webpage in memory is no big deal, then I don't see why not
19:15duncanmis there a reason why 1.0f is not a proper float literal?
19:15duncanm,1.0f
19:15clojurebotInvalid number: 1.0f
19:15duncanmi thought Clojure numbers look the same as Java numbers
19:22raek(class 1.0)
19:22raek,(class 1.0)
19:22clojurebotjava.lang.Double
19:26raekI don't know any particular reason for why there isn't a reader syntax for java.lang.Float
19:27raekbut you rarely deal with the primitive numeric types directly in clojure
19:33quidnuncHow do I use slime with clojure and other lisps? This was working a few months ago but now some magic (c.f. slime-read-interactive-args) is happening that I don't understand how to deal with.
19:50dnolenquidnunc: you're best bet if you want to work with other lisps as well as Clojure is using technomancy's swank-clojure on GitHub, esp. if you want to use the latest version of SLIME. You'll need some .emacs-fu to make it work tho.
19:52alexykliebke: ping
19:53liebkealexyk: hey
19:54tomojhas anyone had any luck with using the ELPA clojure stuff to connect to multiple swank servers at once?
19:58alexykis (apply + things) preferable tp (reduce + things) ?
19:58alexykto
19:58AWizzArdThey are conceptually different things.
19:59alexyk,(let [s [1 2 3]] [(apply + s) (reduce + s)])
19:59clojurebot[6 6]
19:59alexykthat's what I mean
20:00alexyktheir results are identical
20:00AWizzArdYes, there exist several such cases where apply and reduce both can be used.
20:00alexykso what I'm wondering is the performance in this specific case
20:01AWizzArdThey should be practically identical, as those functions that you apply and which produce the same result use reduce under the hood, or something similar.
20:04quidnuncdnolen: I am using swank-clojure. I thought my fu was sufficient but it appears not. The question was what am I missing?
20:06dnolenquidnunc: technomancy's fork of swank-clojure? The original project will not work.
20:06dnolenor won't work with SLIME master rather.
20:11TakeVHow does one open a new frame and buffer in Emacs? Watching the guide on how to set up slime, and when he says to open a new file, it just appears, no commands inputed.
20:11tomojTakeV: maybe try #emacs?
20:12tomoj(but.. C-x C-f)
20:12TakeVI didn't know there was an #emacs.
20:12AWizzArdhttp://www.cheat-sheets.org/
20:12tomoj(also try C-h t)
20:12tomoj(that is, hit control+h, then hit t)
20:12AWizzArdThere you can download and print a two-page overview.
20:12TakeVThanks.
20:12hoeckTakeV: C-x 5 2
20:26quidnuncdnolen: I fetch technomancy branch but I still have the following basic problem: How do I choose clojure as my slime lisp implementation?
20:28dnolenquidnunc: I don't really recall I let my SLIME lisp stuff rot a bit. You definitely need to set some swank-clojure vars.
20:34quidnuncdnolen: Yes, I had it working before. But now the behaviour seems to have changed. slime-lisp-implementations is automatically configured anymore it seems
20:35quidnuncs/is/is not/
20:42raekwe now have a project name generator: http://www.morewords.com/ends-with/sure/
20:42raek:D
20:43raekjust replace the last s with j, and you're good to go!
21:05quidnuncCan anyone clue me in on how to build swank-clojure?
21:27dnolenquidnunc: I recommend using lein to do that
21:27dnolenquidnunc: lien compile should work
21:28quidnuncdnolen: Will try it, thanks
22:12alexykis there a map which preserves the type of the input, e.g. maps vectors onto vectors?
22:22arohneralexyk: no, but it's easy to write your own using 'into' and 'empty'
22:22arohnerI have my own map-same
22:23arohnerhttp://gist.github.com/351238
22:23alexykarohner: how's empty used?
22:23alexyklooking...
22:24alexyknice
22:24arohnerthe (apply map f colls) should probably be moved into the let...
22:25tomojhmm, using into there raises the constant factor?
22:27arohnertomoj: yeah, but if you need at a collection of the same type, you're going to do it anyways
22:27arohnertomoj: is there a faster way to do it?
22:28tomojwell, that's what I was thinking
22:28tomojinstead of using map, can you rewrite map to keep the type?
22:28tomojcouldn't be lazy
22:28tomojbut of course it can't..
22:29arohner~map
22:29clojurebotmap is lazy
22:29arohnerthank you clojurebot
22:29arohner~def map
22:29tomojgod I hate github on core.clj
22:51rem7whats the best way to get an image into clojure (jpg, png, tif -- anything better than 8bit would be a plus) ImageJ?
22:52rem7Im not very familiar with Java's libraries but in C I use openCV mostly for image processing stuff.
22:53hiredman~javadoc javax.imageio.ImageIO
22:53hiredman~google clojure opencv
22:53clojurebotFirst, out of 6090 results is:
22:53clojurebotFun with Clojure, OpenCV and Face Detection
22:53clojurebothttp://nakkaya.com/2010/01/12/fun-with-clojure-opencv-and-face-detection/
22:53rem7yeah I saw that...
23:04slyphonthe compiler is confusing me
23:04slyphonit's giving me very strange "No such var" errors
23:05slyphonwhere the var in question is very much defined
23:05arohnerslyphon: how do you know it's defined?
23:07slyphonhrm, wtf
23:07slyphonok, now i'm just confused
23:07slyphonwhen i C-c C-k the file, it gives me the "no such var" error in a *different* file than the one i'm compiling
23:08arohnerslyphon: do you have require/use statements in your files?
23:08slyphonyeha
23:08arohnerslyphon: and do you have circular requires?
23:08slyphonhrm
23:10slyphonargh
23:11slyphonthis programming thing is hard
23:13slyphonwow, this is gonna be tricky
23:24brweber2how can I improve this code? (and (.exists file) (.isFile file) (.canRead file))
23:24brweber2->, ->> and doto ... none fits exactly
23:24brweber2is there something that does?
23:25lancepantzanyone mind taking a look at http://www.pastie.org/898326 for me?
23:26lancepantzi'm having difficulty figuring out the splicing unquote reader macro
23:26arohnerbrweber2: I'm not aware of anything
23:26hiredmanfoo needs to be an iseq for splicing
23:27hiredman,(let [a '(1 1)] `(~@a))
23:27clojurebot(1 1)
23:27hiredman,(let [a '(1 1)] `(~a))
23:27clojurebot((1 1))
23:27hiredmanyes?
23:28tomoj,(let [foo ["1" "3"]] `(~@foo))
23:28clojurebot("1" "3")
23:28tomojm is ["1" "3"] here
23:30hiredmanthe whole point of macros is the arguments are not evaluated
23:30hiredmanm is the symbol m
23:31tomojoh, yes :)
23:32tomojfoo is the symbol m, I guess?
23:32hiredmanyes
23:32tomojso I guess you want (apply println ~foo) instead of splicing
23:32slyphongod *dammit* it's hard to track down circular deps
23:33lancepantzso in my example, how do i get my for loop to return an iseq?
23:33hiredmanclojurebot: for?
23:33clojurebotfor is a loop...in Java
23:33hiredmanclojurebot: for?
23:33clojurebotfor is not used enough
23:33hiredmanclojurebot: for?
23:33clojurebotfor is not a loop
23:33lancepantzfor macro, sorry
23:33hiredmannot a loop
23:33tomojlancepantz: m is an ISeq in your example
23:33hiredmanit's a list comprehension
23:33tomojthe problem is that foo isn't pointing to the value of m
23:33lancepantzi get for, typo, sorry
23:33hiredmanit does return a seq
23:33hiredmanbut it returns a seq at runtime
23:34hiredmanmacros run before/as part of compile time
23:34hiredmanwhy do you want to write macros anyway? just use hofs
23:35lancepantzjust learning
23:35slyphoni don't understand why i'm having so much trouble with references
23:35somniumhofs?
23:35slyphondon't hassle the hofs
23:36hiredmanhigher order functions
23:36somniumIll have to patch that one into wtf-mode
23:37hiredmanjuxt, partial, comp
23:38somniumso thats what those are
23:39hiredmancompliment, but (comp not ...) has less keystrokes than (compliment ...)
23:40slyphonhas anyone written code-analysis tools for clojure, like to graph dependencies between namespaces?
23:40hiredmansince maps, vectors, sets, keywords, and symbols are all callable as functions, maybe anything that returns on of those is a hof
23:41hiredmanhttp://www.thelastcitadel.com/images/clojure.png
23:41somniumrecently Ive been wishing map would return (partial map f) when called with one arg (or even better a brand new fn that inlines f into the def of map)
23:42slyphonhiredman: yeah, like that
23:42hiredmanhttp://github.com/hiredman/clojure-dependency-grapher
23:42slyphonhiredman: awesome :D
23:43hiredmanfeel free to fork and make better :P
23:43slyphon:)
23:44hiredmanI would use the find-namespaces branch if you do make any improvements
23:44hiredmanI don't exactly recall the difference, but I think it's Betterâ„¢
23:51telaIs there an idiomatic way to ensure an expensive computation only be done once even if multiple threads may near simultaneously request the result?
23:53slyphonuse a monitor?
23:53hiredmansync or async?
23:53hiredmanasync is a future, for sure
23:54hiredmansync may be a promise or a delay
23:54hiredman~def delay
23:55telahm, sync definitely. If the thread tries to force the promise/delay it'll just block until the computation completes, no?
23:55Crowb4rhiredman: did you have any trouble getting the pirc lib to work with clojrue
23:55Crowb4r?
23:56hiredmanCrowb4r: nope
23:56Crowb4rk
23:56hiredmantela: right
23:56Crowb4rmust be somethign with my code, thats good to know. probbably did something dumb.
23:56hiredmanthe delay might not block though
23:57hiredman~def c.l.Delay
23:58telawait, hm. The computation is stochastic. I might be able to work it still but it'll take some more trickery ---
23:58hiredmanlooks like delay will work fine
23:59hiredmanDelay's deref is synchronized
23:59telabut it'll memoize the thunk in the future, right? I want to call it again later for a new stochastic result.