2011-03-10
| 01:04 | technomancy | a version from mid-august that was outdated only three weeks later |
| 01:05 | amalloy | technomancy: a perverse desire to show they're not afraid of 13 |
| 01:08 | amalloy | or: a belief that it will magically turn into clojure 1.3.0 |
| 01:10 | technomancy | with swank-clojure the versions actually match the clojure versions pretty closely |
| 01:18 | amalloy | technomancy: see? so totally plausible that someone might intend lein to do that |
| 01:19 | technomancy | yeah I'd buy that except for the fact that 1.4.0, which is also obsolete, got more downloads than that. |
| 01:36 | Derander | technomancy: you've probably got some old tutorials floating around out there |
| 01:45 | ossareh | Am I right in thinking that when you aot compile a namespace that all dependent namespaces get compiled to? |
| 02:17 | chouser | ossareh: yes |
| 02:27 | ossareh | chouser: 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:27 | ossareh | So at production time I have my test configs :/ |
| 02:33 | iwillig | does anyone know why, if i have a function with keyword arguments, i can't call that function with a hash map |
| 02:33 | iwillig | with the correct keys |
| 02:34 | zakwilson | How long should I expect clojure.xml/parse to take on a 900M file on a modern laptop? |
| 02:35 | iwillig | never mind |
| 02:35 | iwillig | figure it out |
| 02:35 | iwillig | sorry to bug people |
| 03:10 | sorenmacbeth | hello all |
| 03:11 | sorenmacbeth | could someone help me with what I'm sure is a simple problem, unless you are new to clojure that is |
| 03:11 | sorenmacbeth | I'm trying to create word level n-grams of up to a maximum length of n from a seq of words |
| 03:13 | sorenmacbeth | so for a seq like ("foo" "bar" "baz") and n = 2 I'd want ("foo") ("bar") ("baz") ("foo bar") ("foo baz") ("bar baz") |
| 03:31 | bytecoder | sorenmacbeth: have a look at clojure combinatorics. it might help. http://richhickey.github.com/clojure-contrib/combinatorics-api.html |
| 03:33 | sorenmacbeth | bytecoder: 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:35 | tsdh | If 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:36 | raek | tsdh: no. but you can use bound-fn and bound-fn* to make it so. |
| 03:37 | raek | (no, they don't se the dynamically bound value) |
| 03:37 | bytecoder | should be simple with mapcat |
| 03:37 | tsdh | Ah, 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:37 | bytecoder | &(mapcat (partial selections #{"foo" "bar" "baz"}) (range 1 3)) |
| 03:37 | sexpbot | java.lang.Exception: Unable to resolve symbol: selections in this context |
| 03:38 | hiredman | tsdh: *out* is dynamically bound |
| 03:38 | bytecoder | sorenmacbeth: (mapcat (partial selections #{"foo" "bar" "baz"}) (range 1 3)) |
| 03:38 | raek | tsdh: the same reason, actually. the output is sent to *out* which is rebound for the repl thread |
| 03:38 | tsdh | hiredman: Ah, so the same as with x. :-) |
| 03:39 | tsdh | raek: Is your suggestion to bound-fn a function that calls pmap? |
| 03:39 | raek | you can do a (alter-var-root #'*out* (constantly *out*)) in the slime repl |
| 03:40 | sorenmacbeth | bytecoder: awesome, that is super close, the only issue that is does ("foo foo") ("bar bar") ("baz baz") |
| 03:40 | tsdh | raek: Great, that does the trick. |
| 03:40 | raek | tsdh: boudn-fn works as a replacement for fn, so you can use it like (binding [x true] (pmap (bound-fn [y] ...) [...]) |
| 03:41 | tsdh | Ah, I see. |
| 03:41 | bytecoder | sorenmacbeth: oops. replace selections with combinations |
| 03:41 | bytecoder | sorenmacbeth: (mapcat (partial combinations #{"foo" "bar" "baz"}) (range 1 3)) |
| 03:42 | sorenmacbeth | bytecoder: perfect! |
| 03:42 | sorenmacbeth | bytecoder: thanks much. I have MUCH clojure foo to learn ;) |
| 03:42 | tsdh | But 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:43 | hiredman | in master they are shared |
| 03:43 | hiredman | but vars aren't dynamic by default any more |
| 03:44 | tsdh | hiredman: And the latter was a performance reason, right? |
| 03:46 | hiredman | tsdh: yes it means less overhead spent checking for dynamicly bound vars |
| 03:46 | bytecoder | sorenmacbeth: np. look around. there is most likely a function or library that already does what you want :) |
| 03:46 | tsdh | Phew, I hope there will be some good update guide when 1.3 comes arround... |
| 03:53 | tsdh | Is it possible to have a fn with args [x & rest {:keys a b c}]? |
| 03:55 | raek | ,(let [[x & {:keys [a b]}] [0 :a 1 :b 2]] [x a b]) |
| 03:55 | clojurebot | [0 1 2] |
| 04:01 | Cozey | Good 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:02 | Cozey | It's slime 20100404 |
| 04:02 | Cozey | or even 20100404.1 |
| 04:08 | bytecoder | ,(clojure-version) |
| 04:08 | clojurebot | "1.2.0" |
| 04:11 | bartj | how can I remove duplicates from a sequence of hash-maps ? |
| 04:12 | bartj | eg: , ({:a 3} {:a 5} {:a 10} {:b 3}) and retain only the max value |
| 04:12 | bartj | ie. {:a 10 :b 3} |
| 04:14 | clgv | bartj: for exact duplicates distinct does the job. your case seems to require own work^^ |
| 04:16 | clgv | you 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:17 | krumholt | bartj, does the sequence only contain maps in the form {:key value} not {:key1 value1 :key2 value2} ? |
| 04:17 | bartj | I thought of a merge-with -> concat -> pick the max ? |
| 04:17 | bartj | krumholt, yes |
| 04:21 | clgv | that one works too: (merge-with max {:a 3} {:a 5} {:a 10} {:b 3}) |
| 04:21 | clgv | &(merge-with max {:a 3} {:a 5} {:a 10} {:b 3}) |
| 04:21 | sexpbot | ⟹ {:b 3, :a 10} |
| 04:22 | clgv | so for your seq it should be: ##(apply merge max '({:a 3} {:a 5} {:a 10} {:b 3})) |
| 04:22 | sexpbot | java.lang.ClassCastException: clojure.core$max cannot be cast to clojure.lang.IPersistentCollection |
| 04:22 | clgv | ups |
| 04:24 | krumholt | nice solution clgv all you need now is reduce |
| 04:25 | krumholt | ,(reduce #(merge-with max %1 %2) '({:a 3} {:a 5} {:a 10} {:b 3})) |
| 04:25 | clojurebot | {:b 3, :a 10} |
| 04:25 | clgv | krumholt: I thought one can do it with apply but it cant handle the function param it seems |
| 04:26 | bartj | that is better than a bloated reduce I have ! |
| 04:26 | raek | ,(apply merge-with max '({:a 3} {:a 5} {:a 10} {:b 3})) |
| 04:26 | clojurebot | {:b 3, :a 10} |
| 04:26 | clgv | oh damn. forgot the "with" |
| 04:26 | krumholt | thats even better :) |
| 04:27 | bartj | (max-key {:a 5 :b 3}) |
| 04:27 | bartj | , (max-key {:a 5 :b 3}) |
| 04:27 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$max-key |
| 04:27 | bartj | , (apply max-key {:a 5 :b 3}) |
| 04:27 | clojurebot | [:b 3] |
| 04:27 | bartj | shouldn't it be :a ? |
| 04:28 | clgv | it's called max-key and not max-val ;) |
| 04:28 | clgv | :a < :b |
| 04:28 | bartj | yeah, lexographically |
| 04:30 | bartj | are there any utility map functions |
| 04:30 | bartj | to get the keys with the maximum values ? |
| 04:32 | Cozey | what happened to clojure.core/with-out-str in 1.3 ? |
| 04:32 | Cozey | and how to check such things in git? |
| 04:37 | clgv | bartj: 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:37 | sexpbot | ⟹ [:a 5] |
| 04:39 | bartj | my solution was like this (remove nil? (map #(if (= max-val (m %)) % nil) (keys m))) |
| 04:39 | bartj | where m is a map and max-val is the maximum-value |
| 04:39 | bartj | max-val is computed as: (apply max (vals m)) |
| 04:40 | clgv | looks a lot longer ;) |
| 04:40 | bartj | the trouble with clgv is that it doesn't return multiple-keys if both of them have multiple values |
| 04:41 | bartj | sorry I meant with your solution |
| 04:41 | clgv | oh right |
| 04:41 | clgv | well I would use a loop-recur approach over the seq of key-val-pairs then |
| 04:43 | raek | Cozey: what has changed about it? |
| 04:43 | Cozey | it disappeared |
| 04:44 | raek | strange |
| 04:44 | raek | https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4102 |
| 04:44 | Cozey | hmm wait |
| 04:44 | Cozey | but swank thrown a null exception on this.. i need to take a better look, sorry for this one |
| 04:49 | khaliG | Long 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:51 | Cozey | hmm 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:52 | raek | technomancy's |
| 04:53 | raek | the graph is biased towards the fork you are currently viewing (https://github.com/technomancy/swank-clojure/network) |
| 04:53 | Cozey | right, technomancys entry there is just for some old branch |
| 04:55 | raek | hrm, looks technomancy pushes the changes to both branches |
| 04:55 | raek | *forks |
| 04:55 | raek | the last commit of technomancy/swank-clojure is "Resolve print-doc at runtime to fix 1.3 compatibility." |
| 04:56 | raek | the same for jochu/swank-clojure |
| 04:58 | Cozey | thanks :-) |
| 04:58 | Cozey | do You know by the way how to find the commit where a chunk was deleted? |
| 04:59 | Cozey | git blame lets you find the added lines.. how about the removed? |
| 05:00 | raek | I was going to sugest blame, but now I see your point... :-) |
| 05:03 | Cozey | hm it is possible http://feeding.cloud.geek.nz/2010/07/querying-deleted-content-in-git.html |
| 05:04 | Cozey | with some git trickery |
| 05:08 | tsdh | Why 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:21 | tsdh | Is 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:22 | TobiasRaeder | morning |
| 05:28 | raek | the way clojure-mode for emacs seems to do it is to by default align the function arguments with the first one, like this: |
| 05:28 | raek | (foo 1 |
| 05:28 | raek | 2 |
| 05:28 | raek | 3) |
| 05:28 | raek | but a lot of special forms and macros use the "defun" style and indents two spaces |
| 05:29 | raek | (let [x 1] |
| 05:29 | raek | (a) |
| 05:29 | raek | (b) |
| 05:29 | raek | (c)) |
| 05:31 | raek | this seems to be escpecially common for special forms or macros what wrap a code body, like do, future, for and dosync |
| 05:33 | Cozey | anybody 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:38 | tsdh | raek: I mean the docstring if it more than one line long. |
| 05:40 | raek | oh. :) |
| 05:41 | raek | I have seen both 2 and 3 spaces for docstrings |
| 05:41 | tsdh | But never 0 spaces, like in CL? |
| 05:53 | tsdh | ninjudd: Hi. I use your ordered-set lib, and it's great! |
| 05:55 | tsdh | ninjudd: 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:03 | angerman | haha… finally. Rendering Geometry to PDF via LaTeX and TikZ :D |
| 06:04 | angerman | http://dl.dropbox.com/u/281539/tikz-template.pdf |
| 06:14 | __name__ | angerman: pretty |
| 06:15 | angerman | I need quite a bit of geometry drawings for my thesis. |
| 06:17 | angerman | usually 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:21 | clgv | angerman: dont you want to make a latex layer in clojure? that would be a great advance ;) |
| 06:21 | angerman | clgv: rewriting latex in clojure? |
| 06:21 | Cozey | what's the best strategy to make a future doing a certain task on certain time interval? |
| 06:22 | clgv | angerman: so to say. or better replace Latex via ClojureTex ;) |
| 06:22 | angerman | clgv: if I hadn't had a disk crash on a secondary disk, I would still have a markdown -> TeX compiler in Clojure. :/ |
| 06:23 | clgv | angerman: get a DVCS ;) |
| 06:23 | angerman | so 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:24 | clgv | I think it's past the time that the community should have thrown away latex for a better document description DSL |
| 06:24 | angerman | clgv: 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:24 | clgv | ah kk^^ |
| 06:25 | angerman | clgv: 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:25 | angerman | e.g. less \command |
| 06:26 | clgv | the "language" latex is one of its biggest problems. the useful things would have to be rewritten in a new DSL of course |
| 06:27 | clgv | and the "module organization" as well^^ |
| 06:28 | angerman | sure, 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:28 | clgv | oh ok didnt heard of that^^ |
| 06:28 | angerman | But 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:28 | clgv | you have to make the difference between LaTex and Tex |
| 06:29 | clgv | I only would replace LaTex. Tex might stay as kind of an "Assembler level" ;) |
| 06:30 | angerman | clgv: sure that might work out, though sidelining latex is not a perfect solution :/ |
| 06:30 | clgv | probably. since it would take long until you replaced most feature packages |
| 06:32 | angerman | to 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:33 | clgv | I would say most people get their work done with latex, but "being happy with it" is an entirely different dimension ;) |
| 06:33 | angerman | clgv: fair enough. But is there any competition? |
| 06:34 | clgv | I dont think so. I first thought LuaTex could be when I heard it first. But it seems they have other goals |
| 06:35 | angerman | clgv: I think luatex still needs a lot of time. |
| 06:36 | clgv | you understood their primary goals? maybe you can explain them to me ;) |
| 06:37 | angerman | clgv: 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:37 | clgv | ah ok. I just read the wikipedia entry again |
| 06:37 | clgv | on their own page it sounded a bit concusing some time ago |
| 06:37 | clgv | *confusing |
| 06:38 | angerman | thing 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:39 | angerman | I don't know what the size of lua devs is, from my experience they are hanging in WoW or so. |
| 06:40 | clgv | hmm well. maybe one could start a LaTex-Wrapper in Clojure. Libraries that encapsulate main building blocks. |
| 06:40 | clgv | would be less work than replacing LaTex ^^ |
| 06:41 | angerman | clgv: I guess what you would need is a half-assed latex-build-system, and a compiler that can compile augmented ClaTeX to LaTeX. |
| 06:42 | clgv | I did some programming in TikZ for an animation. that was kinda nasty ;) |
| 06:42 | angerman | TikZ is actually pretty awesome, though you need to get used to it's custom DSL. |
| 06:43 | angerman | but afaik it's the best tool for graphics and animations there is for latex. |
| 06:43 | clgv | yeah 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:43 | angerman | I've even created most of the artwork for an iPhone app with TikZ :D |
| 06:44 | angerman | clgv: right. apart from foreach there's little. |
| 06:46 | clgv | indeed. and if you look at the actual implementation of TikZ you'll get nightmares^^ |
| 06:47 | clgv | that's the pretty thing about clojure - you can learn a lot by looking at the core implementation |
| 06:47 | angerman | dunno, I just got respect for Till's mastery of TeX |
| 06:47 | clgv | I agree with that. It wasn't directed at Till but at Tex ;) |
| 06:48 | angerman | and if you remember that same Till is the author of LaTeX Beamer… you got to admire his contribution to LaTeX |
| 06:48 | angerman | clgv: yep. TeX… well… it's from another era |
| 06:48 | clgv | I know. Where did he get all the time for it? ;) |
| 06:48 | angerman | seems to be faculty member at the uni. of Lübeck, iirc. |
| 06:49 | clgv | yeah, but I suppose he has to do real research as well ;) |
| 06:50 | angerman | you never know :D |
| 06:50 | clgv | you thin they have him as "Professor for LaTex"? :P |
| 06:52 | Fossi | hmm. got some buddies who study cs there |
| 06:52 | Fossi | could ask :D |
| 06:54 | clgv | ah he is in theoretic computer science^^ |
| 06:55 | clgv | professor with approx 36. thats fast |
| 07:05 | clgv | oh I did use the wrong year. professor with 30 |
| 07:05 | angerman | lol. |
| 07:06 | angerman | clgv: so, well, he wrote beamer, tikz, a few paper, a doctorial thesis and his habilitation thesis. |
| 07:07 | angerman | not bad. |
| 07:07 | clgv | yeah. didnt have much sparetime I guess. |
| 09:15 | choffstein | Anyone 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:23 | TimMc | choffstein: I know of someone here who has, but they're not logged in. |
| 09:23 | choffstein | Hm, okay. Maybe I'll just idle then :) Thanks |
| 09:24 | tsdh | I 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:27 | TimMc | choffstein: Ask again when waxrose is in the channel. Might be a few hours, though. |
| 09:28 | choffstein | TimMc: Thanks a lot |
| 09:29 | tsdh | Is 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:29 | TimMc | I don't know if he'll be able to help, but I *think* he got something up and running. |
| 09:29 | TimMc | tsdh: Memoized fn? |
| 09:31 | tsdh | TimMc: Not quite. But I guess I can simply wrap a function around. |
| 09:31 | TimMc | Yeah, that's what I would do. |
| 09:32 | TimMc | (def get-graph (memoize (fn [] ...))) |
| 09:32 | TimMc | Only loads on first call. |
| 09:33 | tsdh | TimMc: Oh, yes. That's even better than that what I was thinking of. :-) |
| 09:34 | TimMc | Remember that the huge graph will then be in memory until get-graph can be garbage-collected, but this should be fine for testing. |
| 09:39 | tsdh | TimMc: If it would be collected, would a subsequent call load it again? |
| 09:39 | TimMc | Yeah, but it won't be collected while your program is running, since it's a global var. |
| 09:40 | tsdh | Perfect. |
| 09:48 | TimMc | tsdh: lein test org.timmc.pipeline.test.core |
| 09:48 | TimMc | That runs a specific test file. |
| 09:48 | TimMc | Haven't figured out how to run one deftest. |
| 09:50 | TimMc | There's something about "test selectors", add a reference to a robert.hooke namespace in the source code. |
| 09:50 | TimMc | *and |
| 09:50 | tsdh | Ah, I've though test selectors were just test names. |
| 09:54 | TimMc | tsdh: https://groups.google.com/group/leiningen/browse_thread/thread/e421df80db71b2ce |
| 10:14 | tsdh | TimMc: Thanks. |
| 10:15 | TimMc | Sounds like you might need a :dev-dependencies for robert.hooke, but I'm not sure. |
| 10:16 | fliebel | TimMc: Where are you using robert.hooke? |
| 10:22 | pyr | hi |
| 10:26 | TimMc | fliebel: I'm not, I just saw that lein seems to have a dependency on it for test selectors. |
| 10:27 | clgv | I 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:29 | amalloy | clgv: no |
| 10:30 | clgv | ah a look over the cheat sheet suggests subvec might work |
| 10:32 | raek | clgv: you need to do something like (into (subvec v 0 i) (subvec v (inc i) (count v))), which has linear time complexity |
| 10:33 | clgv | the "into" leads to the linear complexity I guess |
| 10:33 | clgv | since subvec has O(1) according to documentation |
| 10:34 | chouser | clgv: also note the resulting vector will consume no less memory, IIRC |
| 10:34 | clgv | chouser: that's not important |
| 10:34 | Fossi | do you really need a new vector? |
| 10:35 | Fossi | maybe you can just lazily filter or such |
| 10:35 | clgv | I do 2 sequential readings and one random read |
| 10:36 | clgv | s/2/2 complete/ |
| 10:36 | sexpbot | <clgv> I do 2 complete sequential readings and one random read |
| 10:39 | clgv | that deletion is taking about 26% of the time when I implement it with loop-recur and a transient vector |
| 10:40 | amalloy | clgv: 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:40 | amac | amalloy: hah, someone popped into the qbasic channel while I was afk |
| 10:40 | amalloy | *laugh* |
| 10:40 | amac | I told you its coming back! |
| 10:40 | amalloy | see? you're starting a grassroots thing |
| 10:41 | amac | its the future, clojure is passe. |
| 10:42 | clgv | amalloy: hmm could be an option if it doesnt cost to much checking it in the sequential reads all the time |
| 10:43 | amalloy | clgv: you can make the sequential reads cost nothing at all |
| 10:43 | clgv | amalloy: what do you mean? |
| 10:43 | amalloy | (concat (subvec v 0 n) (subvec v (inc n) (count v))) |
| 10:44 | amalloy | &(let [v (vec (range 10)) n 3] (concat (subvec v 0 n) (subvec v (inc n) (count v)))) |
| 10:44 | sexpbot | ⟹ (0 1 2 4 5 6 7 8 9) |
| 10:44 | clgv | the concat will cost me linear time. thats at least as bet as my loop-recur deletion I guess |
| 10:44 | amalloy | clgv: what. no it will cost you nothing. you're already spending linear time to walk over it, and concat is lazy |
| 10:45 | clgv | ah right |
| 10:45 | amalloy | and both subvecs are O(1) |
| 10:45 | clgv | but I cant do it nested |
| 10:45 | clgv | I'll delete increasingly. |
| 10:45 | amalloy | yes. the more requirements you pile on the more complicated the answer will get :P |
| 10:48 | amalloy | maybe you should just have a sorted-map with integer keys |
| 10:49 | clgv | no. that is no option. I am thinking about a way too eliminate the "random read" |
| 10:50 | clgv | there is also another data structure involved that currently has a one-to-one correspondence |
| 11:06 | tsdh | When 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:07 | raek | tsdh: first, {:keys a b c} --> {:keys [a b c]} |
| 11:07 | tsdh | raek: Ah, yes, just a typo. |
| 11:07 | raek | tsdh: but to answer you question: [x & {:as m}] |
| 11:08 | raek | or wait, if you will pass them as they are without inspeciting them: (defn f [& args] (apply g args)) |
| 11:10 | tsdh | raek: 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:11 | raek | (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:12 | tsdh | Or can I just say: (defn foo [x & keys] (other (magic x) keys)), and only other declares them? |
| 11:14 | raek | I think you need an 'apply' there |
| 11:14 | raek | unless 'other' takes an argument with the options on the form [:a 1 :b 2] |
| 11:15 | raek | (not a map= |
| 11:17 | tsdh | Oh, yes, I've meant (apply other (magic x) args) |
| 11:17 | tsdh | Where args = keys... |
| 11:25 | amalloy | tsdh: i'm inclined to just not use the &rest syntax, and just pass around an option map |
| 11:26 | amalloy | (defn foo [x opts] (other (magic x opts))) |
| 11:26 | amalloy | then if there are params you actually need you can pull them out, and if not don't worry about it |
| 11:27 | tsdh | amalloy: Hm, but opts is optional and would lead to many {} in calls. |
| 11:28 | amalloy | add a top-level function that sugars things up for the client before entering into your real functions |
| 11:29 | amalloy | eg if calls into your library typically start with (begin ...), you can (defn begin [arg & opts]) (begin* arg (apply hash-map opts))) |
| 11:30 | amalloy | alternatively, and i stress that this is usually the wrong answer, i have a macro that is the "opposite" of :keys |
| 11:31 | timvisher | hey all |
| 11:31 | tsdh | amalloy: But calls look like (p-apply v1 [p-seq [--> :cls 'Foo][<>-- :cls 'Bar]]) |
| 11:31 | amalloy | https://github.com/amalloy/amalloy-utils/blob/master/src/amalloy/utils.clj#L32 |
| 11:31 | timvisher | anyone have a minute to see if there's anything wrong with this clj repl shell script? https://gist.github.com/864408 |
| 11:32 | timvisher | I had to reinstall when I moved from port to brew and now clojure-contrib doesn't seem to be included in the classpath |
| 11:32 | timvisher | lein works but I'd still like inferior-lisp every now and then |
| 11:32 | amalloy | tim: lein repl or cake repl work outside of projects |
| 11:33 | amalloy | (out of the box with cake; minimal config with lein i believe) |
| 11:33 | timvisher | amalloy: do they include clojure-contrib by default? |
| 11:33 | amalloy | timvisher: my ~/.cake/project.clj includes clojure-contrib and my personal util library |
| 11:34 | timvisher | amalloy: aha. |
| 11:34 | amalloy | and that file gets used when starting an unaffiliated repl |
| 11:34 | timvisher | Didn't know that was possible. Do you know if lein has a similar facility? |
| 11:34 | amalloy | it does |
| 11:34 | amalloy | ask technomancy what it is :P |
| 11:34 | timvisher | interesting |
| 11:34 | timvisher | i can look it up. :) |
| 11:35 | amalloy | fwiw it also includes swank, so i can start a swank server without attaching to a project |
| 11:36 | timvisher | yeah. I just switched inferior-lisp-program to lein repl and it also starts up a swank server |
| 11:36 | tsdh | Argh, 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:39 | timvisher | amalloy: do you manually add clojure-contrib to your CLASSPATH so that cake can see it? |
| 11:39 | amalloy | no |
| 11:39 | amalloy | haven't touched CLASSPATH in five years :P |
| 11:40 | amalloy | i put it into ~/.cake/project.clj like i said |
| 11:40 | timvisher | so does cake have a set of directories that it searches by default or do you set that up somehow? |
| 11:40 | timvisher | what I mean is, lein's ~/.lein/init.clj |
| 11:40 | timvisher | which I think is the equivalent of what you're talking about |
| 11:40 | timvisher | is just arbitrary clojure code |
| 11:40 | amalloy | i don't think so |
| 11:41 | timvisher | ah |
| 11:41 | amalloy | i'm talking about a project.clj entry just like every lein project has |
| 11:41 | amalloy | cake has a global one as well |
| 11:41 | timvisher | oh ok |
| 11:41 | timvisher | so it's sort of a default project when you're outside of a real lein/cake project |
| 11:41 | amalloy | yes |
| 11:42 | amalloy | and also a parent project that all others "inherit" from |
| 11:42 | amalloy | i think |
| 11:42 | timvisher | gotcha |
| 11:45 | amalloy | timvisher: http://malloys.org/~akm/cake.tgz in all its glory |
| 11:45 | amalloy | my whole dang ~/.cake |
| 12:33 | timvisher | anyone around that could explain how to make clojure-contrib available in lein repl running outside of a project? |
| 12:37 | amalloy | alias lein="cake" :) |
| 12:37 | raek | timvisher: for me contrib is available then |
| 12:37 | raek | (with leiningen 1.4.2) |
| 12:38 | raek | I think cake has more customizable "global project" features |
| 12:39 | amalloy | no 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:40 | hiredman | amalloy: ah, but once he actually wants to do anything, he'll have to switch to lein anyway |
| 12:40 | amalloy | haha ouch |
| 12:41 | amalloy | score one for team lein |
| 12:41 | hiredman | cake is absurd |
| 12:42 | timvisher | amalloy: 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:43 | hiredman | timvisher: why are you using build tools to run repls outside of projects? |
| 12:43 | timvisher | raek: I only have 1.4.1. But that doesn't seem like it should make that much of a difference. |
| 12:44 | timvisher | because I can't get my clj command to work. https://gist.github.com/864408 |
| 12:44 | technomancy | timvisher: lein repl => (use 'clojure.contrib.logging) => nil |
| 12:44 | technomancy | WFM |
| 12:44 | hiredman | ~dirt simple |
| 12:44 | clojurebot | http://www.thelastcitadel.com/dirt-simple-clojure |
| 12:44 | timvisher | perhaps there's something wrong with my clojure-contrib install... |
| 12:45 | timvisher | oh my |
| 12:46 | timvisher | OK, 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:46 | timvisher | it appears that that assumption is wrong? |
| 12:47 | technomancy | yeah. in clojure 1.3 even some built-in stuff like clojure.set is not require'd by default |
| 12:47 | hiredman | given that no where else is it true, I would call it a bad assumption |
| 12:48 | timvisher | hiredman: 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:49 | timvisher | so, in other words, (not (or (= 'use 'import) (= 'require 'import))) |
| 12:49 | amalloy | timvisher: (= refer import) |
| 12:50 | __name__ | &(doc refer) |
| 12:50 | sexpbot | ⟹ "([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:50 | amalloy | (= use (comp refer require)) |
| 12:50 | hiredman | timvisher: it isn't true anywhere else |
| 12:50 | timvisher | amalloy: so why do I need to explicitly require when I don't need to explicitly import? |
| 12:51 | amalloy | timvisher: because classes are not the same as namespaces? |
| 12:51 | timvisher | ok |
| 12:52 | amalloy | timvisher: for entertainment value, try (require 'clojure.contrib.repl-utils) and time how long it takes |
| 12:52 | amalloy | then 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:53 | timvisher | yeah |
| 12:53 | timvisher | I get that. I think I've just discovered a few very large holes in my understanding of use, require, and namespaces. |
| 12:53 | amalloy | heh |
| 12:53 | timvisher | back to the drawing board with those topics, I guess |
| 12:54 | timvisher | thank's very much, everyone |
| 12:54 | amalloy | timvisher: require is a "lisp thing". probably best to draw a mental line between that and import |
| 12:54 | amalloy | (dividing them, not connecting them) |
| 12:54 | joelr | is there anything wrong with this sequence of code? (for [file files] (with-open [rdr (io/reader file)] (log/spy rdr))) |
| 12:55 | timvisher | joelr: what behavior are you seeing that you don't like? |
| 12:56 | timvisher | there doesn't appear to be anything syntatically wrong that I can see. |
| 12:57 | joelr | timvisher: for whatever reason, i print the # of files and it's fine, then that code does not print anything |
| 12:57 | timvisher | I think you're bumping up against it's laziness |
| 12:57 | timvisher | I'd use doseq instead |
| 12:58 | joelr | timvisher: i think you are right. let me look at doseq |
| 12:58 | timvisher | someone better than me can use the clojure bot to print the docs |
| 12:58 | joelr | timvisher: still, it's very strange behavior |
| 12:58 | timvisher | not really, unless I'm wrong. clojure tries to be as lazy as possible |
| 12:59 | timvisher | it is weird though if you're not used to it |
| 12:59 | joelr | timvisher: but shouldn't log "force" the results? |
| 12:59 | timvisher | not if that for expression is the only thing in your code. |
| 13:00 | timvisher | what 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:00 | timvisher | but not call any of them |
| 13:00 | timvisher | until something else comes along and consumes the sequence |
| 13:00 | timvisher | which is why something like doseq is usefuly |
| 13:00 | timvisher | the way I see it is as an eager for. |
| 13:01 | joelr | timvisher: thanks |
| 13:01 | joelr | timvisher: 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:01 | timvisher | but don't trust me too much, I'm still very new at this as well. :) |
| 13:02 | timvisher | exactly |
| 13:02 | timvisher | at least if my mental model is right. :) |
| 13:02 | timvisher | it's tough too if you're used to exploring in the repl |
| 13:02 | timvisher | because the repl will always force the results |
| 13:02 | amalloy | timvisher: good summary |
| 13:02 | amalloy | and it's pretty easy to get a bot to show you docs |
| 13:02 | amalloy | &(doc for) |
| 13:02 | timvisher | whereas as soon as you move it into an actual clojure project, you loose a lot of eager behavior |
| 13:02 | sexpbot | ⟹ "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:03 | timvisher | Ah. where are the docs for the bots on this channel? |
| 13:03 | amalloy | sexpbot even responds to inline requests with ##, like ##(doc doseq) |
| 13:03 | sexpbot | ⟹ "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:04 | amalloy | hah, docs for the bots. you wish. the closest you'll get for sexpbot is https://github.com/Raynes/sexpbot/wiki/Commands |
| 13:05 | amalloy | you'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:05 | timvisher | yeah |
| 13:05 | timvisher | so it is it just sexpbot and clojurebot on here? |
| 13:06 | timvisher | i'm more used to the emacs channel |
| 13:06 | amalloy | yeah they're the main bots. if there are others they're lurking |
| 13:06 | timvisher | good stuff |
| 13:06 | timvisher | well this has been educational |
| 13:06 | amalloy | haha |
| 13:07 | timvisher | and i contributed. hurray! |
| 13:07 | timvisher | :) |
| 13:07 | amalloy | (inc timvisher) |
| 13:07 | sexpbot | ⟹ 1 |
| 13:08 | clgv | $8ball |
| 13:08 | sexpbot | clgv: Outlook good. |
| 13:08 | clgv | $8ball |
| 13:08 | sexpbot | clgv: Ask again later. |
| 13:09 | amalloy | clgv: it's more interesting if you say |
| 13:09 | amalloy | $8ball will people get annoyed at clgv's sudden overuse of sexpbot? |
| 13:09 | sexpbot | amalloy: Outlook good. |
| 13:09 | clgv | :P |
| 13:09 | amalloy | $timer 0:20:0 |
| 13:09 | clgv | $dec amalloy |
| 13:09 | sexpbot | ⟹ 4 |
| 13:10 | clgv | $karma amalloy |
| 13:10 | clgv | $dec amalloy |
| 13:10 | sexpbot | ⟹ 3 |
| 13:10 | clgv | lol hihi ;) |
| 13:10 | clgv | time to finish work and go home |
| 13:10 | clgv | cya all |
| 13:11 | amalloy | that's weird. $karma amalloy should have worked as far as i can tell from reading the source (it's not my plugin) |
| 13:14 | buttered-toast | (inc amalloy) |
| 13:14 | sexpbot | ⟹ 4 |
| 13:14 | buttered-toast | (inc amalloy) |
| 13:14 | sexpbot | ⟹ 5 |
| 13:14 | amalloy | :P |
| 13:16 | amalloy | (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:29 | sexpbot | amalloy: ping |
| 14:24 | pyr | hi, I want my log4j.properties file to end up in the uberjar created by leiningen |
| 14:24 | pyr | how would I go about doing that ? |
| 14:26 | technomancy | pyr: slap it in the resources/ directory |
| 14:26 | pyr | thanks, lein new didn't create this one :) |
| 14:32 | tsdh | What does it mean if leiningen cannot fetch org.apache.maven:super-pom:jar:2.0? |
| 14:32 | amalloy | tsdh: generally it means you're misunderstanding maven's error message (i always do too) |
| 14:32 | amalloy | scroll way the hell up to see which library it *actually* had trouble with |
| 14:35 | tsdh | amalloy: I get a backtrace... http://pastebin.com/3VJdQen4 |
| 14:35 | amalloy | don't depend on 1.2.0-snapshot |
| 14:35 | amalloy | just 1.2.0 |
| 14:36 | amalloy | (and figure out which library you depend on itself depends on the snapshot, if it's not you. usually it's labrepl) |
| 14:36 | tsdh | amalloy: Not my lib. But changing to 1.2.0 worked. |
| 14:37 | rick__ | 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:37 | tsdh | amalloy: I wouldn't have come to the conclusion that this is the cause for years. :-) |
| 14:38 | technomancy | rick__: is the readme insufficient? |
| 14:38 | amalloy | tsdh: projects *should* have future-proof dependencies like "[1.2.0-SNAPSHOT,1.2.0]", but they usually don't |
| 14:39 | amalloy | technomancy: isn't your repo the canonical source now, not jochu? |
| 14:39 | tsdh | amalloy: Blame ninjudd. ;-) |
| 14:39 | amalloy | i always do :) |
| 14:39 | tsdh | Haha |
| 14:40 | technomancy | amalloy: yeah, but they have the same readme |
| 14:40 | rick__ | technomancy: tbh I haven't read it.. :x |
| 14:45 | tsdh | How do I tell leiningen to compile some project into a jar? |
| 14:46 | brehaut | lein jar ? |
| 14:46 | tsdh | lein compile doesn't seem to do anything, lein jar packs only the sources. |
| 14:46 | technomancy | tsdh: depends; why do you want .class files in the jar |
| 14:46 | technomancy | ? |
| 14:46 | Fossi | :D |
| 14:47 | Fossi | such a great question XD |
| 14:47 | tsdh | So that I can put it in the CLASSPATH of another project. |
| 14:47 | Fossi | "why in hell would you want any .class files in your jar? are you insane?" |
| 14:47 | tsdh | technomancy: The project I want to jar contains a clj part and a jvm java part. |
| 14:47 | dnolen | man this makes me want a Clojure->JS even more, http://www-sop.inria.fr/indes/scheme2js/ |
| 14:48 | technomancy | tsdh: 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:49 | technomancy | or is it java source you need to run javac over? for that you set :java-source-path. |
| 14:49 | tsdh | technomancy: Yes, java and clojure source. |
| 14:51 | pjstadig | dnolen: another project of inria...make me want to move to france |
| 14:51 | ossareh | dnolen: 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:52 | ossareh | javascript has a BNF, I assume clojure does too? |
| 14:52 | dnolen | pjstadig: heh. |
| 14:53 | dnolen | ossareh: that's what Scheme2Js does. |
| 14:53 | dnolen | they even published a couple papers on how they implemented tail call optimization. |
| 14:54 | edw | Is there a statistician in the house? Or, does anyone know if there's a stats freenode channel? |
| 14:54 | gregh | http://stats.stackexchange.com/ :) |
| 14:55 | edw | Ah. Thanks. |
| 14:55 | TimMc | ossareh: Braces, symbols, and some reader macros. What more do you need? |
| 14:55 | brehaut | TimMc: special forms |
| 14:56 | TimMc | brehaut: For parsing? |
| 14:57 | brehaut | not for parsing |
| 14:57 | brehaut | but parsing an sexp doesnt really provide the same information as say the BNF for javascript |
| 14:57 | TimMc | Ah, OK. |
| 14:57 | brehaut | once you have parsed some javascript you know what the blocks anf functions and whatever are |
| 14:58 | TimMc | do-expr, let-expr, etc. |
| 14:58 | TimMc | fn-call |
| 14:58 | brehaut | TimMc: http://clojure.org/special_forms that stuff |
| 14:59 | TimMc | ossareh: As far as I know, Clojure does not yet have a formal spec. |
| 15:00 | chouser | do primitive args work on forward-declared fns? |
| 15:01 | hiredman | seems like they should |
| 15:01 | hiredman | decalare is just about the name |
| 15:01 | hiredman | the var |
| 15:01 | hiredman | the primitive part is from the fn object |
| 15:02 | hiredman | unless the primitive stuff uses extra metadata |
| 15:02 | hiredman | the new fnloader stuff may mean that primitive fns aren't run as primitive the first time |
| 15:03 | tsdh | lein 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:04 | chouser | (declare a) (defn b [] (a 1)) (defn a [^long i] ...) |
| 15:05 | chouser | It seems like b might compile the call to a with autoboxing. How could it not, actually? |
| 15:06 | dnolen | chouser: I recall rhickey saying, re-defing forces callers to recompile their bodies I thought upon call. |
| 15:07 | chouser | recompiling a function when it's *called*? Sorry if I remain suspicious... |
| 15:07 | dnolen | that's how redefing is supported in post-dynamic-by-default world. |
| 15:07 | hiredman | I dunno about recompiling |
| 15:07 | hiredman | possible some kind of thunk thing like with keyword callsites |
| 15:07 | dnolen | that's what I remember, could be wrong o course. |
| 15:08 | TimMc | Could this be detremined using a macro with side effects? |
| 15:08 | chouser | probably not |
| 15:09 | raek | tsdh: looks like you are trying to 'require' or 'use' a java class |
| 15:10 | hiredman | he could have meant that you need to recompile callers |
| 15:10 | hiredman | not that the compiler does it for you |
| 15:10 | tsdh | raek: 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:11 | amalloy | tsdh: his point is that you don't use/require java classes, you import them |
| 15:11 | hiredman | wow, invokePrim is cute |
| 15:12 | tsdh | amalloy: That's true. |
| 15:12 | raek | the 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:13 | tsdh | Ok, 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:13 | dnolen | hiredman: you don't need need to recompile callers. that was the problem with ^:static. |
| 15:14 | dnolen | new world avoids that mess. |
| 15:14 | hiredman | dnolen: for vars |
| 15:14 | hiredman | but is that really the case for primitive fns? |
| 15:15 | dnolen | hiredman: all i know is, I can now declare primitive fns whenever I want and I don't have to recompile callers. |
| 15:16 | TimMc | jkkramer: I'm failing to understand the proper syntax for edges in the digraph constructor. |
| 15:16 | raek | tsdh: looks like src/ordered_set.clj is missing |
| 15:17 | tsdh | raek: it's in src/clj/ |
| 15:20 | dnolen | hiredman: chouser: http://clojure-log.n01se.net/date/2010-10-18.html#18:35a |
| 15:20 | raek | and src/clj/ is on the classpath rather than src/ ? |
| 15:20 | TimMc | jkkramer: Cancel that, there was an impedance mismatch. :-) |
| 15:21 | hiredman | dnolen: right, but doesn't mention compiling |
| 15:22 | tsdh | raek: I have to admit, that I have no clue, I don't even know what AOT stands for... |
| 15:23 | TimMc | map != mapcat |
| 15:23 | TimMc | tsdh: Ahead Of Time |
| 15:24 | raek | tsdh: (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:26 | hiredman | dnolen: 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:26 | raek | (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:26 | dnolen | hiredman: so it is a recompile? |
| 15:26 | hiredman | possibly AFn's invokePrim has magic to avoid the need to recompile |
| 15:28 | raek | tsdh: also, AOT compilation = ahead of time compilation. |
| 15:29 | tsdh | raek: Hm, even with both :java-source-path and :source-path it doesn't work. http://pastebin.com/QrJn1JC3 |
| 15:31 | raek | tsdh: 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:32 | tsdh | raek: Yeah! That does work. Great! |
| 15:32 | dnolen | chouser: 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:32 | raek | tsdh: a project that has both clojure and java source https://github.com/raek/map-exception |
| 15:33 | hiredman | dnolen: must be something like the call site cache for keywords on records |
| 15:33 | tsdh | Argh, too easy. technomancy has dazzled me with this AOT thingy. :-) |
| 15:33 | hiredman | dnolen: that is a different thing though |
| 15:33 | hiredman | non-dynamic vars and primitive functions are two entirely different features moving towards the same goal of performance |
| 15:34 | raek | tsdh: if you have :gen-class in any namespace, then that namespace needs to be aot compiled |
| 15:34 | tsdh | raek: I don't. |
| 15:35 | hiredman | dnolen: rich is contrasting non-dynamic vars to the "static" call site linking you got with :static |
| 15:41 | dnolen | hiredman: ah, gotcha. |
| 15:43 | hiredman | so now there are var callsite caches, protocol caches, and keyword caches, I suppose there could be primitive caches too |
| 15:45 | angerman | how do i check if a var is already bound? |
| 15:46 | angerman | ahh, i need the #' syntax |
| 15:51 | hiredman | ,#'foo |
| 15:51 | clojurebot | java.lang.Exception: Unable to resolve var: foo in this context |
| 15:59 | angerman | hiredman: I choked on (bound? foo) :D |
| 16:08 | angerman | Subdividing a cube under planarity constrains with clojure and jReality: http://dl.dropbox.com/u/281539/jReality-planar-subd.mov |
| 16:08 | angerman | if only the second iteration wouldn't break :/ |
| 16:09 | jweiss | I 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:12 | jweiss | I 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:13 | angerman | hmm… what do the *-vars say? |
| 16:13 | jweiss | *-vars? |
| 16:14 | angerman | sorry. just had a look at the documentation; there's nothing to hold onto as far as i can see :/ |
| 16:15 | jweiss | yeah, i sorta expected not |
| 16:15 | jweiss | how do people use the various logging utilities then? |
| 16:15 | jweiss | seems like no matter what, you end up with wrong class/method locations. |
| 16:15 | angerman | you could though wrap defn, and inject a (binding [*current-fn* …] … ) |
| 16:16 | angerman | and the (meta …) of that fn tells you line and a bunch more. |
| 16:16 | amalloy | jweiss: 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:17 | angerman | ahh well. good night... |
| 16:17 | raek | are these two proxies the same? https://gist.github.com/864942 |
| 16:18 | raek | (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:21 | jweiss | amalloy: java.util.logging does not use line numbers. |
| 16:21 | jweiss | just class/method. |
| 16:23 | ev4l | good morning everyone. can anyone explain to me why this happens? |
| 16:24 | ev4l | (if (> 2 4) (println "bigger") (println "smaller")) |
| 16:24 | ev4l | > bigger |
| 16:24 | ev4l | > nil |
| 16:24 | hsbot | mueval-core: L.hs: removeLink: does not exist (No such file or directory) |
| 16:24 | hsbot | Not in scope: `nil' |
| 16:24 | ev4l | (if (> 2 4) (println "bigger") ((println "smaller") (println "number"))) |
| 16:24 | ev4l | > smaller |
| 16:24 | ev4l | > number |
| 16:24 | hsbot | Not in scope: `smaller' |
| 16:24 | ev4l | java.jang.NullPointerException (NO_SOURCE_FILE:0) |
| 16:24 | hsbot | Not in scope: `number' |
| 16:24 | ev4l | why am i getting a NullPointerException when i have a multi-statement else form? |
| 16:25 | edw | What is this mult-statement else form you refer to? |
| 16:25 | ev4l | the second one |
| 16:25 | edw | Yeah, that's not legal. |
| 16:25 | jweiss | ,(if (> 2 4) :bigger :smaller) |
| 16:25 | clojurebot | :smaller |
| 16:25 | edw | ((println...) (println ...)) fails because println returns nil. Nil is not a function. |
| 16:26 | amalloy | edw: it's not "Not legal", it's just not what he means |
| 16:26 | ev4l | there are no ways to run two statements or more at the else form? |
| 16:26 | edw | Right, good point. |
| 16:26 | edw | (do (println 'foo) (println 'bar)) |
| 16:27 | ev4l | hmm, nice, lemme check |
| 16:27 | amalloy | this 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:28 | ev4l | amalloy: you're joking ... lol |
| 16:28 | amalloy | &(if (< 1 0) (do (print true) (print 1)) (do (print false) (print 0))) |
| 16:28 | sexpbot | ⟹ false0nil |
| 16:28 | edw | amalloy: I remember back in the day having to unlearn my tendency from C to "when in doubt, throw more parens in." |
| 16:29 | ev4l | edw: amalloy my logic is that every statement should be enclosed in a () form :D |
| 16:29 | amalloy | ev4l: start by taking the word "statement" out of your vocab |
| 16:30 | jweiss | there are no statements in lisp (or at least, no diff between expression and statement) |
| 16:30 | ev4l | jweiss: nice. got your point |
| 16:31 | amalloy | ev4l: ##(= 10 (if (< 9 5) 0 10)) |
| 16:31 | sexpbot | ⟹ true |
| 16:32 | amalloy | because everything is an expression, you can put if-expressions anywhere you would put, say, an addition-expression |
| 16:34 | ev4l | amalloy: lol... still addicted to the fact of if being a special syntactic element |
| 16:34 | ev4l | (in most languages) |
| 16:35 | __name__ | I don't see how that is such a change. |
| 16:35 | TimMc | ev4l: Just pretend it's the ternary operator. :-) |
| 16:36 | amalloy | TimMc: indeed |
| 16:36 | amalloy | now do the same for (for) :) |
| 16:36 | tsdh | When 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:36 | TimMc | Though... I wonder if the ternary operator evaluates all its arguments ahead of time, in various languages. |
| 16:36 | amalloy | TimMc: i can't think of any languages where it does |
| 16:36 | amalloy | not even php is that dumb |
| 16:37 | ev4l | amalloy: jweiss TimMc : thankx a bunch :D |
| 16:37 | TimMc | for is a list comprehension, like in Python |
| 16:37 | TimMc | (I can't do any better than that.) |
| 16:39 | amalloy | TimMc: feh. python. that one wouldn't work for me |
| 16:39 | TimMc | :-P |
| 16:41 | TimMc | I'm so close to having this logic pipeline utility working! |
| 16:41 | TimMc | I just need to figure out why it's being picky about which logic blocks get executed. >_> |
| 16:42 | TimMc | Then I'll need to figure out this whole packaging and clojars and Maven thing. |
| 16:42 | amalloy | TimMc: it is omg so easy |
| 16:43 | amalloy | esp assuming you already have an ssh keypair |
| 16:43 | TimMc | That I do. |
| 16:43 | currentB | can anyone recommend a good course of action for learning to do TDD in clojure, having never done really any testing before? |
| 16:43 | amalloy | (1) get a clojars account (2) associate keypair with it (3) cake release |
| 16:44 | raek | tsdh: there happens to be an example of that here: http://clojuredocs.org/clojure_core/clojure.walk/postwalk |
| 16:44 | jweiss | I can't seem to figure out how to split the string "asdfsd$tyutyu" at the "$" character. (split blah #"\\$") doesn't work |
| 16:45 | tsdh | raek: Oh, great. So that's how to use atoms... :-) |
| 16:45 | amalloy | &(split-with #{\$} "asdfsd$tyutyu") |
| 16:45 | sexpbot | ⟹ [() (\a \s \d \f \s \d \$ \t \y \u \t \y \u)] |
| 16:45 | amalloy | &(split-with (complement #{\$}) "asdfsd$tyutyu") |
| 16:45 | sexpbot | ⟹ [(\a \s \d \f \s \d) (\$ \t \y \u \t \y \u)] |
| 16:45 | amalloy | jweiss: warning: that is like the worst solution there is |
| 16:46 | jweiss | i think my problem is being unable to specify a literal $ to the java regex machine |
| 16:46 | TimMc | jweiss: Backslash it? |
| 16:46 | jweiss | maybe emacs is screweing me. it will only let me add double backslash |
| 16:46 | raek | jweiss: (ns foo.bar (:require [clojure.string :as str])) (str/split "asdfsd$tyutyu" #"\$") |
| 16:46 | jweiss | ah there we go |
| 16:46 | raek | => ["asdfsd" "tyutyu"] |
| 16:46 | TimMc | jweiss: which is then read as a single backslash. |
| 16:47 | jweiss | no, in emacs i really had to type a single backslash |
| 16:47 | jweiss | nd then it says "Escaping Character..." in the minibuffer |
| 16:47 | jweiss | that kinda threw me |
| 16:48 | TimMc | ,(count "\\$") |
| 16:48 | clojurebot | 2 |
| 16:48 | TimMc | Oh wait, I misread you, sorry. |
| 16:58 | powrtoc | has anyone here used clojure.contrib.dataflow? |
| 17:00 | powrtoc | It 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:02 | raek | a common symptom of macroitis... |
| 17:02 | powrtoc | raek, quite |
| 17:03 | powrtoc | it's a PITA... was wondering if I could wrap it in a macro to generate the symbol I need |
| 17:03 | fliebel | You see, macros are contagious. |
| 17:03 | powrtoc | yeah :-\ |
| 17:03 | raek | cgrand was right! |
| 17:03 | fliebel | he still is, I hope... |
| 17:05 | powrtoc | but I don't think wrapping it works... as macros are compile time, and that's when the symbol name needs to be specified |
| 17:07 | raek | powrtoc: 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:09 | powrtoc | raek, 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:10 | raek | that can be circumvented... >:) |
| 17:10 | raek | well, relying on private fns are not very good to do of course... |
| 17:10 | powrtoc | raek, how do you circumvent it? |
| 17:11 | powrtoc | (other than copying the fn into my namespace) |
| 17:11 | raek | ,(require 'clojure.contrib.dataflow) |
| 17:11 | clojurebot | java.io.FileNotFoundException: Could not locate clojure/contrib/dataflow__init.class or clojure/contrib/dataflow.clj on classpath: |
| 17:11 | amalloy | powrtoc: (#'somens/somefn args) |
| 17:13 | powrtoc | amalloy, cute |
| 17:15 | powrtoc | hmmm... has anyone here tried dgraph? https://github.com/gcv/dgraph |
| 17:16 | raek | what 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:17 | amalloy | raek: http://download.oracle.com/javase/1.5.0/docs/api/java/awt/Window.html#addWindowListener%28java.awt.event.WindowListener%29 |
| 17:19 | amalloy | raek: proxy WindowAdapter and put your logic on windowClosed |
| 17:23 | TimMc | $findfn #(= % 9) [6 4 5 9 7] 3 |
| 17:23 | sexpbot | [] |
| 17:23 | TimMc | $findfn #(= % 9) [6 4 5 9 7] 9 |
| 17:23 | sexpbot | [] |
| 17:23 | fliebel | powrtoc: Woa, looks nice :) |
| 17:23 | amalloy | TimMc: you're looking for indexof? |
| 17:24 | TimMc | Perhaps. |
| 17:24 | amalloy | &(.indexOf [6 4 5 9 7] 4) |
| 17:24 | sexpbot | ⟹ 1 |
| 17:24 | raek | amalloy: I did an experiment with a proxy and some printlns. "closing" seems to be called, but "closed" is not |
| 17:24 | amalloy | raek: k. it's been a long time since i knew details about the difference |
| 17:25 | TimMc | amalloy: No, I want to use a predicate |
| 17:26 | amalloy | TimMc: keep-indexed? |
| 17:26 | raek | setDefaultCloseOperation accepts both HIDE_ON_CLOSE and DISPOSE_ON_CLOSE. *investigates* |
| 17:26 | amalloy | raek: hide leaves the object alive |
| 17:26 | amalloy | so that you can (.show) it later |
| 17:26 | amalloy | dispose destroys it |
| 17:28 | raek | but how do I detect that it gets hidden? windowClosed is not called when I close the window. |
| 17:29 | TimMc | amalloy: Hmm, perhaps. |
| 17:30 | raek | ah. http://stackoverflow.com/questions/622814/window-events-for-jframes-that-are-hidden-shown-via-setvisible |
| 17:32 | TimMc | amalloy: Yay! |
| 17:33 | amalloy | TimMc: i think i wrote this code like yesterday for someone else |
| 17:33 | amalloy | in the #clojure logs |
| 17:33 | amalloy | (after stealing the idea from hiredman) |
| 17:34 | TimMc | amalloy: I implemented the Collatz calculation as a series of logic blocks and registers, and it works! |
| 17:34 | amalloy | nice |
| 17:35 | TimMc | https://github.com/timmc/pipeline/blob/master/test/org/timmc/pipeline/test/core.clj#L87 |
| 17:35 | TimMc | It's a very contrived test-case. |
| 17:39 | amalloy | can you think of any use of collatz that is not contrived and/or useless? |
| 17:39 | TimMc | heh |
| 17:40 | TimMc | So... it's doubly contrived! |
| 17:42 | raek | now this is starting to become something! http://raek.se/gophure.png |
| 17:47 | amalloy | raek: not sure why, nor whether you care, but that font/layout makes me think of EULAs for some reason |
| 17:49 | raek | since that directory contains the text "PLEASE READ" and "LEGAL INFORMATION", I'm not surprised by your reaction... ;-) |
| 17:54 | TimMc | I 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:54 | TimMc | "Pipeline" is the current name, but that's what I'll be using it *for*, not what it is. |
| 17:55 | TimMc | I'm kind of tempted to give up and name it after some animal or pastry. -.- |
| 17:55 | brehaut | what about 'wijure' :P |
| 17:56 | amalloy | clojd-circuit :P |
| 17:57 | TimMc | Those are both brilliant suggestions that I would totally take if I were a bad person. |
| 17:57 | amalloy | OMG. 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:58 | TimMc | You're not visually impaired, I can see you just fine! |
| 17:58 | amalloy | TimMc: i'm typing extra small for you |
| 18:07 | edoloughlin | Easiest 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:07 | TimMc | The 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:08 | TimMc | ,(into {} ["key" "val"]) |
| 18:08 | clojurebot | java.lang.ClassCastException: java.lang.Character cannot be cast to java.util.Map$Entry |
| 18:08 | raek | edoloughlin: ##(conj {} ["key" "val"]) |
| 18:08 | sexpbot | ⟹ {"key" "val"} |
| 18:08 | TimMc | ,(into {} [["key" "val"]]) |
| 18:08 | clojurebot | {"key" "val"} |
| 18:08 | TimMc | ,(apply assoc {} ["key" "val"]) |
| 18:08 | clojurebot | {"key" "val"} |
| 18:09 | brehaut | ,(apply hash-map [:key :val]) |
| 18:09 | clojurebot | {:key :val} |
| 18:09 | edoloughlin | TimMc: thanks. Still don't have API muscle memory... |
| 18:09 | raek | TimMc: maybe "signal"? |
| 18:10 | TimMc | I'mma grab me a thesaurus. |
| 18:13 | TimMc | Oh, huh... "circuit" is related to "circular". |
| 18:20 | TimMc | short-circuit? feedback? |
| 18:24 | edoloughlin | raek: apologies, didn't notice your conj solution earlier |
| 18:24 | brehaut | TimMc: johnny-5 |
| 18:25 | TimMc | brehaut: Error: Could not dereference symbol "johnny-5" |
| 18:25 | brehaut | TimMc: not a child of the 80s then |
| 18:25 | TimMc | Nope, born in 1984. |
| 18:25 | brehaut | johnny 5 is the robot from the movie Short Circuit |
| 18:25 | TimMc | Oh, ha! |
| 18:25 | brehaut | he was also programmed in lisp |
| 18:26 | companion_cube | do you have a Big Brother, TimMc ? |
| 18:26 | brehaut | (seriously, you can see big green blurry lisp in the movie) |
| 18:26 | TimMc | companion_cube: No, only child. |
| 18:32 | amalloy | TimMc: i like feedback |
| 18:33 | amalloy | also: tired of old fogies like TimMc - 1985 all the way |
| 18:33 | TimMc | johnny-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:33 | amalloy | brehaut: that's neat. i haven't watched the movie since picking up lisp |
| 18:35 | TimMc | So, would I name the project org.timmc/feedback ? (I own timmc.org) |
| 18:36 | amalloy | TimMc: 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:36 | TimMc | heh |
| 18:36 | amalloy | the 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:37 | amalloy | __name__: and i'm here (to lisp) |
| 18:37 | TimMc | __name__: I really want tim.mc, but I think I'd have to start a business in Monaco. |
| 18:37 | TimMc | It's *available* though. |
| 18:38 | TimMc | and then my reverse domain would be mc.tim |
| 18:38 | brehaut | ive not bothered with the RDN packages for my own stuff |
| 18:38 | __name__ | \o/ |
| 18:38 | amalloy | TimMc: take it anyway |
| 18:38 | TimMc | haha |
| 18:38 | amalloy | my utility project is in namespace amalloy.utils |
| 18:39 | TimMc | mc.tim/feedback? |
| 18:39 | brehaut | it wouldnt be slash, because thats the contents of a namespace |
| 18:39 | brehaut | raher than a namespace itself |
| 18:39 | TimMc | Oh right. |
| 18:40 | TimMc | I was mixing up the Maven stuff with namespaces. |
| 18:40 | TimMc | arg |
| 18:40 | raek | works as a grop/artifact id for maven repos though |
| 18:40 | raek | *group |
| 18:40 | TimMc | I really shouldn't take mc.tim as a group if I don't have the domain, since it would be a valid domain. |
| 18:41 | brehaut | amalloy: 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:41 | TimMc | org.timmc/feedback <-- would it make sense to just have ./src/feedback.clj, or should I use feedback.core instead? |
| 18:44 | raek | why not org/timmc/feedback.clj? |
| 18:45 | TimMc | Does the artifact ID have anything to do with the namespaces? |
| 18:46 | raek | iirc, the .core suffix was added in leiningen to default to a non-empty package (since Java chokes on that somethimes) |
| 18:46 | raek | namespaces and group+artifact id does not have to have anything in common |
| 18:47 | raek | (technically) |
| 18:48 | TimMc | Then org/timmc/feedback.clj with identifier org.timmc/feedback ? Sounds reasonable. |
| 18:48 | raek | the 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:48 | brehaut | TimMc: yes |
| 18:48 | raek | TimMc: that would be how I would do it... :) (note that there are other convetions as well) |
| 18:49 | raek | for 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:49 | brehaut | TimMc: 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:51 | TimMc | And last thing... versioning. Should I just leave it as 0.1.0-SNAPSHOT for now? |
| 18:51 | brehaut | if its just a snapshot yes. if its actually your 0.1.0 release: no |
| 18:52 | TimMc | sure |
| 18:52 | TimMc | For releases, I remove snapshot, bump the version appropriately, tag, and release? |
| 18:53 | brehaut | yeah pretty much |
| 18:53 | TimMc | OK, sweet. |
| 18:53 | raek | ...and obey the rules of http://semver.org/ :) |
| 18:53 | TimMc | raek: indeed |
| 18:55 | brehaut | TimMc: 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:56 | TimMc | Yeah, I was surprised that lein uses 1.0.0-SNAPSHOT as the default. |
| 19:06 | amalloy | i changed ~/.cake/project.clj to use 0.0.1 (not snapshot) |
| 19:08 | TimMc | What is the point of snapshot, anyway? |
| 19:09 | powrtoc | do futures execute on their own thread or the agent thread pool? |
| 19:09 | amalloy | TimMc: git HEAD without git access |
| 19:09 | amalloy | basically |
| 19:09 | TimMc | (going AFK for dinner) |
| 19:09 | powrtoc | I can never remember |
| 19:09 | amalloy | powrtoc: new thread |
| 19:12 | hiredman | no, it is the same threadpool that send-oof uses |
| 19:12 | hiredman | send-off |
| 19:13 | amalloy | $source send-off |
| 19:13 | sexpbot | send-off is http://is.gd/h4vV3P |
| 19:14 | rata_ | is there anything special about a ring app that could make my (def foo (atom {})) clear unexpectedly? |
| 19:16 | amalloy | hiredman: neat. so it reuses threads, but there's no limit to how many of them can exist at once, right? |
| 19:16 | rata_ | amalloy: yes |
| 19:17 | rata_ | isn't a atom or ref supposed to be the normal way to store state in a webapp? |
| 19:18 | hiredman | depends, generally you'll want to stick state in some kind of external datastore |
| 19:19 | amalloy | rata_: are you using reload middleware? that might reload the namespace |
| 19:19 | brehaut | rata_: what server/adapter are you using for your ring app? |
| 19:19 | rata_ | amalloy: yes, I'm using the reload middleware... I'll try with defonce |
| 19:20 | rata_ | brehaut: I don't really understand your question |
| 19:20 | brehaut | rata_: are you using jetty with the ring.adapter.jetty adapter ? |
| 19:20 | rata_ | (I'm new to ring and web development) |
| 19:20 | rata_ | brehaut: yes |
| 19:21 | brehaut | rata_: then amalloy's guess is the best. |
| 19:21 | brehaut | the jetty adapter does nothing fancy with your application |
| 19:21 | rata_ | ok |
| 19:23 | rata_ | oh thank you guys =) it doesn't get clear now |
| 19:25 | amalloy | omg i helped with a ring app. i can't even write a ring app |
| 19:25 | brehaut | ahaha |
| 19:25 | brehaut | thats the secret of ring: its nothing special |
| 19:29 | weilawei | If 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:29 | weilawei | (note, im not a java programmer and new to clojure) |
| 19:30 | hiredman | the $ is part of the class name |
| 19:31 | hiredman | package is org.zeromq and the class is ZMQ$Context |
| 19:31 | hiredman | $ means something in java but you don't really have to care about it |
| 19:37 | weilawei | thanks hiredman :) |
| 19:37 | weilawei | is there any way i can import it as Context? or use it like that? |
| 19:38 | weilawei | technomancy: but i like zeromq and I use it from C already >_< |
| 19:38 | technomancy | well 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:40 | hiredman | weilawei: 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:40 | danlarkin | I have found this is the best way to bring it into a leiningen project, https://github.com/Storkle/jzmq-native-deps |
| 19:47 | powrtoc | if 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:47 | powrtoc | obviously loop/recur work .. but is there a nice oneliner? |
| 19:48 | powrtoc | I want to bottom out on the nil |
| 19:48 | hiredman | ,(doc tree-seq) |
| 19:48 | clojurebot | "([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:34 | waxrose | Morning all. |