#clojure logs

2011-03-10

01:04technomancya version from mid-august that was outdated only three weeks later
01:05amalloytechnomancy: a perverse desire to show they're not afraid of 13
01:08amalloyor: a belief that it will magically turn into clojure 1.3.0
01:10technomancywith swank-clojure the versions actually match the clojure versions pretty closely
01:18amalloytechnomancy: see? so totally plausible that someone might intend lein to do that
01:19technomancyyeah I'd buy that except for the fact that 1.4.0, which is also obsolete, got more downloads than that.
01:36Derandertechnomancy: you've probably got some old tutorials floating around out there
01:45ossarehAm I right in thinking that when you aot compile a namespace that all dependent namespaces get compiled to?
02:17chouserossareh: yes
02:27ossarehchouser: is there any way to limit that behaviour? I'm compiling a web app and at some point there is a var which, when accessed at run time, pulls data from the database.
02:27ossarehSo at production time I have my test configs :/
02:33iwilligdoes anyone know why, if i have a function with keyword arguments, i can't call that function with a hash map
02:33iwilligwith the correct keys
02:34zakwilsonHow long should I expect clojure.xml/parse to take on a 900M file on a modern laptop?
02:35iwillignever mind
02:35iwilligfigure it out
02:35iwilligsorry to bug people
03:10sorenmacbethhello all
03:11sorenmacbethcould someone help me with what I'm sure is a simple problem, unless you are new to clojure that is
03:11sorenmacbethI'm trying to create word level n-grams of up to a maximum length of n from a seq of words
03:13sorenmacbethso for a seq like ("foo" "bar" "baz") and n = 2 I'd want ("foo") ("bar") ("baz") ("foo bar") ("foo baz") ("bar baz")
03:31bytecodersorenmacbeth: have a look at clojure combinatorics. it might help. http://richhickey.github.com/clojure-contrib/combinatorics-api.html
03:33sorenmacbethbytecoder: thanks, I did have a peek in there. that gets me most of the way there, I think I need to do a map or recursion to get all the combinations up to n, but not sure exactly
03:35tsdhIf I have (def x false) (binding [x true] (pmap #(...) [...])), do the threads spawned by pmap see the binding value true, or the root binding false of x?
03:36raektsdh: no. but you can use bound-fn and bound-fn* to make it so.
03:37raek(no, they don't se the dynamically bound value)
03:37bytecodershould be simple with mapcat
03:37tsdhAh, I've just tested it using #(println x) in the pmap. BTW, why is output in other threads not sent to the usual slime output?
03:37bytecoder&(mapcat (partial selections #{"foo" "bar" "baz"}) (range 1 3))
03:37sexpbotjava.lang.Exception: Unable to resolve symbol: selections in this context
03:38hiredmantsdh: *out* is dynamically bound
03:38bytecodersorenmacbeth: (mapcat (partial selections #{"foo" "bar" "baz"}) (range 1 3))
03:38raektsdh: the same reason, actually. the output is sent to *out* which is rebound for the repl thread
03:38tsdhhiredman: Ah, so the same as with x. :-)
03:39tsdhraek: Is your suggestion to bound-fn a function that calls pmap?
03:39raekyou can do a (alter-var-root #'*out* (constantly *out*)) in the slime repl
03:40sorenmacbethbytecoder: awesome, that is super close, the only issue that is does ("foo foo") ("bar bar") ("baz baz")
03:40tsdhraek: Great, that does the trick.
03:40raektsdh: boudn-fn works as a replacement for fn, so you can use it like (binding [x true] (pmap (bound-fn [y] ...) [...])
03:41tsdhAh, I see.
03:41bytecodersorenmacbeth: oops. replace selections with combinations
03:41bytecodersorenmacbeth: (mapcat (partial combinations #{"foo" "bar" "baz"}) (range 1 3))
03:42sorenmacbethbytecoder: perfect!
03:42sorenmacbethbytecoder: thanks much. I have MUCH clojure foo to learn ;)
03:42tsdhBut is not sharing the bindings of the spawning thread a bit counterintuitive? Or is it that costly, that it's the way it is for efficiency reasons?
03:43hiredmanin master they are shared
03:43hiredmanbut vars aren't dynamic by default any more
03:44tsdhhiredman: And the latter was a performance reason, right?
03:46hiredmantsdh: yes it means less overhead spent checking for dynamicly bound vars
03:46bytecodersorenmacbeth: np. look around. there is most likely a function or library that already does what you want :)
03:46tsdhPhew, I hope there will be some good update guide when 1.3 comes arround...
03:53tsdhIs it possible to have a fn with args [x & rest {:keys a b c}]?
03:55raek,(let [[x & {:keys [a b]}] [0 :a 1 :b 2]] [x a b])
03:55clojurebot[0 1 2]
04:01CozeyGood day. I updated to latest swank-clojure from technomancy's github, and now the package/function description doesn't work (returns nil). Maybe I'm missing a correct slime release? I have one from elpa (but with technomancy repo added)
04:02CozeyIt's slime 20100404
04:02Cozeyor even 20100404.1
04:08bytecoder,(clojure-version)
04:08clojurebot"1.2.0"
04:11bartjhow can I remove duplicates from a sequence of hash-maps ?
04:12bartjeg: , ({:a 3} {:a 5} {:a 10} {:b 3}) and retain only the max value
04:12bartjie. {:a 10 :b 3}
04:14clgvbartj: for exact duplicates distinct does the job. your case seems to require own work^^
04:16clgvyou could sort by value increasingle and then assoc as you traverse the sorted sequence. it would do the trick but wouldnt be the fastest implementation
04:17krumholtbartj, does the sequence only contain maps in the form {:key value} not {:key1 value1 :key2 value2} ?
04:17bartjI thought of a merge-with -> concat -> pick the max ?
04:17bartjkrumholt, yes
04:21clgvthat one works too: (merge-with max {:a 3} {:a 5} {:a 10} {:b 3})
04:21clgv&(merge-with max {:a 3} {:a 5} {:a 10} {:b 3})
04:21sexpbot⟹ {:b 3, :a 10}
04:22clgvso for your seq it should be: ##(apply merge max '({:a 3} {:a 5} {:a 10} {:b 3}))
04:22sexpbotjava.lang.ClassCastException: clojure.core$max cannot be cast to clojure.lang.IPersistentCollection
04:22clgvups
04:24krumholtnice solution clgv all you need now is reduce
04:25krumholt,(reduce #(merge-with max %1 %2) '({:a 3} {:a 5} {:a 10} {:b 3}))
04:25clojurebot{:b 3, :a 10}
04:25clgvkrumholt: I thought one can do it with apply but it cant handle the function param it seems
04:26bartjthat is better than a bloated reduce I have !
04:26raek,(apply merge-with max '({:a 3} {:a 5} {:a 10} {:b 3}))
04:26clojurebot{:b 3, :a 10}
04:26clgvoh damn. forgot the "with"
04:26krumholtthats even better :)
04:27bartj(max-key {:a 5 :b 3})
04:27bartj, (max-key {:a 5 :b 3})
04:27clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$max-key
04:27bartj, (apply max-key {:a 5 :b 3})
04:27clojurebot[:b 3]
04:27bartjshouldn't it be :a ?
04:28clgvit's called max-key and not max-val ;)
04:28clgv:a < :b
04:28bartjyeah, lexographically
04:30bartjare there any utility map functions
04:30bartjto get the keys with the maximum values ?
04:32Cozeywhat happened to clojure.core/with-out-str in 1.3 ?
04:32Cozeyand how to check such things in git?
04:37clgvbartj: the doc for max-key kinda didnt help me, but I found an example. the solution for you is: ##(apply max-key val {:a 5 :b 3})
04:37sexpbot⟹ [:a 5]
04:39bartjmy solution was like this (remove nil? (map #(if (= max-val (m %)) % nil) (keys m)))
04:39bartjwhere m is a map and max-val is the maximum-value
04:39bartjmax-val is computed as: (apply max (vals m))
04:40clgvlooks a lot longer ;)
04:40bartjthe trouble with clgv is that it doesn't return multiple-keys if both of them have multiple values
04:41bartjsorry I meant with your solution
04:41clgvoh right
04:41clgvwell I would use a loop-recur approach over the seq of key-val-pairs then
04:43raekCozey: what has changed about it?
04:43Cozeyit disappeared
04:44raekstrange
04:44raekhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4102
04:44Cozeyhmm wait
04:44Cozeybut swank thrown a null exception on this.. i need to take a better look, sorry for this one
04:49khaliGLong shot but wondering if anyone has had trouble with Incanter "Caused by: java.lang.ClassNotFoundException: incanter.Matrix" when trying to run their project from a jarfile. i can use lein run fine, just not from a jar.
04:51Cozeyhmm which swank-clojure is more up to date to work with 1.3 ? technomancys or jochu's ? (https://github.com/jochu/swank-clojure/network)
04:52raektechnomancy's
04:53raekthe graph is biased towards the fork you are currently viewing (https://github.com/technomancy/swank-clojure/network)
04:53Cozeyright, technomancys entry there is just for some old branch
04:55raekhrm, looks technomancy pushes the changes to both branches
04:55raek*forks
04:55raekthe last commit of technomancy/swank-clojure is "Resolve print-doc at runtime to fix 1.3 compatibility."
04:56raekthe same for jochu/swank-clojure
04:58Cozeythanks :-)
04:58Cozeydo You know by the way how to find the commit where a chunk was deleted?
04:59Cozeygit blame lets you find the added lines.. how about the removed?
05:00raekI was going to sugest blame, but now I see your point... :-)
05:03Cozeyhm it is possible http://feeding.cloud.geek.nz/2010/07/querying-deleted-content-in-git.html
05:04Cozeywith some git trickery
05:08tsdhWhy does (def lll "doc" 1) say that there are too many args to def? The docs say, that it accepts an optional docstring, right?
05:21tsdhIs there a convention about how much lines should be indented? Usually (CL, EL), one starts following lines at column zero, but it seems clojure guys usually indent following lines with 2 spaces...
05:22TobiasRaedermorning
05:28raekthe way clojure-mode for emacs seems to do it is to by default align the function arguments with the first one, like this:
05:28raek(foo 1
05:28raek 2
05:28raek 3)
05:28raekbut a lot of special forms and macros use the "defun" style and indents two spaces
05:29raek(let [x 1]
05:29raek (a)
05:29raek (b)
05:29raek (c))
05:31raekthis seems to be escpecially common for special forms or macros what wrap a code body, like do, future, for and dosync
05:33Cozeyanybody knows why they are checking here if print-doc is :private? https://github.com/technomancy/swank-clojure/blob/master/src/swank/commands/basic.clj#L210
05:38tsdhraek: I mean the docstring if it more than one line long.
05:40raekoh. :)
05:41raekI have seen both 2 and 3 spaces for docstrings
05:41tsdhBut never 0 spaces, like in CL?
05:53tsdhninjudd: Hi. I use your ordered-set lib, and it's great!
05:55tsdhninjudd: But one uncertainty: can you guarantee, that (clojure.set/difference ord-set1 ord-set2) also preserves the ordering (of either the former or the latter)?
06:03angermanhaha… finally. Rendering Geometry to PDF via LaTeX and TikZ :D
06:04angermanhttp://dl.dropbox.com/u/281539/tikz-template.pdf
06:14__name__angerman: pretty
06:15angermanI need quite a bit of geometry drawings for my thesis.
06:17angermanusually I use JReality+Clojure to see if the algorithms work as expected. But at some point, raster images are just not suitable. Currently it takes the clojure geometry description, and renders it into \coordinate (node-N) at (X,Y); and \draw[black!FRACTION] (node-A) -- (node-B); commands to be fed into TikZ :D
06:21clgvangerman: dont you want to make a latex layer in clojure? that would be a great advance ;)
06:21angermanclgv: rewriting latex in clojure?
06:21Cozeywhat's the best strategy to make a future doing a certain task on certain time interval?
06:22clgvangerman: so to say. or better replace Latex via ClojureTex ;)
06:22angermanclgv: if I hadn't had a disk crash on a secondary disk, I would still have a markdown -> TeX compiler in Clojure. :/
06:23clgvangerman: get a DVCS ;)
06:23angermanso I've been using clojure for quite some time to augment LaTeX… I'm not so sure if a pure ClojureTeX would make sense.
06:24clgvI think it's past the time that the community should have thrown away latex for a better document description DSL
06:24angermanclgv: I have. That project though was never considered remotely useful except for creating lots of flash-cards quickly to study a course on set theory.
06:24clgvah kk^^
06:25angermanclgv: I'm not so sure. I'm more for augmenting LaTeX, there's just so much usefull stuff in LaTeX. But it's interface could use quite a bit of polish.
06:25angermane.g. less \command
06:26clgvthe "language" latex is one of its biggest problems. the useful things would have to be rewritten in a new DSL of course
06:27clgvand the "module organization" as well^^
06:28angermansure, the macro expansion feels very ancient. And iirc. Knuth actually remarked to be puzzled that no one had taken a serious shot at advancing tex.
06:28clgvoh ok didnt heard of that^^
06:28angermanBut for now, TeX is a somewhat standard. Thus if you write an augmentation system that compiles to TeX that's going to have the best acceptance for now i think.
06:28clgvyou have to make the difference between LaTex and Tex
06:29clgvI only would replace LaTex. Tex might stay as kind of an "Assembler level" ;)
06:30angermanclgv: sure that might work out, though sidelining latex is not a perfect solution :/
06:30clgvprobably. since it would take long until you replaced most feature packages
06:32angermanto get accepted, you'd need it to be easier to use without panelizing the current workflow. And most people at the math department are happy with LaTeX…
06:33clgvI would say most people get their work done with latex, but "being happy with it" is an entirely different dimension ;)
06:33angermanclgv: fair enough. But is there any competition?
06:34clgvI dont think so. I first thought LuaTex could be when I heard it first. But it seems they have other goals
06:35angermanclgv: I think luatex still needs a lot of time.
06:36clgvyou understood their primary goals? maybe you can explain them to me ;)
06:37angermanclgv: I thought it was along the lines of "I love LUA, why on earth didn't Knuth write TeX in Lua? Hell it's such an awesome language, let's rewrite TeX"
06:37clgvah ok. I just read the wikipedia entry again
06:37clgvon their own page it sounded a bit concusing some time ago
06:37clgv*confusing
06:38angermanthing though is that, lua is a more modern langauge, and thus they are more likely to attract "new" developers, for whom TeX is just too weird.
06:39angermanI don't know what the size of lua devs is, from my experience they are hanging in WoW or so.
06:40clgvhmm well. maybe one could start a LaTex-Wrapper in Clojure. Libraries that encapsulate main building blocks.
06:40clgvwould be less work than replacing LaTex ^^
06:41angermanclgv: I guess what you would need is a half-assed latex-build-system, and a compiler that can compile augmented ClaTeX to LaTeX.
06:42clgvI did some programming in TikZ for an animation. that was kinda nasty ;)
06:42angermanTikZ is actually pretty awesome, though you need to get used to it's custom DSL.
06:43angermanbut afaik it's the best tool for graphics and animations there is for latex.
06:43clgvyeah it's results are awesome. but when you actually want to programm an algorithm illustration it gets really nasty - I missed a "map"-function for example ;)
06:43angermanI've even created most of the artwork for an iPhone app with TikZ :D
06:44angermanclgv: right. apart from foreach there's little.
06:46clgvindeed. and if you look at the actual implementation of TikZ you'll get nightmares^^
06:47clgvthat's the pretty thing about clojure - you can learn a lot by looking at the core implementation
06:47angermandunno, I just got respect for Till's mastery of TeX
06:47clgvI agree with that. It wasn't directed at Till but at Tex ;)
06:48angermanand if you remember that same Till is the author of LaTeX Beamer… you got to admire his contribution to LaTeX
06:48angermanclgv: yep. TeX… well… it's from another era
06:48clgvI know. Where did he get all the time for it? ;)
06:48angermanseems to be faculty member at the uni. of Lübeck, iirc.
06:49clgvyeah, but I suppose he has to do real research as well ;)
06:50angermanyou never know :D
06:50clgvyou thin they have him as "Professor for LaTex"? :P
06:52Fossihmm. got some buddies who study cs there
06:52Fossicould ask :D
06:54clgvah he is in theoretic computer science^^
06:55clgvprofessor with approx 36. thats fast
07:05clgvoh I did use the wrong year. professor with 30
07:05angermanlol.
07:06angermanclgv: so, well, he wrote beamer, tikz, a few paper, a doctorial thesis and his habilitation thesis.
07:07angermannot bad.
07:07clgvyeah. didnt have much sparetime I guess.
09:15choffsteinAnyone here played with clojure on GAE? I've been following a tutorial (http://compojureongae.posterous.com/), but when I try to test locally, the dev server won't stay up -- it just drops silently (whether it is my code or the demo code from the tutorial). My google-fu is failing me on a solution to the problem...
09:23TimMcchoffstein: I know of someone here who has, but they're not logged in.
09:23choffsteinHm, okay. Maybe I'll just idle then :) Thanks
09:24tsdhI use leiningen and have a big testis-test file. "lein test" executes all tests, but what's the right syntax to let it execute one specifig deftest?
09:27TimMcchoffstein: Ask again when waxrose is in the channel. Might be a few hours, though.
09:28choffsteinTimMc: Thanks a lot
09:29tsdhIs there some "initialize when first used" feature for vars? In my test, I have several defs that load huge graphs. It would be awesome if they'd be only loaded on demand.
09:29TimMcI don't know if he'll be able to help, but I *think* he got something up and running.
09:29TimMctsdh: Memoized fn?
09:31tsdhTimMc: Not quite. But I guess I can simply wrap a function around.
09:31TimMcYeah, that's what I would do.
09:32TimMc(def get-graph (memoize (fn [] ...)))
09:32TimMcOnly loads on first call.
09:33tsdhTimMc: Oh, yes. That's even better than that what I was thinking of. :-)
09:34TimMcRemember that the huge graph will then be in memory until get-graph can be garbage-collected, but this should be fine for testing.
09:39tsdhTimMc: If it would be collected, would a subsequent call load it again?
09:39TimMcYeah, but it won't be collected while your program is running, since it's a global var.
09:40tsdhPerfect.
09:48TimMctsdh: lein test org.timmc.pipeline.test.core
09:48TimMcThat runs a specific test file.
09:48TimMcHaven't figured out how to run one deftest.
09:50TimMcThere's something about "test selectors", add a reference to a robert.hooke namespace in the source code.
09:50TimMc*and
09:50tsdhAh, I've though test selectors were just test names.
09:54TimMctsdh: https://groups.google.com/group/leiningen/browse_thread/thread/e421df80db71b2ce
10:14tsdhTimMc: Thanks.
10:15TimMcSounds like you might need a :dev-dependencies for robert.hooke, but I'm not sure.
10:16fliebelTimMc: Where are you using robert.hooke?
10:22pyrhi
10:26TimMcfliebel: I'm not, I just saw that lein seems to have a dependency on it for test selectors.
10:27clgvI have to remove an element from a vector. if I know that it is the n-th element, is there a fast way to create a vector without it?
10:29amalloyclgv: no
10:30clgvah a look over the cheat sheet suggests subvec might work
10:32raekclgv: you need to do something like (into (subvec v 0 i) (subvec v (inc i) (count v))), which has linear time complexity
10:33clgvthe "into" leads to the linear complexity I guess
10:33clgvsince subvec has O(1) according to documentation
10:34chouserclgv: also note the resulting vector will consume no less memory, IIRC
10:34clgvchouser: that's not important
10:34Fossido you really need a new vector?
10:35Fossimaybe you can just lazily filter or such
10:35clgvI do 2 sequential readings and one random read
10:36clgvs/2/2 complete/
10:36sexpbot<clgv> I do 2 complete sequential readings and one random read
10:39clgvthat deletion is taking about 26% of the time when I implement it with loop-recur and a transient vector
10:40amalloyclgv: if you only do one random read, and only want to delete one thing(?), you can just manually keep a note of what index you deleted, and so a little math to avoid picking it
10:40amacamalloy: hah, someone popped into the qbasic channel while I was afk
10:40amalloy*laugh*
10:40amacI told you its coming back!
10:40amalloysee? you're starting a grassroots thing
10:41amacits the future, clojure is passe.
10:42clgvamalloy: hmm could be an option if it doesnt cost to much checking it in the sequential reads all the time
10:43amalloyclgv: you can make the sequential reads cost nothing at all
10:43clgvamalloy: what do you mean?
10:43amalloy(concat (subvec v 0 n) (subvec v (inc n) (count v)))
10:44amalloy&(let [v (vec (range 10)) n 3] (concat (subvec v 0 n) (subvec v (inc n) (count v))))
10:44sexpbot⟹ (0 1 2 4 5 6 7 8 9)
10:44clgvthe concat will cost me linear time. thats at least as bet as my loop-recur deletion I guess
10:44amalloyclgv: what. no it will cost you nothing. you're already spending linear time to walk over it, and concat is lazy
10:45clgvah right
10:45amalloyand both subvecs are O(1)
10:45clgvbut I cant do it nested
10:45clgvI'll delete increasingly.
10:45amalloyyes. the more requirements you pile on the more complicated the answer will get :P
10:48amalloymaybe you should just have a sorted-map with integer keys
10:49clgvno. that is no option. I am thinking about a way too eliminate the "random read"
10:50clgvthere is also another data structure involved that currently has a one-to-one correspondence
11:06tsdhWhen I have a parameter list like [x & {:keys a b c}] and I don't want to handle them but pass them through to another function, how can I do that except (other x :a a :b b :c c)?
11:07raektsdh: first, {:keys a b c} --> {:keys [a b c]}
11:07tsdhraek: Ah, yes, just a typo.
11:07raektsdh: but to answer you question: [x & {:as m}]
11:08raekor wait, if you will pass them as they are without inspeciting them: (defn f [& args] (apply g args))
11:10tsdhraek: Ah, no, you got me wrong. Currently, I have several functions like (defn foo [x & {:keys [a b c]}] (other (magic x) :a a :b b :c c)), and I'd like to stop that stupid repetition somehow.
11:11raek(defn foo [x & {:keys [a b c], :as m}] (apply other (magic x) (apply concat m))) is one way (but it's not very pretty)
11:12tsdhOr can I just say: (defn foo [x & keys] (other (magic x) keys)), and only other declares them?
11:14raekI think you need an 'apply' there
11:14raekunless 'other' takes an argument with the options on the form [:a 1 :b 2]
11:15raek(not a map=
11:17tsdhOh, yes, I've meant (apply other (magic x) args)
11:17tsdhWhere args = keys...
11:25amalloytsdh: i'm inclined to just not use the &rest syntax, and just pass around an option map
11:26amalloy(defn foo [x opts] (other (magic x opts)))
11:26amalloythen if there are params you actually need you can pull them out, and if not don't worry about it
11:27tsdhamalloy: Hm, but opts is optional and would lead to many {} in calls.
11:28amalloyadd a top-level function that sugars things up for the client before entering into your real functions
11:29amalloyeg if calls into your library typically start with (begin ...), you can (defn begin [arg & opts]) (begin* arg (apply hash-map opts)))
11:30amalloyalternatively, and i stress that this is usually the wrong answer, i have a macro that is the "opposite" of :keys
11:31timvisherhey all
11:31tsdhamalloy: But calls look like (p-apply v1 [p-seq [--> :cls 'Foo][<>-- :cls 'Bar]])
11:31amalloyhttps://github.com/amalloy/amalloy-utils/blob/master/src/amalloy/utils.clj#L32
11:31timvisheranyone have a minute to see if there's anything wrong with this clj repl shell script? https://gist.github.com/864408
11:32timvisherI had to reinstall when I moved from port to brew and now clojure-contrib doesn't seem to be included in the classpath
11:32timvisherlein works but I'd still like inferior-lisp every now and then
11:32amalloytim: lein repl or cake repl work outside of projects
11:33amalloy(out of the box with cake; minimal config with lein i believe)
11:33timvisheramalloy: do they include clojure-contrib by default?
11:33amalloytimvisher: my ~/.cake/project.clj includes clojure-contrib and my personal util library
11:34timvisheramalloy: aha.
11:34amalloyand that file gets used when starting an unaffiliated repl
11:34timvisherDidn't know that was possible. Do you know if lein has a similar facility?
11:34amalloyit does
11:34amalloyask technomancy what it is :P
11:34timvisherinteresting
11:34timvisheri can look it up. :)
11:35amalloyfwiw it also includes swank, so i can start a swank server without attaching to a project
11:36timvisheryeah. I just switched inferior-lisp-program to lein repl and it also starts up a swank server
11:36tsdhArgh, if I get a NullPointerException in a line that only contains "(map" and its function starts on the next line, what might be the reason?
11:39timvisheramalloy: do you manually add clojure-contrib to your CLASSPATH so that cake can see it?
11:39amalloyno
11:39amalloyhaven't touched CLASSPATH in five years :P
11:40amalloyi put it into ~/.cake/project.clj like i said
11:40timvisherso does cake have a set of directories that it searches by default or do you set that up somehow?
11:40timvisherwhat I mean is, lein's ~/.lein/init.clj
11:40timvisherwhich I think is the equivalent of what you're talking about
11:40timvisheris just arbitrary clojure code
11:40amalloyi don't think so
11:41timvisherah
11:41amalloyi'm talking about a project.clj entry just like every lein project has
11:41amalloycake has a global one as well
11:41timvisheroh ok
11:41timvisherso it's sort of a default project when you're outside of a real lein/cake project
11:41amalloyyes
11:42amalloyand also a parent project that all others "inherit" from
11:42amalloyi think
11:42timvishergotcha
11:45amalloytimvisher: http://malloys.org/~akm/cake.tgz in all its glory
11:45amalloymy whole dang ~/.cake
12:33timvisheranyone around that could explain how to make clojure-contrib available in lein repl running outside of a project?
12:37amalloyalias lein="cake" :)
12:37raektimvisher: for me contrib is available then
12:37raek(with leiningen 1.4.2)
12:38raekI think cake has more customizable "global project" features
12:39amalloyno offense to lein intended there. i am pretty sure lein has an equivalent feature, but i've already said so; since i only know how to do it in cake, switching to cake is the best advice i can give
12:39__name__good morning.
12:40hiredmanamalloy: ah, but once he actually wants to do anything, he'll have to switch to lein anyway
12:40amalloyhaha ouch
12:41amalloyscore one for team lein
12:41hiredmancake is absurd
12:42timvisheramalloy: I know that you can do it in cake, but I'm now down the rabbit hole of lein, as it were, and I'd like to figure out how to do it there.
12:43hiredmantimvisher: why are you using build tools to run repls outside of projects?
12:43timvisherraek: I only have 1.4.1. But that doesn't seem like it should make that much of a difference.
12:44timvisherbecause I can't get my clj command to work. https://gist.github.com/864408
12:44technomancytimvisher: lein repl => (use 'clojure.contrib.logging) => nil
12:44technomancyWFM
12:44hiredman~dirt simple
12:44clojurebothttp://www.thelastcitadel.com/dirt-simple-clojure
12:44timvisherperhaps there's something wrong with my clojure-contrib install...
12:45timvisheroh my
12:46timvisherOK, so I was under the impression that I could do something like (clojure.contrib.math/abs -1/3) and _not_ have to use or require.
12:46timvisherit appears that that assumption is wrong?
12:47technomancyyeah. in clojure 1.3 even some built-in stuff like clojure.set is not require'd by default
12:47hiredmangiven that no where else is it true, I would call it a bad assumption
12:48timvisherhiredman: it's true all over the place. I think of use and require like I think of import (which seems like a potential problem). In other words, import is a way of not having to type out java.xml.Blah every time I want to use Blah.
12:49timvisherso, in other words, (not (or (= 'use 'import) (= 'require 'import)))
12:49amalloytimvisher: (= refer import)
12:50__name__&(doc refer)
12:50sexpbot⟹ "([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, a... http://gist.github.com/864543
12:50amalloy(= use (comp refer require))
12:50hiredmantimvisher: it isn't true anywhere else
12:50timvisheramalloy: so why do I need to explicitly require when I don't need to explicitly import?
12:51amalloytimvisher: because classes are not the same as namespaces?
12:51timvisherok
12:52amalloytimvisher: for entertainment value, try (require 'clojure.contrib.repl-utils) and time how long it takes
12:52amalloythen ask yourself if you'd like to wait a hundred times that long every time you start a repl, so that it can load every namespace you might ever use
12:53timvisheryeah
12:53timvisherI get that. I think I've just discovered a few very large holes in my understanding of use, require, and namespaces.
12:53amalloyheh
12:53timvisherback to the drawing board with those topics, I guess
12:54timvisherthank's very much, everyone
12:54amalloytimvisher: require is a "lisp thing". probably best to draw a mental line between that and import
12:54amalloy(dividing them, not connecting them)
12:54joelris there anything wrong with this sequence of code? (for [file files] (with-open [rdr (io/reader file)] (log/spy rdr)))
12:55timvisherjoelr: what behavior are you seeing that you don't like?
12:56timvisherthere doesn't appear to be anything syntatically wrong that I can see.
12:57joelrtimvisher: for whatever reason, i print the # of files and it's fine, then that code does not print anything
12:57timvisherI think you're bumping up against it's laziness
12:57timvisherI'd use doseq instead
12:58joelrtimvisher: i think you are right. let me look at doseq
12:58timvishersomeone better than me can use the clojure bot to print the docs
12:58joelrtimvisher: still, it's very strange behavior
12:58timvishernot really, unless I'm wrong. clojure tries to be as lazy as possible
12:59timvisherit is weird though if you're not used to it
12:59joelrtimvisher: but shouldn't log "force" the results?
12:59timvishernot if that for expression is the only thing in your code.
13:00timvisherwhat that'll do, if my mental model is right, is basically transform each of the items in files into a function that can be called
13:00timvisherbut not call any of them
13:00timvisheruntil something else comes along and consumes the sequence
13:00timvisherwhich is why something like doseq is usefuly
13:00timvisherthe way I see it is as an eager for.
13:01joelrtimvisher: thanks
13:01joelrtimvisher: i think the key point here is that for collects results. this is where laziness is coming from. it's saving my printing for later.
13:01timvisherbut don't trust me too much, I'm still very new at this as well. :)
13:02timvisherexactly
13:02timvisherat least if my mental model is right. :)
13:02timvisherit's tough too if you're used to exploring in the repl
13:02timvisherbecause the repl will always force the results
13:02amalloytimvisher: good summary
13:02amalloyand it's pretty easy to get a bot to show you docs
13:02amalloy&(doc for)
13:02timvisherwhereas as soon as you move it into an actual clojure project, you loose a lot of eager behavior
13:02sexpbot⟹ "Macro ([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost f... http://gist.github.com/864558
13:03timvisherAh. where are the docs for the bots on this channel?
13:03amalloysexpbot even responds to inline requests with ##, like ##(doc doseq)
13:03sexpbot⟹ "Macro ([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
13:04amalloyhah, docs for the bots. you wish. the closest you'll get for sexpbot is https://github.com/Raynes/sexpbot/wiki/Commands
13:05amalloyyou'll probably have better luck asking me or Raynes about sexpbot, or hiredman for clojurebot; and better luck still watching what people do and then stealing it
13:05timvisheryeah
13:05timvisherso it is it just sexpbot and clojurebot on here?
13:06timvisheri'm more used to the emacs channel
13:06amalloyyeah they're the main bots. if there are others they're lurking
13:06timvishergood stuff
13:06timvisherwell this has been educational
13:06amalloyhaha
13:07timvisherand i contributed. hurray!
13:07timvisher:)
13:07amalloy(inc timvisher)
13:07sexpbot⟹ 1
13:08clgv$8ball
13:08sexpbotclgv: Outlook good.
13:08clgv$8ball
13:08sexpbotclgv: Ask again later.
13:09amalloyclgv: it's more interesting if you say
13:09amalloy$8ball will people get annoyed at clgv's sudden overuse of sexpbot?
13:09sexpbotamalloy: Outlook good.
13:09clgv:P
13:09amalloy$timer 0:20:0
13:09clgv$dec amalloy
13:09sexpbot⟹ 4
13:10clgv$karma amalloy
13:10clgv$dec amalloy
13:10sexpbot⟹ 3
13:10clgvlol hihi ;)
13:10clgvtime to finish work and go home
13:10clgvcya all
13:11amalloythat's weird. $karma amalloy should have worked as far as i can tell from reading the source (it's not my plugin)
13:14buttered-toast(inc amalloy)
13:14sexpbot⟹ 4
13:14buttered-toast(inc amalloy)
13:14sexpbot⟹ 5
13:14amalloy:P
13:16amalloy(that was my fork of sexpbot just now. karma isn't terribly important but it's even less important if it gets dec'd/inc'd arbitrarily
13:29sexpbotamalloy: ping
14:24pyrhi, I want my log4j.properties file to end up in the uberjar created by leiningen
14:24pyrhow would I go about doing that ?
14:26technomancypyr: slap it in the resources/ directory
14:26pyrthanks, lein new didn't create this one :)
14:32tsdhWhat does it mean if leiningen cannot fetch org.apache.maven:super-pom:jar:2.0?
14:32amalloytsdh: generally it means you're misunderstanding maven's error message (i always do too)
14:32amalloyscroll way the hell up to see which library it *actually* had trouble with
14:35tsdhamalloy: I get a backtrace... http://pastebin.com/3VJdQen4
14:35amalloydon't depend on 1.2.0-snapshot
14:35amalloyjust 1.2.0
14:36amalloy(and figure out which library you depend on itself depends on the snapshot, if it's not you. usually it's labrepl)
14:36tsdhamalloy: Not my lib. But changing to 1.2.0 worked.
14:37rick__Where can I find an up to date slime/swank + clojure tutorial? All the ones I've found use "swank-clojure-autoload" "swank-clojure/src/emacs" but they're not there in the git repositories (github.com/jochu). Any ideas?
14:37tsdhamalloy: I wouldn't have come to the conclusion that this is the cause for years. :-)
14:38technomancyrick__: is the readme insufficient?
14:38amalloytsdh: projects *should* have future-proof dependencies like "[1.2.0-SNAPSHOT,1.2.0]", but they usually don't
14:39amalloytechnomancy: isn't your repo the canonical source now, not jochu?
14:39tsdhamalloy: Blame ninjudd. ;-)
14:39amalloyi always do :)
14:39tsdhHaha
14:40technomancyamalloy: yeah, but they have the same readme
14:40rick__technomancy: tbh I haven't read it.. :x
14:45tsdhHow do I tell leiningen to compile some project into a jar?
14:46brehautlein jar ?
14:46tsdhlein compile doesn't seem to do anything, lein jar packs only the sources.
14:46technomancytsdh: depends; why do you want .class files in the jar
14:46technomancy?
14:46Fossi:D
14:47Fossisuch a great question XD
14:47tsdhSo that I can put it in the CLASSPATH of another project.
14:47Fossi"why in hell would you want any .class files in your jar? are you insane?"
14:47tsdhtechnomancy: The project I want to jar contains a clj part and a jvm java part.
14:47dnolenman this makes me want a Clojure->JS even more, http://www-sop.inria.fr/indes/scheme2js/
14:48technomancytsdh: ok, so you're using gen-class or deftype or some such? add the namespaces that need AOT to :aot [my.funky.ns my.other.ns] in project.clj
14:49technomancyor is it java source you need to run javac over? for that you set :java-source-path.
14:49tsdhtechnomancy: Yes, java and clojure source.
14:51pjstadigdnolen: another project of inria...make me want to move to france
14:51ossarehdnolen: I've been thinking about that - in my case I'd like to write "normal" clojure and have some compilation process to JS - I don't want to write js in clojure.
14:52ossarehjavascript has a BNF, I assume clojure does too?
14:52dnolenpjstadig: heh.
14:53dnolenossareh: that's what Scheme2Js does.
14:53dnolenthey even published a couple papers on how they implemented tail call optimization.
14:54edwIs there a statistician in the house? Or, does anyone know if there's a stats freenode channel?
14:54greghhttp://stats.stackexchange.com/ :)
14:55edwAh. Thanks.
14:55TimMcossareh: Braces, symbols, and some reader macros. What more do you need?
14:55brehautTimMc: special forms
14:56TimMcbrehaut: For parsing?
14:57brehautnot for parsing
14:57brehautbut parsing an sexp doesnt really provide the same information as say the BNF for javascript
14:57TimMcAh, OK.
14:57brehautonce you have parsed some javascript you know what the blocks anf functions and whatever are
14:58TimMcdo-expr, let-expr, etc.
14:58TimMcfn-call
14:58brehautTimMc: http://clojure.org/special_forms that stuff
14:59TimMcossareh: As far as I know, Clojure does not yet have a formal spec.
15:00chouserdo primitive args work on forward-declared fns?
15:01hiredmanseems like they should
15:01hiredmandecalare is just about the name
15:01hiredmanthe var
15:01hiredmanthe primitive part is from the fn object
15:02hiredmanunless the primitive stuff uses extra metadata
15:02hiredmanthe new fnloader stuff may mean that primitive fns aren't run as primitive the first time
15:03tsdhlein compile always gives me "FileNotFoundException: Could not locate clojure/lang/PersistentOrderedSet__init.class or clojure/lang/PersistentOrderedSet.clj on classpath". But there is classes/clojure/lang/PersistentOrderedSet.class.
15:04chouser(declare a) (defn b [] (a 1)) (defn a [^long i] ...)
15:05chouserIt seems like b might compile the call to a with autoboxing. How could it not, actually?
15:06dnolenchouser: I recall rhickey saying, re-defing forces callers to recompile their bodies I thought upon call.
15:07chouserrecompiling a function when it's *called*? Sorry if I remain suspicious...
15:07dnolenthat's how redefing is supported in post-dynamic-by-default world.
15:07hiredmanI dunno about recompiling
15:07hiredmanpossible some kind of thunk thing like with keyword callsites
15:07dnolenthat's what I remember, could be wrong o course.
15:08TimMcCould this be detremined using a macro with side effects?
15:08chouserprobably not
15:09raektsdh: looks like you are trying to 'require' or 'use' a java class
15:10hiredmanhe could have meant that you need to recompile callers
15:10hiredmannot that the compiler does it for you
15:10tsdhraek: Yeah, the project has 1 java class and one clj file. The java class is successfully compiled to classes/clojure/lang/PersistentOrderedSet.class, and then I get that error.
15:11amalloytsdh: his point is that you don't use/require java classes, you import them
15:11hiredmanwow, invokePrim is cute
15:12tsdhamalloy: That's true.
15:12raekthe JVM handles class loading automatically, so as long the class in available on the classpath you should be able to instantiate it using (clojure.lang.PersistentOrderedSet. ...) without importing or requireing anything
15:13tsdhOk, now I switched import versus use, and now lein compile errors with: Exception in thread "main" java.io.FileNotFoundException: Could not locate ordered_set__init.class or ordered_set.clj on classpath
15:13dnolenhiredman: you don't need need to recompile callers. that was the problem with ^:static.
15:14dnolennew world avoids that mess.
15:14hiredmandnolen: for vars
15:14hiredmanbut is that really the case for primitive fns?
15:15dnolenhiredman: all i know is, I can now declare primitive fns whenever I want and I don't have to recompile callers.
15:16TimMcjkkramer: I'm failing to understand the proper syntax for edges in the digraph constructor.
15:16raektsdh: looks like src/ordered_set.clj is missing
15:17tsdhraek: it's in src/clj/
15:20dnolenhiredman: chouser: http://clojure-log.n01se.net/date/2010-10-18.html#18:35a
15:20raekand src/clj/ is on the classpath rather than src/ ?
15:20TimMcjkkramer: Cancel that, there was an impedance mismatch. :-)
15:21hiredmandnolen: right, but doesn't mention compiling
15:22tsdhraek: I have to admit, that I have no clue, I don't even know what AOT stands for...
15:23TimMcmap != mapcat
15:23TimMctsdh: Ahead Of Time
15:24raektsdh: (I'm assuming leiningen here) you need to set :source-path "src/clj/" in your project.clj. otherwise "src/" will be treated as the source root
15:26hiredmandnolen: the compiler seems to convert the a call of (foo 1 2) where foo is a primitive fn to (.invokePrim foo 1 2) and then compile it
15:26raek(either that or change the require/use form to "clj.ordered-set", but I assume that you don't want to have "clj" as a part of your namespace)
15:26dnolenhiredman: so it is a recompile?
15:26hiredmanpossibly AFn's invokePrim has magic to avoid the need to recompile
15:28raektsdh: also, AOT compilation = ahead of time compilation.
15:29tsdhraek: Hm, even with both :java-source-path and :source-path it doesn't work. http://pastebin.com/QrJn1JC3
15:31raektsdh: clojure.lang.PersistentOrderedSet shouldn't be in :aot. :aot is only for clojure code. leiningen makes sure that all .java files in :java-source-path gets compiled when you run "lein compile"
15:32tsdhraek: Yeah! That does work. Great!
15:32dnolenchouser: hiredman: http://clojure-log.n01se.net/date/2010-10-15.html#12:22e, ok maybe not recompile :) I'm not sure what "reload cache" entails.
15:32raektsdh: a project that has both clojure and java source https://github.com/raek/map-exception
15:33hiredmandnolen: must be something like the call site cache for keywords on records
15:33tsdhArgh, too easy. technomancy has dazzled me with this AOT thingy. :-)
15:33hiredmandnolen: that is a different thing though
15:33hiredmannon-dynamic vars and primitive functions are two entirely different features moving towards the same goal of performance
15:34raektsdh: if you have :gen-class in any namespace, then that namespace needs to be aot compiled
15:34tsdhraek: I don't.
15:35hiredmandnolen: rich is contrasting non-dynamic vars to the "static" call site linking you got with :static
15:41dnolenhiredman: ah, gotcha.
15:43hiredmanso now there are var callsite caches, protocol caches, and keyword caches, I suppose there could be primitive caches too
15:45angermanhow do i check if a var is already bound?
15:46angermanahh, i need the #' syntax
15:51hiredman,#'foo
15:51clojurebotjava.lang.Exception: Unable to resolve var: foo in this context
15:59angermanhiredman: I choked on (bound? foo) :D
16:08angermanSubdividing a cube under planarity constrains with clojure and jReality: http://dl.dropbox.com/u/281539/jReality-planar-subd.mov
16:08angermanif only the second iteration wouldn't break :/
16:09jweissI have a macro that expands into code that logs with java.util.logging. if I don't specify the class and method to log with, it will use "sun.reflect.NativeMethodAccessorImpl.invoke0" which I assume happens because it's being invoked via reflection. So I want to specify. I can get the "class" right with (str *ns*) i think. But the method? seems like my macro would have to know the name of the surrounding defn.
16:12jweissI don't think it's possible to write (defn myblahfn [] (somecode) ) such that "somecode" will print whatever the fn name is (in this case "myblahfn")
16:13angermanhmm… what do the *-vars say?
16:13jweiss*-vars?
16:14angermansorry. just had a look at the documentation; there's nothing to hold onto as far as i can see :/
16:15jweissyeah, i sorta expected not
16:15jweisshow do people use the various logging utilities then?
16:15jweissseems like no matter what, you end up with wrong class/method locations.
16:15angermanyou could though wrap defn, and inject a (binding [*current-fn* …] … )
16:16angermanand the (meta …) of that fn tells you line and a bunch more.
16:16amalloyjweiss: most clojure logging uses the namespace as the smallest unit of logging; ns/line is plenty of info to debug without needing ns/class/line
16:17angermanahh well. good night...
16:17raekare these two proxies the same? https://gist.github.com/864942
16:18raek(I prefer the first one since I can replace prepare-renderer with #'prepare-renderer, but I want to be sure I don't construct a broken proxy)
16:21jweissamalloy: java.util.logging does not use line numbers.
16:21jweissjust class/method.
16:23ev4lgood morning everyone. can anyone explain to me why this happens?
16:24ev4l(if (> 2 4) (println "bigger") (println "smaller"))
16:24ev4l> bigger
16:24ev4l> nil
16:24hsbot mueval-core: L.hs: removeLink: does not exist (No such file or directory)
16:24hsbot Not in scope: `nil'
16:24ev4l(if (> 2 4) (println "bigger") ((println "smaller") (println "number")))
16:24ev4l> smaller
16:24ev4l> number
16:24hsbot Not in scope: `smaller'
16:24ev4ljava.jang.NullPointerException (NO_SOURCE_FILE:0)
16:24hsbot Not in scope: `number'
16:24ev4lwhy am i getting a NullPointerException when i have a multi-statement else form?
16:25edwWhat is this mult-statement else form you refer to?
16:25ev4lthe second one
16:25edwYeah, that's not legal.
16:25jweiss,(if (> 2 4) :bigger :smaller)
16:25clojurebot:smaller
16:25edw((println...) (println ...)) fails because println returns nil. Nil is not a function.
16:26amalloyedw: it's not "Not legal", it's just not what he means
16:26ev4lthere are no ways to run two statements or more at the else form?
16:26edwRight, good point.
16:26edw(do (println 'foo) (println 'bar))
16:27ev4lhmm, nice, lemme check
16:27amalloythis is funny because i was ev4l a year ago. i was in #lisp going like "well why can't the dang computer just tell that i mean ((f1 blah) (f2 blah)) as a list instead of some other crazy thing"
16:28ev4lamalloy: you're joking ... lol
16:28amalloy&(if (< 1 0) (do (print true) (print 1)) (do (print false) (print 0)))
16:28sexpbot⟹ false0nil
16:28edwamalloy: I remember back in the day having to unlearn my tendency from C to "when in doubt, throw more parens in."
16:29ev4ledw: amalloy my logic is that every statement should be enclosed in a () form :D
16:29amalloyev4l: start by taking the word "statement" out of your vocab
16:30jweissthere are no statements in lisp (or at least, no diff between expression and statement)
16:30ev4ljweiss: nice. got your point
16:31amalloyev4l: ##(= 10 (if (< 9 5) 0 10))
16:31sexpbot⟹ true
16:32amalloybecause everything is an expression, you can put if-expressions anywhere you would put, say, an addition-expression
16:34ev4lamalloy: lol... still addicted to the fact of if being a special syntactic element
16:34ev4l(in most languages)
16:35__name__I don't see how that is such a change.
16:35TimMcev4l: Just pretend it's the ternary operator. :-)
16:36amalloyTimMc: indeed
16:36amalloynow do the same for (for) :)
16:36tsdhWhen I have a nested vector of function symbols like [a [b c d] a], and I want to put a numbering as metadata on them, how would I do that? I guess with clojure.walk, but how to do the "counter"?
16:36TimMcThough... I wonder if the ternary operator evaluates all its arguments ahead of time, in various languages.
16:36amalloyTimMc: i can't think of any languages where it does
16:36amalloynot even php is that dumb
16:37ev4lamalloy: jweiss TimMc : thankx a bunch :D
16:37TimMcfor is a list comprehension, like in Python
16:37TimMc(I can't do any better than that.)
16:39amalloyTimMc: feh. python. that one wouldn't work for me
16:39TimMc:-P
16:41TimMcI'm so close to having this logic pipeline utility working!
16:41TimMcI just need to figure out why it's being picky about which logic blocks get executed. >_>
16:42TimMcThen I'll need to figure out this whole packaging and clojars and Maven thing.
16:42amalloyTimMc: it is omg so easy
16:43amalloyesp assuming you already have an ssh keypair
16:43TimMcThat I do.
16:43currentBcan anyone recommend a good course of action for learning to do TDD in clojure, having never done really any testing before?
16:43amalloy(1) get a clojars account (2) associate keypair with it (3) cake release
16:44raektsdh: there happens to be an example of that here: http://clojuredocs.org/clojure_core/clojure.walk/postwalk
16:44jweissI can't seem to figure out how to split the string "asdfsd$tyutyu" at the "$" character. (split blah #"\\$") doesn't work
16:45tsdhraek: Oh, great. So that's how to use atoms... :-)
16:45amalloy&(split-with #{\$} "asdfsd$tyutyu")
16:45sexpbot⟹ [() (\a \s \d \f \s \d \$ \t \y \u \t \y \u)]
16:45amalloy&(split-with (complement #{\$}) "asdfsd$tyutyu")
16:45sexpbot⟹ [(\a \s \d \f \s \d) (\$ \t \y \u \t \y \u)]
16:45amalloyjweiss: warning: that is like the worst solution there is
16:46jweissi think my problem is being unable to specify a literal $ to the java regex machine
16:46TimMcjweiss: Backslash it?
16:46jweissmaybe emacs is screweing me. it will only let me add double backslash
16:46raekjweiss: (ns foo.bar (:require [clojure.string :as str])) (str/split "asdfsd$tyutyu" #"\$")
16:46jweissah there we go
16:46raek=> ["asdfsd" "tyutyu"]
16:46TimMcjweiss: which is then read as a single backslash.
16:47jweissno, in emacs i really had to type a single backslash
16:47jweissnd then it says "Escaping Character..." in the minibuffer
16:47jweissthat kinda threw me
16:48TimMc,(count "\\$")
16:48clojurebot2
16:48TimMcOh wait, I misread you, sorry.
16:58powrtochas anyone here used clojure.contrib.dataflow?
17:00powrtocIt seems it's only good for static cells as the macro they use to expose node names uses the symbol you give it for the cell name, and doesn't seem to let you generate a symbol programatically
17:02raeka common symptom of macroitis...
17:02powrtocraek, quite
17:03powrtocit's a PITA... was wondering if I could wrap it in a macro to generate the symbol I need
17:03fliebelYou see, macros are contagious.
17:03powrtocyeah :-\
17:03raekcgrand was right!
17:03fliebelhe still is, I hope...
17:05powrtocbut I don't think wrapping it works... as macros are compile time, and that's when the symbol name needs to be specified
17:07raekpowrtoc: can you use build-standard-cell, build-source-cell or build-validator-cell? (note, I haven't used dataflow, but the macro expands into calls to those fns)
17:09powrtocraek, Yeah I looked at that... the problem is build-standard-cell (which is the case I want), needs to get-deps which is a private function to the namespace
17:10raekthat can be circumvented... >:)
17:10raekwell, relying on private fns are not very good to do of course...
17:10powrtocraek, how do you circumvent it?
17:11powrtoc(other than copying the fn into my namespace)
17:11raek,(require 'clojure.contrib.dataflow)
17:11clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/dataflow__init.class or clojure/contrib/dataflow.clj on classpath:
17:11amalloypowrtoc: (#'somens/somefn args)
17:13powrtocamalloy, cute
17:15powrtochmmm... has anyone here tried dgraph? https://github.com/gcv/dgraph
17:16raekwhat is the best way of detecting when a JFrame is closed? I want a watcher to be in place when the frame is visible and for it to be removed when the frame is closed.
17:17amalloyraek: http://download.oracle.com/javase/1.5.0/docs/api/java/awt/Window.html#addWindowListener%28java.awt.event.WindowListener%29
17:19amalloyraek: proxy WindowAdapter and put your logic on windowClosed
17:23TimMc$findfn #(= % 9) [6 4 5 9 7] 3
17:23sexpbot[]
17:23TimMc$findfn #(= % 9) [6 4 5 9 7] 9
17:23sexpbot[]
17:23fliebelpowrtoc: Woa, looks nice :)
17:23amalloyTimMc: you're looking for indexof?
17:24TimMcPerhaps.
17:24amalloy&(.indexOf [6 4 5 9 7] 4)
17:24sexpbot⟹ 1
17:24raekamalloy: I did an experiment with a proxy and some printlns. "closing" seems to be called, but "closed" is not
17:24amalloyraek: k. it's been a long time since i knew details about the difference
17:25TimMcamalloy: No, I want to use a predicate
17:26amalloyTimMc: keep-indexed?
17:26raeksetDefaultCloseOperation accepts both HIDE_ON_CLOSE and DISPOSE_ON_CLOSE. *investigates*
17:26amalloyraek: hide leaves the object alive
17:26amalloyso that you can (.show) it later
17:26amalloydispose destroys it
17:28raekbut how do I detect that it gets hidden? windowClosed is not called when I close the window.
17:29TimMcamalloy: Hmm, perhaps.
17:30raekah. http://stackoverflow.com/questions/622814/window-events-for-jframes-that-are-hidden-shown-via-setvisible
17:32TimMcamalloy: Yay!
17:33amalloyTimMc: i think i wrote this code like yesterday for someone else
17:33amalloyin the #clojure logs
17:33amalloy(after stealing the idea from hiredman)
17:34TimMcamalloy: I implemented the Collatz calculation as a series of logic blocks and registers, and it works!
17:34amalloynice
17:35TimMchttps://github.com/timmc/pipeline/blob/master/test/org/timmc/pipeline/test/core.clj#L87
17:35TimMcIt's a very contrived test-case.
17:39amalloycan you think of any use of collatz that is not contrived and/or useless?
17:39TimMcheh
17:40TimMcSo... it's doubly contrived!
17:42raeknow this is starting to become something! http://raek.se/gophure.png
17:47amalloyraek: not sure why, nor whether you care, but that font/layout makes me think of EULAs for some reason
17:49raeksince that directory contains the text "PLEASE READ" and "LEGAL INFORMATION", I'm not surprised by your reaction... ;-)
17:54TimMcI also need a decent name for this thing. It's a behavioral simulator for digital circuits, using arbitrary-valued "wires" (not just booleans.) You initialize it with a set of registers and then step it forward, and can check the value on each wire or register.
17:54TimMc"Pipeline" is the current name, but that's what I'll be using it *for*, not what it is.
17:55TimMcI'm kind of tempted to give up and name it after some animal or pastry. -.-
17:55brehautwhat about 'wijure' :P
17:56amalloyclojd-circuit :P
17:57TimMcThose are both brilliant suggestions that I would totally take if I were a bad person.
17:57amalloyOMG. C-= and C-- change text size in the current buffer. how did i go so many months as a visually-impaired user not knowing this
17:58TimMcYou're not visually impaired, I can see you just fine!
17:58amalloyTimMc: i'm typing extra small for you
18:07edoloughlinEasiest way to achieve this: (assoc {} ["key" "val"]) - i.e., I've got a vector I want to use as key, value? Best I can come up with is (assoc {} (first ["key" "val"]) (second ["key" "val"])) but this seems ugly...
18:07TimMcThe name should probably have something to do with "cycle" or "circular", since it is specifically for logic circuits that loop back on themselves and change only on clock cycles.
18:08TimMc,(into {} ["key" "val"])
18:08clojurebotjava.lang.ClassCastException: java.lang.Character cannot be cast to java.util.Map$Entry
18:08raekedoloughlin: ##(conj {} ["key" "val"])
18:08sexpbot⟹ {"key" "val"}
18:08TimMc,(into {} [["key" "val"]])
18:08clojurebot{"key" "val"}
18:08TimMc,(apply assoc {} ["key" "val"])
18:08clojurebot{"key" "val"}
18:09brehaut,(apply hash-map [:key :val])
18:09clojurebot{:key :val}
18:09edoloughlinTimMc: thanks. Still don't have API muscle memory...
18:09raekTimMc: maybe "signal"?
18:10TimMcI'mma grab me a thesaurus.
18:13TimMcOh, huh... "circuit" is related to "circular".
18:20TimMcshort-circuit? feedback?
18:24edoloughlinraek: apologies, didn't notice your conj solution earlier
18:24brehautTimMc: johnny-5
18:25TimMcbrehaut: Error: Could not dereference symbol "johnny-5"
18:25brehautTimMc: not a child of the 80s then
18:25TimMcNope, born in 1984.
18:25brehautjohnny 5 is the robot from the movie Short Circuit
18:25TimMcOh, ha!
18:25brehauthe was also programmed in lisp
18:26companion_cubedo you have a Big Brother, TimMc ?
18:26brehaut(seriously, you can see big green blurry lisp in the movie)
18:26TimMccompanion_cube: No, only child.
18:32amalloyTimMc: i like feedback
18:33amalloyalso: tired of old fogies like TimMc - 1985 all the way
18:33TimMcjohnny-5 is a pretty good name, though I'd feel weird about referencing a character from a movie I hadn't actually seen. :-P
18:33amalloybrehaut: that's neat. i haven't watched the movie since picking up lisp
18:35TimMcSo, would I name the project org.timmc/feedback ? (I own timmc.org)
18:36amalloyTimMc: you *could*, and java would
18:36__name__why is it not mc tim?
18:36__name__that'd be an awesome rap name.
18:36TimMcheh
18:36amalloythe trend in clojure is to just use "feedback" on the theory nobody else will want it. your name is so general that they might though
18:36__name__jo, i'm mc tim!
18:37amalloy__name__: and i'm here (to lisp)
18:37TimMc__name__: I really want tim.mc, but I think I'd have to start a business in Monaco.
18:37TimMcIt's *available* though.
18:38TimMcand then my reverse domain would be mc.tim
18:38brehautive not bothered with the RDN packages for my own stuff
18:38__name__\o/
18:38amalloyTimMc: take it anyway
18:38TimMchaha
18:38amalloymy utility project is in namespace amalloy.utils
18:39TimMcmc.tim/feedback?
18:39brehautit wouldnt be slash, because thats the contents of a namespace
18:39brehautraher than a namespace itself
18:39TimMcOh right.
18:40TimMcI was mixing up the Maven stuff with namespaces.
18:40TimMcarg
18:40raekworks as a grop/artifact id for maven repos though
18:40raek*group
18:40TimMcI really shouldn't take mc.tim as a group if I don't have the domain, since it would be a valid domain.
18:41brehautamalloy: that gist i sent you is doing a bunch of busywork with the bracket counting; it never actually uses that information. i think you can get away with the implicit stack of the parser, just use failpoint to work out what kind of error you have
18:41TimMcorg.timmc/feedback <-- would it make sense to just have ./src/feedback.clj, or should I use feedback.core instead?
18:44raekwhy not org/timmc/feedback.clj?
18:45TimMcDoes the artifact ID have anything to do with the namespaces?
18:46raekiirc, the .core suffix was added in leiningen to default to a non-empty package (since Java chokes on that somethimes)
18:46raeknamespaces and group+artifact id does not have to have anything in common
18:47raek(technically)
18:48TimMcThen org/timmc/feedback.clj with identifier org.timmc/feedback ? Sounds reasonable.
18:48raekthe project I am working on now is called [se.raek/gophure-swing "1.0.0"] and has its main namespace as se.raek.gophure.swing
18:48brehautTimMc: yes
18:48raekTimMc: that would be how I would do it... :) (note that there are other convetions as well)
18:49raekfor projects to be in the central maven repo, the group id has to be a real domain name and you have to own it
18:49brehautTimMc: i'm a bit lazier so my xml-rpc lib is 'necessary-evil' for the the identifier and 'necessary-evil.core' for the primary namespace
18:51TimMcAnd last thing... versioning. Should I just leave it as 0.1.0-SNAPSHOT for now?
18:51brehautif its just a snapshot yes. if its actually your 0.1.0 release: no
18:52TimMcsure
18:52TimMcFor releases, I remove snapshot, bump the version appropriately, tag, and release?
18:53brehautyeah pretty much
18:53TimMcOK, sweet.
18:53raek...and obey the rules of http://semver.org/ :)
18:53TimMcraek: indeed
18:55brehautTimMc: thats important; necessary-evil is accidentally a 1.0.0 project because i forgot to wind back the version before doing the first release, so now because semantic versioning, im not allowed to do that. luckily not much needs to change
18:56TimMcYeah, I was surprised that lein uses 1.0.0-SNAPSHOT as the default.
19:06amalloyi changed ~/.cake/project.clj to use 0.0.1 (not snapshot)
19:08TimMcWhat is the point of snapshot, anyway?
19:09powrtocdo futures execute on their own thread or the agent thread pool?
19:09amalloyTimMc: git HEAD without git access
19:09amalloybasically
19:09TimMc(going AFK for dinner)
19:09powrtocI can never remember
19:09amalloypowrtoc: new thread
19:12hiredmanno, it is the same threadpool that send-oof uses
19:12hiredmansend-off
19:13amalloy$source send-off
19:13sexpbotsend-off is http://is.gd/h4vV3P
19:14rata_is there anything special about a ring app that could make my (def foo (atom {})) clear unexpectedly?
19:16amalloyhiredman: neat. so it reuses threads, but there's no limit to how many of them can exist at once, right?
19:16rata_amalloy: yes
19:17rata_isn't a atom or ref supposed to be the normal way to store state in a webapp?
19:18hiredmandepends, generally you'll want to stick state in some kind of external datastore
19:19amalloyrata_: are you using reload middleware? that might reload the namespace
19:19brehautrata_: what server/adapter are you using for your ring app?
19:19rata_amalloy: yes, I'm using the reload middleware... I'll try with defonce
19:20rata_brehaut: I don't really understand your question
19:20brehautrata_: are you using jetty with the ring.adapter.jetty adapter ?
19:20rata_(I'm new to ring and web development)
19:20rata_brehaut: yes
19:21brehautrata_: then amalloy's guess is the best.
19:21brehautthe jetty adapter does nothing fancy with your application
19:21rata_ok
19:23rata_oh thank you guys =) it doesn't get clear now
19:25amalloyomg i helped with a ring app. i can't even write a ring app
19:25brehautahaha
19:25brehautthats the secret of ring: its nothing special
19:29weilaweiIf I have something of a type #<Context org.zeromq.ZMQ$Context@384ab40a> (or ZMQ$Context) in clojure, why do I need the ZMQ$ bit.. and what's it mean in java? I can't do (. ZMQ Context) and get a Context class or anything.
19:29weilawei(note, im not a java programmer and new to clojure)
19:30hiredmanthe $ is part of the class name
19:31hiredmanpackage is org.zeromq and the class is ZMQ$Context
19:31hiredman$ means something in java but you don't really have to care about it
19:37weilaweithanks hiredman :)
19:37weilaweiis there any way i can import it as Context? or use it like that?
19:38weilaweitechnomancy: but i like zeromq and I use it from C already >_<
19:38technomancywell if you're familiar with the APIs it's a plus, but JVM libraries that call into C can often cause difficult-to-diagnose build/distribution problems.
19:40hiredmanweilawei: I would just use as is, there are some things you could do to fiddle what clojure symbol maps to what class in a given namespace, but it's generally better not to
19:40danlarkinI have found this is the best way to bring it into a leiningen project, https://github.com/Storkle/jzmq-native-deps
19:47powrtocif I have a tree of nested maps... e.g. {:p {:p {:p nil :k 3} :k 2} :k1} whats the best way to walk it up the :p keys, executing a side-effecting function for each map?
19:47powrtocobviously loop/recur work .. but is there a nice oneliner?
19:48powrtocI want to bottom out on the nil
19:48hiredman,(doc tree-seq)
19:48clojurebot"([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may ...
22:34waxroseMorning all.