2010-12-22
| 00:00 | amalloy | brehaut: nah, i should just do it right the first time instead of flattening the wrong version :P |
| 00:00 | brehaut | amalloy: haha sure :P |
| 00:00 | amalloy | &(into [] (for [[k v] {3 1, 2 2, 0 3}] (repeat v k))) |
| 00:00 | sexpbot | ⟹ [(3) (2 2) (0 0 0)] |
| 00:00 | amalloy | haha nope, not that either |
| 00:00 | dnolen | &(reduce concat (for [[k v] {3 1, 2 2, 0 3}] (repeat v k)))) |
| 00:00 | sexpbot | ⟹ (3 2 2 0 0 0) |
| 00:00 | amalloy | &(mapcat (fn [[k v]] (repeat v k)) {3 1, 2 2, 0 3}) |
| 00:00 | sexpbot | ⟹ (3 2 2 0 0 0) |
| 00:01 | brehaut | amalloy: nice |
| 00:03 | amalloy | mapcat solves a lot of problems if you remember it's there |
| 00:03 | amalloy | dougbradbury: ^^ |
| 00:04 | dougbradbury | amalloy:, dnolen:, brehaut: et al thanks! |
| 00:04 | dougbradbury | I'll look at mapcat |
| 00:04 | brehaut | amalloy: it does. i knew it was possible with seq-m but couldnt remember the sane name :P |
| 00:04 | dougbradbury | haven't used it yet |
| 00:05 | dnolen | &(mapcat (juxt inc dec) [1 2 3]) |
| 00:05 | sexpbot | ⟹ (2 0 3 1 4 2) |
| 00:05 | brehaut | &((juxt inc dec) 1) |
| 00:05 | sexpbot | ⟹ [2 0] |
| 00:05 | brehaut | i love juxt |
| 00:07 | amalloy | brehaut: juxt is great. fnil is another HOF that's surprisingly useful |
| 00:07 | dnolen | &((juxt true? false?) true) |
| 00:07 | sexpbot | ⟹ [true false] |
| 00:07 | amalloy | &((juxt :a :b :c) {:a 1 :b 4 :c 9}) |
| 00:07 | sexpbot | ⟹ [1 4 9] |
| 00:08 | brehaut | amalloy: im quite confused about what fnil does |
| 00:11 | amalloy | &(let [m {:a 1}] (update-in m [:a] (fnil inc 0))) |
| 00:11 | sexpbot | ⟹ {:a 2} |
| 00:11 | amalloy | &(let [m {:a 1}] (update-in m [:b] (fnil inc 0))) |
| 00:11 | sexpbot | ⟹ {:b 1, :a 1} |
| 00:12 | brehaut | amalloy: awesome |
| 00:12 | amalloy | brehaut: you can often use fnil to gloss over the base case of your recursion |
| 00:14 | brehaut | amalloy: yeah thats really cool. definately adding it to my toolbox |
| 00:16 | amalloy | &(map (fnil (memfn length) "") ["foo" nil "x"]) |
| 00:16 | sexpbot | java.lang.IllegalStateException: Var clojail.core/tester is unbound. |
| 00:16 | amalloy | &(doall (map (fnil (memfn length) "") ["foo" nil "x"])) |
| 00:16 | sexpbot | ⟹ (3 0 1) |
| 00:17 | amalloy | that is a really annoying bug to fix in sexpbot, btw. i've been trying to wrap my head around it for a couple days |
| 00:19 | brehaut | im off. have a good rest of your day |
| 01:44 | replaca | Q: does anyone know the idiom to get clojure.walk/walk to stop recursing at some point in its walk? |
| 01:45 | replaca | I want to create a modified version of loop that modifies any returns inside, but doesn't modify nested loops |
| 01:46 | replaca | s/returns/recurs/ |
| 01:46 | sexpbot | <replaca> I want to create a modified version of loop that modifies any recurs inside, but doesn't modify nested loops |
| 01:47 | amalloy | replaca: walk doesn't recur at all; it's post-walk that adds the recursive-ness |
| 01:48 | amalloy | you want to call walk with an <inner> function like (fn [x] (if (some-condition x) x (some-transform x))) |
| 01:49 | replaca | amalloy: ahh, that makes the code make sense! Thanks for the insight - I knew I was missing something |
| 01:55 | brehaut | i think i have succeeded in writing my scraggliest piece of clojure so far. unimpressed with myself; there must be a cleaner way. |
| 01:55 | amalloy | brehaut: an admirable attitude, and expressed in such a way that i can't help but laugh |
| 01:55 | brehaut | amalloy: hah :) |
| 01:56 | brehaut | amalloy: any ideas on 'handle-post' in https://github.com/brehaut/necessary-evil/blob/master/src/necessary_evil/core.clj |
| 01:57 | brehaut | the nested if-let in a try are just plain nasty |
| 02:00 | amalloy | brehaut: hrm. there's no obvious way to improve it |
| 02:00 | brehaut | amalloy: le sigh |
| 02:01 | amalloy | brehaut: it makes me think of cond-let, though. i wonder if that can help somehow |
| 02:03 | brehaut | hmm. someone was asking about maybe-m which did stuff on failures. clearly this is my penance for not working harder on his problem |
| 02:03 | brehaut | cond-let looks interesting though |
| 02:03 | amalloy | brehaut: it is interesting, but i don't think we can apply it to this problem easily |
| 02:04 | brehaut | amalloy: agreed |
| 02:05 | amalloy | &(cond-let [[a b]] nil {a b} [1 2] (list a b)) |
| 02:05 | sexpbot | java.lang.Exception: Unable to resolve symbol: cond-let in this context |
| 02:05 | amalloy | (use 'clojure.contrib.cond) |
| 02:05 | amalloy | &(use 'clojure.contrib.cond) |
| 02:05 | sexpbot | java.io.FileNotFoundException: Could not locate clojure/contrib/cond__init.class or clojure/contrib/cond.clj on classpath: |
| 02:05 | amalloy | oh well |
| 02:06 | brehaut | (1 2) |
| 02:06 | brehaut | according to my repl |
| 02:07 | amalloy | brehaut: yeah, i hoped it would be. cond-let is kinda inside-out from when-let and if-let |
| 02:08 | brehaut | im not quite sure i understand what is going on |
| 02:09 | brehaut | i mean, i can kind of see whats happening, but im not quite sure how it deviates from cond |
| 02:10 | amalloy | brehaut: it gives you bindings from the test which you can use in the expr |
| 02:11 | amalloy | ie, it evaluates first nil, and then [1 2]; the first one that evaluates to true it binds to [[a b]], and then evaluates the corresponding expression |
| 02:11 | brehaut | ah right now i see |
| 02:11 | brehaut | clever |
| 02:12 | amalloy | brehaut: yes, it looks clever but i've never found a condition where it seems to fit. so maybe not |
| 02:12 | brehaut | amalloy: it doesnt seem to quite suit what i need |
| 02:12 | amalloy | no |
| 02:13 | brehaut | amalloy: i wonder if ideally id be best suited by a form that has pairs of expressions, first of each pair is the expression to try. if it fails (ie results in nil) then the second of the pair is evaluated and that isthe result of the expression. if i succeeds it moves on to the next pair and repeats. once there is no more pairs it returns the final result |
| 02:14 | brehaut | except that it gets horrible fast |
| 02:14 | amalloy | brehaut: so you want "and-let" |
| 02:14 | replaca | brehaut: isn't that just cond with a lot of "not"s |
| 02:14 | brehaut | amalloy: that would be a good name for it |
| 02:15 | brehaut | replaca: i missed a detail. the result of each successful pair is passed onto the next as an argument |
| 02:15 | brehaut | lets see if i can do a hypothetical |
| 02:16 | replaca | brehaut: ok, that's different |
| 02:17 | replaca | sort of like a mash-up of cond and -?> |
| 02:17 | brehaut | -?> is new to me |
| 02:18 | brehaut | (attempt [foo ({:foo {:bar 2}} :foo)] "no foo present" |
| 02:18 | brehaut | [r (:bar foo)] "found foo but not bar" |
| 02:18 | brehaut | r) ; => 2 |
| 02:18 | amalloy | brehaut: clojure.contrib.core/-?> |
| 02:19 | brehaut | this is really looking monadic to me :( |
| 02:19 | brehaut | clearly im on the wrong track if thats the case |
| 02:20 | brehaut | amalloy, replaca: cheers for the -?> pointer. looks handy |
| 02:25 | brehaut | is there a function to determine the available arity(s) of a fn? |
| 02:27 | amalloy | brehaut: none that i know of, but you can do it with a var, sorta |
| 02:28 | amalloy | &(-> partition var meta :arglists) |
| 02:28 | sexpbot | ⟹ ([n coll] [n step coll] [n step pad coll]) |
| 02:28 | _ato | brehaut: http://stackoverflow.com/questions/1696693/clojure-how-to-find-out-the-arity-of-function-at-runtime |
| 02:28 | amalloy | &(->> partition var meta :arglists first (map count)) |
| 02:28 | sexpbot | java.lang.UnsupportedOperationException: count not supported on this type: Symbol |
| 02:28 | amalloy | &(->> partition var meta :arglists (map count)) |
| 02:28 | sexpbot | ⟹ (2 3 4) |
| 02:29 | brehaut | amalloy _ato: cheers |
| 02:30 | amalloy | brehaut: but i'll echo the sentiments on stackoverflow: relying on this is unlikely to work well in practice |
| 02:30 | brehaut | amalloy: i was worried about that |
| 02:30 | brehaut | esp seeing as the comments are that its not really workable on anon funs |
| 02:30 | amalloy | right, like i said: only for vars |
| 02:31 | brehaut | amalloy: yeah. oh well. |
| 02:31 | amalloy | well. i suppose someone could attach arglist metadata to the anonymous functions they return you, but... |
| 02:31 | _ato | IIRC you can do it with java reflection on anon fns |
| 02:31 | brehaut | yeah thats unlikely to happen! |
| 02:31 | _ato | not sure if that breaks with primitive args in 1.3 though |
| 02:32 | brehaut | _ato that might be something i put off for now |
| 02:32 | amalloy | _ato: i don't think primitives will break it, but anon functions with multiple arities would |
| 02:33 | _ato | http://groups.google.com/group/clojure/browse_thread/thread/d9953ada48068d78/1823e56ffba50dbb |
| 02:33 | _ato | see Achim's answer |
| 02:34 | amalloy | yeah, that's a good answer |
| 02:34 | amalloy | "here is some clever code that does what you want. but don't use it, it's really a bad idea" |
| 02:35 | brehaut | im comfortable with just catching the exception and having really minimal autodocumentation for these handlers |
| 02:35 | brehaut | cheers for all the pointers |
| 03:54 | brehaut | Raynes: ping? |
| 03:54 | Raynes | brehaut: Furious pong. |
| 03:55 | brehaut | im not quite sure what to make of that! |
| 03:55 | Raynes | :p |
| 03:55 | brehaut | so as to not duplicate effort on another project, did you have any partcular blog api's you were planning to start work on ? |
| 03:56 | Raynes | brehaut: Wordpress mostly. I wanted to write a library for all of the major blogging engines, but I'm not sure how feasible that is given differences in APIs. |
| 03:56 | Raynes | I need wordpress as a prerequisite for my blog editor. |
| 03:56 | brehaut | Raynes: so you are planning to consume their APIs rather than reimplement them? |
| 03:57 | brehaut | Raynes: i was planning to implement both ends of pingback next just as a heads up |
| 03:57 | Raynes | The former. |
| 03:57 | brehaut | sweet as. that should mean we avoid duplicating effort |
| 03:58 | Raynes | I haven't started work on anything and didn't have any plans on doing so in the immediate future, so no duplicating going on here. <3 |
| 03:58 | Raynes | I've been busy on a super secret project lately. |
| 03:59 | brehaut | heh :) |
| 04:04 | AWizzArd | Will protocol fns always dispatch to the most specific type? |
| 04:08 | raek | AWizzArd: http://groups.google.com/group/clojure-dev/browse_thread/thread/fb3a0b03bf3ef8ca?pli=1 |
| 04:13 | AWizzArd | raek: thx |
| 04:20 | ejackson | morning all |
| 04:56 | fbru02 | Hey all , don't want to bring back the thread about primitive support, but just want to check that i understand correctly According to this : http://dev.clojure.org/display/doc/Enhanced+Primitive+Support it seems that the reason for the change was to gain ability to have primitives in fns, thus being able to do high-order stuff with primitives. Am i right ? |
| 05:02 | fliebel | morning |
| 05:02 | fbru02 | fliebel: morning ! |
| 05:03 | _ato | fbru02: as arguments and return values yes. You could already use primitives within a fn, but they would be boxed when passed to another fn |
| 05:03 | fbru02 | _ato: thanks |
| 05:05 | fliebel | This morning I found a very good argument for the new pods, and why they should not do the lock managing thing. You know why? Because it'll be awesome to have Podrace conditions! :) |
| 05:16 | fbru02 | _ato: the other day i was reading this http://tech.puredanger.com/2010/10/25/conj-parallel/ and if you look near the end it says that (after this changes) "we can leverage everything latent in the JVM" what is everything latent in the JVM? |
| 05:16 | fbru02 | fliebel: nice :D |
| 05:30 | Leonidas | what is the name of the function to divite a seq into two, depending on a predicate? |
| 05:30 | Leonidas | *divide |
| 05:30 | fliebel | split-with |
| 05:31 | Leonidas | fliebel: thanks, exactly what I was looking for |
| 05:42 | Raynes | Morning cemerick. |
| 05:43 | cemerick | morning :-) |
| 05:43 | Raynes | cemerick: Been doing much book writing lately? |
| 05:44 | cemerick | Raynes: my usual amount. I've been on the same cadence since ~October. |
| 05:45 | ejackson | cemerick: is the book going to built using Maven, like the Maven book ? |
| 05:45 | cemerick | ejackson: no, O'Reilly has its own tooling platform. I've no idea what drives it. |
| 05:46 | cemerick | All the code in the book will likely be tested via maven, though. |
| 05:46 | ejackson | if you write in LaTeX, then the whole process is just like coding.... How fun :) |
| 05:47 | ejackson | deployment to pdf, hahahaha |
| 05:48 | cemerick | They're very anti-latex. Non-semantic markup, etc. |
| 05:49 | ejackson | I guess they'd know. Still, it seems like a powerful toolchain. |
| 05:51 | cemerick | My impression of their impression is that it doesn't play well with others, in various ways. |
| 05:51 | cemerick | e.g. if you're Knuth or writing a dissertation, it seems just fine because you can do things your way |
| 05:51 | cemerick | If you're trying to keep a "house style" across 100's of books, it's just a PITA. *shrug* |
| 05:52 | cemerick | I actually figured I'd have to learn latex for the book, but asciidoc is **way** simpler. :-D |
| 05:52 | Raynes | I'm using Lyx for my book. LaTeX without having to deal with LaTeX. |
| 05:52 | ejackson | In our lab we had a latex stylesheet that did exactly that. I grant that requires an in house wizard though. |
| 05:53 | Raynes | Lyx has been a joy to write with so far. |
| 05:53 | ejackson | Glad to hear it. LaTeX is marvellous. |
| 05:54 | mrBliss | Raynes: what's your book about? |
| 05:54 | fliebel | Raynes: You're writing a book? And, LaTeX is the math thing, right? You write books with that? |
| 05:54 | Raynes | mrBliss: Clojure |
| 05:54 | Raynes | LaTeX is for * |
| 05:54 | ejackson | cemerick: actually, I'm suprised to hear that argument, given that all the techie journals ask for LaTeX and manage to publish in a house style. |
| 05:54 | mrBliss | Raynes: what's gonna be your focus? |
| 05:55 | ejackson | fliebel: latex is a document layout language. Its particularly good at doing maths, hence the association. |
| 05:55 | cemerick | ejackson: I'm not sure anyone else operates at O'Reilly's scale. |
| 05:55 | fliebel | okay |
| 05:55 | ejackson | cemerick: this is true :D |
| 05:55 | cemerick | In any case, insofar as their approach didn't force me to use latex, I'm happy for it. ;-) |
| 05:55 | Raynes | mrBliss: Freeness. It's licensed under a CC license and will be made freely available upon completion. It is not aimed at anybody in particular, but the book is an introductory book that expects some programming knowledge in any given language. |
| 05:56 | Raynes | cemerick: I remember your editor from the Conj. |
| 05:56 | Raynes | Julie Steele. |
| 05:56 | cemerick | Yup, that's her. |
| 05:56 | Raynes | One of the few women that attended. |
| 05:56 | Raynes | My own book has been keeping me away from doing tech review on your book. :( |
| 05:57 | Raynes | I'm paranoid that if I don't hurry with the tech review, I'll get way behind when more drafts are out. |
| 05:57 | bobo_ | Someone should write a book about web devlopment or statistics in clojure. so i can read it =) |
| 05:58 | cemerick | Raynes: I think that's a fair bet. You've got to keep your own cadence. ;-) |
| 05:58 | ejackson | bobo_: an interesting idea indeed.... |
| 05:58 | cemerick | bobo_: @marick is doing a book on Ring, FWIW |
| 05:58 | Raynes | mrBliss: Of course, it isn't being published by anybody, so if anybody wants printed copies, they'll have to print it themselves. |
| 06:00 | bobo_ | cemerick: oh he is? awesome |
| 06:01 | mrBliss | Now that we're on the topic of books: which one should I read first "On Lisp" or "ANSI Common Lisp". Or does reading one make the other redundant? |
| 06:03 | bobo_ | a mixed book with one chapter on web development, one on statistics, and other more practical things would also be nice |
| 06:03 | fbru02 | bobo_: clojure in action kinda does that |
| 06:03 | Raynes | Well, I might self-publish printed copies while making the pdf free. |
| 06:03 | cemerick | bobo_: That almost perfectly describes our book, actually. |
| 06:04 | bobo_ | fbru02: it does? and i thought i have read clojure in action =) |
| 06:04 | fbru02 | bobo_: i thought i read it too :) |
| 06:04 | bobo_ | cemerick: yours is practical clojure? |
| 06:04 | Raynes | My book is going to have a chapter devoted to creating a library and an application that uses that library. Using cake. Probably some stuff on web development and whatever else I feel like talking about. |
| 06:04 | cemerick | bobo_: no: http://cemerick.com/2010/09/10/clojure-programming-the-book/ |
| 06:05 | bobo_ | ah |
| 06:05 | ejackson | Raynes: thought of pre-publishing on a blog ? Would be nice for rapid iteration and feedback. |
| 06:05 | Raynes | I enjoyed Real World Haskell's chapters walking through the creation of real things. |
| 06:06 | fbru02 | Raynes: i was thinking that too ! I even grabbed my copy of RWH |
| 06:07 | Raynes | ejackson: I've been giving drafts to a lot of people from different walks of life, including non-Clojure and non-Lispers. I'll probably give it to more and more as I write more. I'll probably throw the final drafts up on my blog and let people give me feedback before I totally finalize the book. |
| 06:07 | ejackson | groovy |
| 06:07 | clojurebot | Titim gan éirí ort. |
| 06:08 | ejackson | $botsnack |
| 06:08 | sexpbot | ejackson: Thanks! Om nom nom!! |
| 06:08 | ejackson | take that clojurebot ! ha |
| 06:09 | Raynes | $huggle ejackson |
| 06:09 | ejackson | oh lord |
| 06:14 | Raynes | It's surprising that I've written as much as I have so quickly. Especially given that I wrote more typos than coherent sentences. |
| 06:14 | Gigaroby | hello guys |
| 06:16 | Gigaroby | can I ask a question ? |
| 06:16 | fliebel | Gigaroby: No! |
| 06:16 | fliebel | Welll, yes of course |
| 06:16 | Gigaroby | thanks |
| 06:16 | Gigaroby | I'm new to clojure |
| 06:16 | fliebel | And to IRC... |
| 06:16 | Gigaroby | and I'm trying to write somethink that make sense |
| 06:16 | Gigaroby | yep both |
| 06:16 | Gigaroby | never used |
| 06:17 | Gigaroby | irc |
| 06:17 | Gigaroby | what am I doing wrong btw ? |
| 06:17 | fliebel | Gigaroby: "Don't aks to ask" |
| 06:17 | Gigaroby | good |
| 06:17 | Gigaroby | I was looking |
| 06:17 | Gigaroby | for a function |
| 06:18 | Gigaroby | to count how many elements are in a collection |
| 06:18 | Gigaroby | like |
| 06:18 | fliebel | (and type a whole sentence before you hit enter) |
| 06:18 | Raynes | &(count [1 2 3 4]) |
| 06:18 | sexpbot | ⟹ 4 |
| 06:18 | Gigaroby | no |
| 06:18 | Gigaroby | not that |
| 06:18 | Gigaroby | I meant (count 1 '( 1 2 4 5 1 5 2)) |
| 06:18 | fliebel | $(distinct [1 2 3 1 2]) |
| 06:18 | Gigaroby | -> 2 |
| 06:19 | Raynes | Oh. I see. |
| 06:19 | mrBliss | $(count (filter #{1} '( 1 2 4 5 1 5 2))) |
| 06:19 | Raynes | &(distinct [1 2 3 1 2]) |
| 06:19 | sexpbot | ⟹ (1 2 3) |
| 06:19 | Raynes | Ampersand, silly. |
| 06:19 | mrBliss | &(count (filter #{1} '( 1 2 4 5 1 5 2))) |
| 06:19 | sexpbot | ⟹ 2 |
| 06:19 | fliebel | The PHP I did yesterday got me I think :( |
| 06:20 | Gigaroby | ok that what I meant I just thought there was a function I didn't see |
| 06:20 | Raynes | &(group-by identity [1 2 3 4 5 1 5 2]) |
| 06:20 | sexpbot | ⟹ {1 [1 1], 2 [2 2], 3 [3], 4 [4], 5 [5 5]} |
| 06:21 | Raynes | &((group-by identity [1 2 3 4 5 1 5 2]) 1) |
| 06:21 | sexpbot | ⟹ [1 1] |
| 06:21 | Raynes | Fun. |
| 06:21 | Raynes | mrBliss's example is better, of course. Still, fun. |
| 06:21 | Gigaroby | yeah |
| 06:21 | Gigaroby | good |
| 06:21 | mrBliss | Gigaroby: Clojure's count is CL's length, not CL's count. |
| 06:21 | fliebel | Poor Gigaroby, asks for one solutions, gets ten :) |
| 06:22 | Gigaroby | better than 0 anyway |
| 06:22 | Gigaroby | thanks a lot |
| 06:24 | fliebel | &(get 1 (frequencies [ 1 2 3 1 2 3])) |
| 06:24 | sexpbot | ⟹ nil |
| 06:24 | fliebel | &(get (frequencies [ 1 2 3 1 2 3]) 1) |
| 06:24 | sexpbot | ⟹ 2 |
| 06:25 | Gigaroby | a set used like a function just test the membership of the argument ? |
| 06:25 | fliebel | $huggle frequencies |
| 06:26 | Raynes | fliebel: Ah! I knew there was something I was forgetting. |
| 06:26 | mrBliss | Gigaroby: correct |
| 06:26 | Gigaroby | ok |
| 06:26 | Gigaroby | it's weird not having all the usual loops and stuff |
| 06:27 | mrBliss | Gigaroby: What's your background? Common Lisp, Ruby, Python, Java, ...? |
| 06:27 | Gigaroby | Python and Java at most |
| 06:27 | Gigaroby | some php |
| 06:27 | Gigaroby | some C |
| 06:27 | fliebel | Gigaroby: Same as me :) |
| 06:28 | mrBliss | Gigaroby: I thought Common Lisp, since the 'count' you suggested, does exactly what you need in Common Lisp :-) |
| 06:28 | Gigaroby | mrBliss no just get a clojure manual on the kindle sounded like fun |
| 06:29 | Gigaroby | infact it was btw |
| 06:29 | fliebel | &(reduce #(if (= %2 1) (inc %1) %1) 0 [1 2 3 2 3 1]) |
| 06:29 | sexpbot | ⟹ 2 |
| 06:31 | fliebel | &(keep (map #{1} [1 2 3 1 2 3])) |
| 06:31 | sexpbot | java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$keep |
| 06:31 | mrBliss | Gigaroby: besides the good books that are currently available, http://clojuredocs.org/quickref/Clojure%20Core is very helpful |
| 06:31 | fliebel | &(keep identity (map irc://irc.freenode.net:6667/#%7B1} [1 2 3 1 2 3])) |
| 06:31 | sexpbot | java.lang.Exception: Unmatched delimiter: } |
| 06:31 | Gigaroby | mrBliss, thanks I'll have a look but when I begin a new language I like to have a manual to follow |
| 06:32 | fliebel | huh? |
| 06:33 | mrBliss | fliebel: another one for your list: ##(count (remove (complement #{1}) '(1 2 3 1 2 3))) ; pretty similar to my previous solution though |
| 06:34 | sexpbot | ⟹ 2 |
| 06:36 | Gigaroby | mrBliss, the first is my favourite I think |
| 06:37 | AWizzArd | &seen AWizzArd |
| 06:37 | sexpbot | java.lang.Exception: Unable to resolve symbol: seen in this context |
| 06:37 | mrBliss | Gigaroby: it's probably the most idiomatic |
| 06:37 | AWizzArd | Raynes: can you add a $seen fn to the sex bot? |
| 06:38 | Raynes | $seen AWizzArd |
| 06:38 | sexpbot | AWizzArd was last seen talking on #clojure 10 seconds and 787 milliseconds ago. |
| 06:38 | Raynes | Normal commands are prefixed with $, while code is prefixed with & for evaluation. |
| 06:39 | fliebel | &(count (nth (partition-by identity (sort [ 1 2 3 1 2 3])) 0)) |
| 06:39 | sexpbot | ⟹ 2 |
| 06:43 | fliebel | 5 distinct solutions so far. |
| 07:01 | fliebel | http://pepijndevos.nl/6-ways-to-tell-how-many-xes-are-in-a-list |
| 07:17 | Gigaroby | how do you do != in clojure ? |
| 07:18 | Raynes | not= |
| 07:18 | Raynes | &(not= 3 3) |
| 07:18 | sexpbot | ⟹ false |
| 07:21 | Gigaroby | thanks Raynes |
| 07:29 | _ato | &((fn f [[x & xs :as coll]] (cond (= coll '(1)) 1, (nil? xs) 0, :else (apply + (map #(f (take-nth 2 %)) [coll xs])))) [1 2 3 4 5 1 5 2]) |
| 07:29 | sexpbot | ⟹ 2 |
| 07:30 | Raynes | Holy God, I've just went blind. |
| 07:38 | _ato | &(let [s (sort [1 2 3 4 5 1 5 2])] (- (.lastIndexOf s 1) (.indexOf s 1) -1)) |
| 07:38 | sexpbot | ⟹ 2 |
| 07:40 | AWizzArd | Raynes: ah ok |
| 07:41 | AWizzArd | $seen rhickey |
| 07:41 | sexpbot | rhickey was last seen quitting 2 weeks and 2 days ago. |
| 07:41 | Raynes | $seen stuarthalloway |
| 07:41 | sexpbot | stuarthalloway was last seen quitting 4 weeks ago. |
| 07:42 | Raynes | If not for chouser, I'd feel like a chick without a hen. |
| 07:52 | rsenior | I've got a -main function (invoking via lein run) and I am trying to get console input from (.readLine *in*) or (read-line) via that main function and for some reason (.readLine *in*) does not prompt for input and always just returns nil |
| 07:52 | rsenior | is it possible that something else has grabbed System/in? |
| 08:03 | rsenior | probably too early for an I/O question :-) |
| 08:04 | mids | rsenior: http://stackoverflow.com/questions/3790889/clojure-lein-read-line-stdin-woes |
| 08:04 | LauJensen | Morning all |
| 08:06 | fliebel | _ato: I'll add them. beautiful! |
| 08:06 | fliebel | LauJensen: morning |
| 08:06 | ejackson | hey Lau |
| 08:07 | LauJensen | Hey Action Jackson |
| 08:07 | rsenior | mids: that certainly seems like my issue, thanks! |
| 08:08 | ejackson | Lau, no that's ajackson. |
| 08:09 | Raynes | LauJensen: Ohai |
| 08:09 | Raynes | LauJensen: You missed the public announcement of my new book. ;> |
| 08:09 | LauJensen | I sure did - link? :) |
| 08:10 | Raynes | It isn't actually finished yet. Only been writing for just over a week. I've got a 47 page draft sitting in front of me right now. |
| 08:10 | LauJensen | Exiciting, how did you get the idea for a book ? |
| 08:11 | Raynes | Well, it's a Clojure book. Not fiction. |
| 08:11 | jk_ | silly question but... "byte b = 0x80" works in java (= -127) but how do i do this in clojure? I understand that Java doesn't have unsigned bytes, I just want it to give me the equivalent value with the same bits set |
| 08:12 | Raynes | LauJensen: I'd like to fill the 'free' niche that no Clojure book fills yet. |
| 08:12 | Raynes | I'm licensing it under a CC license and making it freely available upon completion. |
| 08:12 | Raynes | Might self-publish it and make printed copies available. |
| 08:12 | LauJensen | Interesting. What would happen if you put no license on it at all ? |
| 08:13 | Raynes | Well, there is the unlikely event that someone would take the book and put their name on it and sell it. |
| 08:14 | LauJensen | In which case you would be prepared to sue ? :) |
| 08:14 | fliebel | Hah, I found the link to the Ring book on the Google group . "This book seems intended to be about Ring specifically, rather than the more general topic of how to write Clojure web applications." |
| 08:15 | Raynes | With a fury. I'm almost ready to take the BAR. |
| 08:16 | fliebel | So, no general web dev books yet? |
| 08:16 | Raynes | Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License is the license I'm licensing it under. Nice long one. |
| 08:19 | Raynes | Speaking of all that: dear chouser, thank you for coauthoring The Joy of Clojure. If I didn't have that book to teach me this stuff, I wouldn't be able to write what I'm writing in the first place. |
| 08:20 | Raynes | I keep it open for reference as I write. |
| 08:20 | cemerick | That's a good one. Lets others pass around the PDF, but doesn't allow others to sell copies. |
| 08:20 | cemerick | IIRC, anyway. |
| 08:20 | Raynes | cemerick: That's about right. |
| 08:21 | Raynes | And, people can make changes to it as long as it remains under the same license. |
| 08:22 | jk_ | silly question but... "byte b = 0x80" works in java (= -127) but how do i do this in clojure? I understand that Java doesn't have unsigned bytes, I just want it to give me the equivalent value with the same bits set |
| 08:22 | jk_ | this document says (byte) should wrap around, but it doesn't seem to: http://faustus.webatu.com/clj-quick-ref.html |
| 08:25 | ejackson | jk_: that's true, now it throws an out of range exception |
| 08:28 | jk_ | ejackson: and no function exists to return the byte equivalent? |
| 08:29 | ejackson | jk_: no idea. |
| 08:29 | jk_ | ejackson: i'm trying to pack an integer value into 3 bytes and was confronted by this when i had working java code to do the same |
| 08:30 | jk_ | not b64 encoding... some stupid proprietary protocol |
| 08:30 | TubeSteak | jk_: well, if it's a constant, why don't you put the signed value? |
| 08:31 | jk_ | TubeSteak: sure, that's what i want to do. i want to pass an arbitrary value 0x00-0xFF and have it return the signed byte value |
| 08:31 | jk_ | TubeSteak: i just thought a byte cast would do that, or that an existing function at least existed.(java byte cast does this exact thing) |
| 08:34 | jk_ | i could write the function but i found it hard to believe that this functionality was lost in clojure |
| 08:34 | jk_ | that's why i'm asking here :) |
| 08:37 | fliebel | LauJensen: You know about this? http://en.wikipedia.org/wiki/Language_Integrated_Query |
| 08:37 | LauJensen | fliebel: yep |
| 08:37 | LauJensen | Its like a poor mans version of ClojureQL :) |
| 08:38 | fliebel | LauJensen: Just what I thought… Somewhat related: Is there a data structure backend for CQL? |
| 08:39 | LauJensen | fliebel: Yes, the RTable record is effectively an AST comprised by its fields, altered by its methods |
| 08:40 | fliebel | LauJensen: I'm afraid you use to many unknown words in that sentence… A what record is effective a what? |
| 08:41 | LauJensen | fliebel: ClojureQL contains this like (defrecord RTable [....]). That record has fields like table-name, columns, predicates etc. Together they form an Abstract Syntax Tree, a datarepresentation of the query. This AST can be easily modified by the methods of the record, ie. (select tble (where (= :x 5))) etc. |
| 08:41 | Crowb4r | amalloy_: Hey, how do I give a plugin to you and Raynes for sexpbot? |
| 08:42 | jk_ | LauJensen: but can you easily convert any seq or data collection in clojure to an RTable? that's what LINQ does for you, (i think, not a .net programmer) |
| 08:42 | Raynes | Crowb4r: If you have forked sexpbot on Github and added the plugin, you're welcome to issue a pull request and it will be looked at as soon as possible. |
| 08:42 | LauJensen | jk_: essentialy its a hashmap |
| 08:44 | jk_ | LauJensen: all i'm saying is that LINQ has functionality that isn't already built into ClojureQL in that you can apply LINQ operations to any enumerable or sequence in .NET |
| 08:45 | LauJensen | jk_: Im not sure I follow, can you show an example ? |
| 08:45 | fliebel | LauJensen: So can I do (into (RTable) {:a 1 :b 2 :c 3}) and then do the CQL equivalent of SELECT * FROM :a , or something like that? |
| 08:45 | jk_ | LauJensen: read the wikipedia article referenced... section on LINQ providers |
| 08:45 | LauJensen | Aha. That would be trivial to implement. Like (map rtable [{:a 5} {:b 5} {:c 5}]) etc |
| 08:46 | LauJensen | Im not sure that buys us anything in the composability department though |
| 08:52 | Crowb4r | Raynes: ok, will do. I have a couple of features my bot has that can be converted to run on sexpbot. |
| 08:53 | fliebel | LauJensen: What it buys you is that you can do relational stuff to your seqs, rather than (reduce (map)). Like NoSQL vs SQL. |
| 08:57 | LauJensen | fliebel: But you realiase that ClojureQL already lets you do relational operations right? |
| 08:58 | Gigaroby | how can I load a file into the repl ? |
| 08:58 | fliebel | LauJensen: On relational databases. What if I parse a nice XML file, can it do relational stuff to that as well? |
| 08:58 | LauJensen | fliebel: no, hence the QL |
| 08:59 | LauJensen | For normal relational algebra ops, you have clojure.set, for SQL backends, you have clojureql |
| 08:59 | fliebel | LauJensen: LINQ to XML offers this, but I'll have a closer look at clojure.set. |
| 09:01 | fliebel | *amazed* I had no idea clojure.set contained things like join and select! |
| 09:15 | ejackson | fliebel: you didn't read Stuart Halloways book (seeing we're talking books today) ! |
| 09:16 | fliebel | ejackson: Uh, no. Which one is it? |
| 09:16 | ejackson | "Programming Clojure" the first clojure book |
| 09:27 | Gigaroby | gotta problem : I was trying to execute a few lines I write and I dunno what's wrong but the compiler gives me an error on line 0. http://pastebin.com/EqBxpSEz |
| 09:28 | fliebel | Gigaroby: What error? |
| 09:28 | mrBliss | Gigaroby: the docstring give me an error |
| 09:28 | mrBliss | only the first line should start with a " and only the last line should end with a " |
| 09:29 | Gigaroby | mrBliss, wich first line are you talking about ? |
| 09:29 | Gigaroby | mrBliss, you mean docstrings ? |
| 09:29 | mrBliss | Gigaroby: yes remove the last char from L10 and the first from L11 |
| 09:30 | Gigaroby | mrBliss, fliebel thanks a lot |
| 09:31 | Gigaroby | mrBliss, still same error |
| 09:31 | mrBliss | Gigaroby: I'll post a fixed version in a sec |
| 09:31 | Gigaroby | mrBliss, but I did correct the docstring |
| 09:31 | Gigaroby | mrBliss, thanks |
| 09:32 | agentwrangler | Is it a bug or a feature that you can't send-off from within the error-handler of a failed agent? |
| 09:32 | chouser | agentwrangler: what version of Clojure? |
| 09:32 | agentwrangler | chouser: 1.2.0 |
| 09:34 | Gigaroby | mrBliss, must be a lot of mess I'm sorry but that's the first I do with clojure |
| 09:34 | mrBliss | Gigaroby: http://pastebin.com/C7WjXM88 |
| 09:35 | chouser | I believe it was intentional, but has been changed in 1.3-alpha4: http://dev.clojure.org/jira/browse/CLJ-390 |
| 09:35 | mrBliss | Gigaroby: it's ok, I've seen much worse ;-) |
| 09:35 | mrBliss | Gigaroby: this compiles |
| 09:36 | agentwrangler | chouser: thanks! |
| 09:36 | Gigaroby | mrBliss, you think the style is lispy enaugh or I'm still too in imperative programming ? |
| 09:37 | mrBliss | Gigaroby: judging by this small amount of code, I think you're on the right path |
| 09:38 | Gigaroby | mrBliss, ok thanks I understood what was wrong |
| 09:39 | Gigaroby | mrBliss, you gotta declare the functions in the order in wich you are going to use or at least with declare |
| 09:39 | mrBliss | Gigaroby: correct. Also notice the last expression (the or) |
| 09:39 | mrBliss | Gigaroby: In Clojure, you seldomly return false or true explicitly |
| 09:40 | Gigaroby | mrBliss, that was just style of indentation or there was an error ? |
| 09:40 | mrBliss | Gigaroby: in Lisps in general, everything that's not nil or false will be treated as 'true' in an 'if' |
| 09:42 | Gigaroby | mrBliss, good thanks |
| 09:43 | mids | Gigaroby: minor nitpick; for a predicate I'd drop the is- prefix if it already has a ? at the end |
| 09:43 | Gigaroby | mids, fair enaugh thanks |
| 09:43 | mids | so position-valid? instead of is-position-valid? |
| 09:44 | mrBliss | Gigaroby: small tip: you can replace L27 with (let [{:keys [board current-queen]} queens |
| 09:45 | Gigaroby | mrBliss, any suggestion for an IDE ? |
| 09:46 | mrBliss | Gigaroby: most Clojurians use Emacs + Slime, but I think Eclipse + counterclockwise is easier to start with |
| 09:47 | Gigaroby | mrBliss, yeah I do use eclipse for python and java as well |
| 09:47 | mrBliss | Gigaroby: http://www.assembla.com/wiki/show/clojure/Getting_Started |
| 09:58 | Gigaroby | mrBliss, counterclockwise is really good thanks for the tips now I go offline |
| 09:58 | Gigaroby | see ya |
| 09:58 | mrBliss | Gigaroby: hope to see you again on this channel |
| 09:58 | Gigaroby | mrBliss, tomorrow for sure xD |
| 10:08 | drdozer | hi - are there any resources to get me started with genetic programming using clojure? |
| 10:08 | mrBliss | drdozer: An example: http://npcontemplation.blogspot.com/2009/01/clojure-genetic-mona-lisa-problem-in.html |
| 10:12 | drdozer | Now I'm remembering why I don't use lisp :) |
| 10:13 | drdozer | thanks mrBliss for that example |
| 10:13 | drdozer | I have a multi-player game coded up in scala, and need to write some bots to play it |
| 10:15 | drdozer | so I'm hoping to breed functions that make sensible responses when it is time for the bot to make a move |
| 10:15 | companion_cube | wow, anonymous classes are not garbage collected ? this is ugly |
| 10:17 | chouser | companion_cube: where are you seeing that? |
| 10:17 | companion_cube | in the blog post mrBliss posted |
| 10:18 | Raynes | companion_cube: Where did that name come from, if you don't mind me asking? I am deadly curious. |
| 10:19 | companion_cube | you mean my nickname ? |
| 10:19 | Raynes | Yes. |
| 10:19 | joly | sound like Portal |
| 10:19 | companion_cube | it comes from portal, yeah :D |
| 10:19 | Raynes | I was thinking of a few games with cubes. None of them were minecraft. |
| 10:19 | joly | interesting 1st person puzzle game that I couldn't play due to motion sickness :P |
| 10:24 | chouser | joly: I can relate. Very high framerate helps, but still I often had to stop playing to recover my equilibrium. |
| 10:24 | Crowb4r | what makes sexpbot eval clojure code? |
| 10:25 | chouser | companion_cube: you see the note in there that the class GC problem has been corrected? |
| 10:25 | companion_cube | oh, i didn't see it, thanks |
| 10:28 | fliebel | Crowb4r: prefix it with an ampersand or with ##(println "this") mid-sentence. |
| 10:28 | sexpbot | ⟹ this nil |
| 10:28 | Raynes | Crowb4r: There is a Clojure plugin. clojure.clj. It uses clojail to evaluate code. |
| 10:28 | Raynes | Oh. Is that what he was asking? |
| 10:28 | fliebel | I don't know... |
| 10:29 | Raynes | ;) |
| 10:29 | fliebel | Crowb4r: Enlighten us, what did you want to know? |
| 10:30 | Crowb4r | I was asking the keyword to kick it off |
| 10:31 | Crowb4r | before opening up the src code to look at the trigger |
| 10:31 | Crowb4r | like ',' is clojurebot |
| 10:31 | eckroth | If I defn a multiple-arity fn, I cannot :use it in another ns; why is that (or am I mistaken)? |
| 10:31 | joly | &(println "test") |
| 10:31 | sexpbot | ⟹ test nil |
| 10:31 | Crowb4r | got ya |
| 10:32 | Crowb4r | Raynes: also where are the dynamic.clj and status.clj files I had to take them out of plugins to load because it could not find the files and I don't see them on github anyplace. |
| 10:33 | Raynes | Crowb4r: Eh, those were deleted a few weeks ago. I forgot to remove the references to them from the default configuration. |
| 10:34 | Raynes | Just remove them from the plugin lists in your config. Sorry for that. I'll push a commit to remove them in a moment. |
| 10:34 | Crowb4r | Raynes: kk, umm another question anything specdial I have to do besides have mongo db just run in and be connectable (using ubuntu 10.10)? |
| 10:35 | Crowb4r | or is ther ea config I'm missing |
| 10:35 | Crowb4r | this is fresh from apt in this vm |
| 10:36 | Raynes | Right. You should just be able to start it up and run. If the apt installation configures it to use a non-standard default port, it might not work though. |
| 10:37 | Crowb4r | Raynes: because I get this error when I send him a message in an irc server http://pastebin.com/yVxfNSeH |
| 10:37 | Raynes | Right, that means he isn't seeing mongo. Make sure that it is being run on port 27017 |
| 10:37 | Raynes | I don't think I've made that configurable yet. |
| 10:37 | Crowb4r | Raynes: ok thanks |
| 10:37 | Crowb4r | will look |
| 10:38 | Crowb4r | thanks for all the help |
| 10:38 | cemerick | fliebel: a couchdb "external handler"? |
| 10:38 | Raynes | Crowb4r: Also, we have a channel for sexpbot and related projects: #sexpbot |
| 10:38 | Crowb4r | Raynes: alright, I will squat in that one as well, thanks |
| 10:38 | Raynes | If you don't mind, please join there for further discussion/questions. |
| 10:38 | Raynes | :) |
| 10:38 | Crowb4r | done |
| 11:02 | joly | &(macroexpand-1 (binding [test 5] (println test))) |
| 11:02 | sexpbot | ⟹ 5 nil |
| 11:02 | joly | &(doc binding) |
| 11:02 | sexpbot | ⟹ "Macro ([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made i... http://gist.github.com/751681 |
| 11:02 | fliebel | &(macroexpand-1 '(binding [test 5] (println test))) |
| 11:02 | sexpbot | ⟹ (let* [] (clojure.core/push-thread-bindings (clojure.core/hash-map (var test) 5)) (try (println test) (finally (clojure.core/pop-thread-bindings)))) |
| 11:02 | joly | ah, thanks |
| 11:06 | joly | I'm looking at some scheme code that uses make-parameter and parameterize. Would binding be a good way to translate that in general? |
| 11:10 | chouser | joly: After reading a couple paragraphs of related scheme docs, I think so. |
| 11:11 | chouser | though clojure's use of lazy seqs can sometimes lead to surprising results with 'binding' |
| 11:13 | chouser | because of that, how they interact with multiple threads, and how it leads to non-pure functions, many people avoid using 'binding' as much as possible in Clojure. |
| 11:28 | joly | chouser: thanks, I'll keep an eye out trouble. I shouldn't be dealing with lazy seqs or multiple threads here, but I'll be on my guard |
| 11:28 | joly | for trouble* |
| 11:32 | kurtharriger | where does one find foldr foldl do these functions not already exist? |
| 11:33 | chouser | reduce is one of them, though I forget which |
| 11:34 | chouser | foldl I think |
| 11:34 | joly | reduce should be foldl |
| 11:34 | chouser | foldr is rarely needed and not provided by clojure core, afaik. |
| 11:34 | kurtharriger | k |
| 11:35 | kurtharriger | reduce works thanks |
| 11:36 | chouser | I think foldr would be something like (reduce #(f %2 %1) (reverse coll)) |
| 11:36 | tonyl | morning |
| 11:36 | Dranik | for what projects do you guys use clojure? |
| 11:37 | chouser | eeeeevvvvrrrryyyytttthhhiiinnnngggggg |
| 11:37 | chouser | ;-) |
| 11:37 | Dranik | chouser, for example? |
| 11:38 | fbru02_ | Dranik: what's on your mind , and i will tell u if clojure is a good fit ! :) |
| 11:38 | Dranik | fbru02_, well, I'm trying to determin which projects clojure fits best comparing to java |
| 11:39 | fbru02_ | comparing to java? |
| 11:39 | Dranik | yep |
| 11:39 | fbru02_ | if you are thinking of doing sth in java , do it in clojure, you will be happier |
| 11:40 | Dranik | fbru02_, well, its a bit complex to do j2ee with pure clojure |
| 11:40 | chouser | the most common good reason I run into for not using Clojure is because the JVM is unavailable or a poor fit |
| 11:41 | Dranik | chouser, like in Android, for instance? |
| 11:41 | fbru02_ | i agree with chouser, and i would add web-dev is somehow easier in rails for me because i have experience with that |
| 11:41 | chouser | Dranik: well, some people are doing even that. I meant like in the web browser, or for quick-startup at the command line. |
| 11:41 | fbru02_ | but other than that , clojure for most of the stuff |
| 11:42 | Dranik | fbru02_, that's why I've said "comparing to java", bcs web-development with rails3 is really much easier :-) |
| 11:42 | Dranik | chouser, could you give any examples? |
| 11:43 | fbru02_ | we are doing a web app hallf in rails and half in clojure , with zeromq and works great |
| 11:43 | chouser | Dranik: examples of things I've used Clojure for? |
| 11:43 | Dranik | fbru02_, so why did you choose clojure with rails, not pure rails? |
| 11:44 | Dranik | chouser, yep |
| 11:45 | fbru02_ | i was doing provisioning but wanting to do it concurrently and used pallet for that, hugod does a great job and i much prefer it over the ruby solutions |
| 11:45 | chouser | scraping web pages, web apps, web apis, mongo abstraction layer, protobuf library, data structure experimentation |
| 11:45 | chouser | I'm sure I'm forgetting things |
| 11:46 | chouser | fractal applets, custom RPC protocol |
| 11:46 | Dranik | chouser, ok, thanks :-) |
| 11:46 | chouser | swing gui |
| 11:47 | Dranik | chouser, btw, is any of your clojure code available anywhere? or maybe you coud share some? |
| 11:47 | fbru02_ | Dranik: many people are using clojure in the bigdata niche |
| 11:47 | Dranik | I just try to lear clojure |
| 11:47 | chouser | Dranik: I have a bunch in contrib and on github |
| 11:48 | Dranik | fbru02_, yep, I see. Clojure is really good at concurrent programming |
| 11:48 | replaca | chouser: didn't you write some kind of book filled with great examples? :) |
| 11:48 | chouser | oh, right, IRC log to web site converter. |
| 11:49 | chouser | replaca: yeah, it's a great language to use for examples in a Clojure book! |
| 11:49 | tonyl | brehaut: ping |
| 11:49 | Dranik | chouser, could you please share some links and the book? |
| 11:50 | Dranik | I've just searched through github and there are really many links with "chouser" strings there... so I've got lost |
| 11:50 | chouser | Dranik: http://joyofclojure.com/ FETCH parties IS demo.parties |
| 11:50 | chouser | FOR party IN parties |
| 11:50 | chouser | HAVING party.name = \"Old Timers\" |
| 11:51 | chouser | doh |
| 11:51 | chouser | sorry |
| 11:52 | chouser | Dranik: http://joyofclojure.com/ http://tinyurl.com/fingertree https://github.com/Chouser/textjure https://github.com/Chouser/data-munge https://github.com/Chouser/clojure-irc-log https://github.com/Chouser/clojure-jna https://github.com/Chouser/clojure-classes |
| 11:52 | Dranik | chouser, thanks a lot! |
| 11:53 | fbru02_ | into-array converts a seq into an array, is there a way to make a seq from an array ? |
| 11:53 | chouser | Dranik: contrib is full of interesting and primarily high-quality code, too |
| 11:53 | replaca | chouser: hey, do you know when we're going to see the dead-tree version of JoC? |
| 11:53 | chouser | fbru02_: seq |
| 11:53 | chouser | replaca: soon. Maybe January? |
| 11:53 | fbru02_ | chouser: don't know why i didn't try that :D |
| 11:54 | chouser | :-) |
| 11:54 | replaca | chouser: excellent! Can't wait to have it on my shelf. Really nice discussion of records, types, and protocols there by the way |
| 11:54 | replaca | (among other things) |
| 11:55 | fbru02_ | yeah i thought it was coll -> seq , didn't know it worked with java arrays |
| 11:55 | chouser | replaca: thanks! |
| 11:55 | Dranik | chouser, clojure-jna -- wow! that's great! |
| 11:55 | replaca | fbru02_: seq is the (almost) universal magic function |
| 11:55 | fbru02_ | thanks ! |
| 11:56 | chouser | fbru02_: also strings, iterators, etc. |
| 11:56 | chouser | Dranik: there is a much more industrial-strength lib out there if clojure-jna's features are too thin for you: clj-native |
| 11:58 | Dranik | chouser, yep, I'll give it a try! |
| 12:14 | Raynes | chouser: You're fairly performance savvy, aren't you? |
| 12:15 | Raynes | I'm curious as to what would be the absolute dirtiest, rawest, fastest way to write this in Clojure: https://gist.github.com/c1b5a16b6ea582ef85ba |
| 12:15 | chouser | Raynes: s is always a string? |
| 12:15 | Raynes | The idea is to just count the number of non-space characters in a string. |
| 12:15 | Raynes | I want the fastest possible thing I can get without using Java. |
| 12:16 | chouser | and this is on 1.3-alpha-something? |
| 12:16 | Raynes | 1.2.0, but I'd be interested in 1.3-alpha versions as well if they make an important difference. |
| 12:17 | chouser | it makes a difference in the code, not the potential speed, I think. |
| 12:18 | Raynes | I'm trying to see how close I can get to some Java algorithms I've seen. |
| 12:21 | Raynes | I've wrote a version using loop, but it leaves much to be desired at an average of 138168.371 to run on a 460 character string 1000 times. |
| 12:21 | Raynes | The fastest Java solution I saw ran at just under 3000 nanoseconds. |
| 12:22 | chouser | hm, I'm not sure how to do primitive char equality |
| 12:23 | amatos | In clojure.test what is the equivalent of JUnit's assertEquals(double, double, delta)? Basically comparing doubles but passing a small delta because doubles are never exact? |
| 12:27 | chouser | Raynes: I think the problem might be that char comparison. I can't think of a way to check the equality of chars without autoboxing them. |
| 12:28 | Raynes | :\ |
| 12:29 | chouser | hmm... |
| 12:32 | chouser | (defn count-num-chars [^String s] (let [len (.length s), space (int 32)] (loop [i (int 0), c (int 0)] (if (< i len) (recur (inc i) (if (== (.codePointAt s i) space) c (inc c))) c)))) |
| 12:33 | chouser | I've done no profiling of that, but it ought to produce bytecode that deals only with primitives and does no reflection |
| 12:33 | Raynes | chouser: Runs slower than my loop version. |
| 12:33 | chouser | noooo |
| 12:33 | Raynes | Marginally. :p |
| 12:33 | chouser | good thing I shrugged in the first place. :-) |
| 12:33 | chouser | what's yours? |
| 12:34 | Raynes | https://gist.github.com/51073bc37369fcda9368 |
| 12:34 | Raynes | Nothing special at all, actually. |
| 12:35 | Raynes | I wrote an example with reduce that runs around the same time as yours does. |
| 12:35 | chouser | hm, I must have missed something in mine then. |
| 12:35 | Raynes | More eye watering code? :p |
| 12:35 | chouser | oh |
| 12:35 | chouser | #^String |
| 12:36 | chouser | you probably caught that already? |
| 12:36 | Raynes | Nope, did the same thing in my example as well. |
| 12:36 | Raynes | Doesn't seem to make a difference though. |
| 12:37 | chouser | hm, I guess 1.2 already supported ^ for tagging |
| 12:37 | Raynes | I thought so. I was already googling to make sure. |
| 12:38 | chouser | I suppose .codePointAt might be slow |
| 12:39 | chouser | performance questions might do better on the google group |
| 12:40 | Raynes | I'm not sure I care enough to bother the group with it. |
| 12:40 | Raynes | It's a trivial example that I was just obsessing over. |
| 12:40 | chouser | I bet there are people on the group who would enjoy it. |
| 12:41 | Raynes | You have a point. I guess I'll go ahead and post it and see what I can get. |
| 12:41 | Raynes | Thanks for trying. <3 |
| 12:41 | chouser | :-) sorry I didn't help |
| 12:42 | Raynes | Well, you did help. It was a demonstration that "Hey, even though I'm obviously much smarter than you, even I could come up with a speedy example." |
| 12:42 | Raynes | (inc ego) |
| 12:42 | sexpbot | ⟹ 1 |
| 12:43 | chouser | Raynes: are you using a profiler? |
| 12:44 | Raynes | No. Just a bit of code that checks the current nanotime, runs the code 1000 times, and then checks the nanotime again. |
| 12:44 | amalloy | Raynes: wouldn't it be faster to convert the string to a byte[] first? |
| 12:45 | Raynes | amalloy: If you think you can implement it faster, go for it. I'm interested in all sorts of fun ideas. :> |
| 12:47 | gtrak | (inc nil) |
| 12:47 | sexpbot | ⟹ 1 |
| 12:48 | gtrak | (nil) |
| 12:50 | clizzin_ | is there a way to take a sequence of lazy sequences and make one lazy sequence that iterates through each of the elements of those lazy sequences in turn? basically, i'd like to (apply lazy-cat foo) where foo is a sequence of lazy sequences, but unfortunately i can't apply a macro. |
| 12:51 | chouser | (apply concat foo) should do what I you want, I believe. |
| 12:52 | amalloy | clizzin_: or mapcat before you get those lazy sequences: ##(mapcat range [5 6]) |
| 12:52 | sexpbot | ⟹ (0 1 2 3 4 0 1 2 3 4 5) |
| 12:52 | chouser | the only what that lazy-cat is more lazy than concat is that because concat is a function, it's arguments will normally all be evaluated first. |
| 12:52 | chouser | but apply itself is lazy, so you should be ok |
| 12:53 | clizzin_ | amalloy, chouser: great info, thanks! |
| 13:09 | Raynes | chouser: Switching to using unchecked-inc in your version gives me an extreme speed increase. |
| 13:09 | Raynes | rayne@ubuntu:~$ cake run ~/challenge.clj |
| 13:09 | Raynes | Chars outputted: 460 |
| 13:09 | Raynes | Time (in nanoseconds): 5711.932 |
| 13:10 | tomoj | (.start (Thread. (fn [] (loop [] (.read stream (byte-array (.available stream))) ())))) |
| 13:10 | tomoj | that makes no sense, right? |
| 13:13 | tomoj | the loop form can be removed, and the empty list at the end as well if the return value is ignored? (.start (Thread. (fn [] (.read stream (byte-array (.available stream)))))) ? |
| 13:13 | Raynes | chouser: I also changed .codePointAt to be (int (.charAt ..)), because .codePointAt was a huge bottleneck. |
| 13:17 | clizzin_ | hmm so the behaviour i was attempting to achieve is to create a lazy sequence on top of a sequence of readers. so i have a function (defn datum-seq [filenames] (mapcat (comp line-seq clojure.java.io/reader) filenames)). and then i have a function foo that iterates through a sequence and updates a transient map as it goes. my hope was to have the iteration through lines in the files be such that it discards files (or even b |
| 13:17 | clizzin_ | lines) from memory as soon as it's done with them, but i'm seeing linear growth in memory as foo iterates through the sequence that suggests that the file contents are being cached. anyone have any ideas on how i can achieve the behaviour i'm looking for? thanks in advance! |
| 13:23 | amalloy | clizzin_: garbage collection only runs when it's needed. if you have enough memory to keep it all cached, the gc won't bother cleaning it up even if clojure has thrown away all references to the earlier stuff |
| 13:24 | technomancy | clizzin_: you need to use with-open for readers; this doesn't play nicely with laziness. |
| 13:25 | amalloy | clizzin_: see http://blogs.msdn.com/b/oldnewthing/archive/2010/08/09/10047586.aspx for an interesting take on this, even if it is from a CLR perspective |
| 13:28 | clizzin | amalloy, technomancy: hmmm. ideally, i'd like to create a sequence abstraction over all the lines of these files so that foo can take any sequence of data as input. it sounds like this isn't possible without manually opening/closing each file as the iteration starts/finishes with that file's lines, but how can i have the resulting function be treated as a sequence? i come from a python background, so the best way i can expl |
| 13:28 | clizzin | what i'm trying to achieve is the equivalent of a python generator. |
| 13:28 | clizzin | also feel free to let me know if i'm thinking about this all wrong |
| 13:30 | clizzin | my main concern is that i can't hold all of the data in these files in memory at once, so i thought making a lazy sequence on top of the readers would avoid caching the contents of multiple files at once. |
| 13:52 | leif-p | Hi, all. Is there a clojure json lib that accepts all legal json? c.c.json/read-json seems to take only a subset. |
| 13:52 | Raynes | $google clj-json |
| 13:52 | sexpbot | First out of 459 results is: mmcgrana/clj-json - GitHub |
| 13:52 | sexpbot | https://github.com/mmcgrana/clj-json |
| 13:52 | Raynes | That probably does. |
| 13:53 | Raynes | It wraps a Java JSON lib though, so it isn't a pure Clojure implementation. |
| 13:55 | chouser | clizzin: having a lazy seq close an underlying resource (like a file) when it is fully consumed is generally considered fragile, because of how often lazy seqs in general are abandoned before being fully consumed. |
| 13:56 | chouser | clizzin: but in your case, it may be less objectionable since you should be able to guarantee that no more than one file is open at a time. |
| 14:03 | raek | leif-p: what does it not accept? |
| 14:07 | technomancy | apparently clj-time has not released any stable versions; what's up with that? ಠ_ಠ |
| 14:08 | leif-p | raek: maps with numeric keys. Hmm... I'm just assuming that's legal json, let me check. And while it technically accepts maps with any string keys, the fact that it automatically converts them all to keywords means the result is hard to use if any of the keys contain clojure special characters. |
| 14:10 | raek | the awesome syntax diagram of http://json.org/ suggests that it isn't allowed to have numbers as keys in json |
| 14:11 | raek | leif-p: you can turn off the keywordization of you like |
| 14:12 | raek | or you can construct keywords from strings ##(keyword "\u2603") |
| 14:12 | sexpbot | ⟹ :☃ |
| 14:13 | raek | (unicode snowman) |
| 14:14 | raek | but yeah, keywordization is perhaps not always a good idea |
| 14:14 | raek | ,(doc read-json) |
| 14:14 | clojurebot | Gabh mo leithscéal? |
| 14:14 | raek | &(doc read-json) |
| 14:14 | sexpbot | java.lang.Exception: Unable to resolve var: read-json in this context |
| 14:15 | raek | &(use clojure.contrib.json) |
| 14:15 | sexpbot | java.lang.ClassNotFoundException: clojure.contrib.json |
| 14:17 | leif-p | raek: You're right, I am looking at that right now. I guess I am using json wrong. Unfortunately, when almost all json libraries dump to string, they fix my mistake, and js might be doing some str->num magic. :( |
| 14:22 | dnm | technomancy: Hey there. |
| 14:23 | dnm | technomancy: Quick question. Are you still in Seattle? I happened to be perusing the careers section of the Sonian website, and it seems all the open positions are in Boston. Is there still a telecommute option available for certain roles? |
| 14:29 | technomancy | dnm: all our engineering roles are telecommute, but I'm not sure if we are actively looking for Clojure hackers right now. I'll ask. |
| 14:34 | dnm | technomancy: Ah, I see. Thanks for asking! It happened to be an interesting conincidence, as I was just mentioning elsewhere (#dylan) that I missed Boston and would consider moving there second to moving to Seattle, but didn't know what I would do in Boston. And last I knew, you, anyway, were in Seattle with Sonian. I didn't know they were Boston-based. |
| 14:35 | technomancy | we hire wherever there's talent |
| 14:36 | technomancy | I'm in Seattle, but I work with people all over the place. |
| 14:36 | technomancy | are you in Seattle? |
| 14:37 | dnm | No. Currently I'm in the D.C. area. |
| 14:37 | dnm | But I have plans to move to Seattle. |
| 14:37 | technomancy | it's great; I love it |
| 14:38 | technomancy | see also http://seajure.technomancy.us of course |
| 14:38 | dnm | Is the picture of the bench that showed up on Fogus's interview of you from Green Lake? |
| 14:38 | dnm | Or elsewhere? |
| 14:38 | fogus` | dnm: Have you been out to any of the NOVA Clojure meetups? |
| 14:39 | dnm | fogus`: Sadly no, they're all out in Reston, and I am never out that far. I live carless in Arlington, and I work in downtown D.C. during the day. |
| 14:39 | dnm | fogus`: Would like to meet up with local Clojure hackers though. |
| 14:40 | technomancy | dnm: that's a park across the street from my house, but I love working from the shores of Green Lake in the summer =) |
| 14:40 | technomancy | dnm: http://www.flickr.com/photos/technomancy/4798518932/ |
| 14:40 | fogus` | dnm: People are usually willing to do drop/pick at local metro stations |
| 14:40 | dnm | technomancy: Intensely envious. ;] Looking at apartments on padmapper.com, it seems I can find a place in Seattle or surrounding areas for less than I pay here, which seems like a win/win! |
| 14:41 | technomancy | dnm: my remoteoffice flickr feed is a covert Sonian recruitment mechanism. |
| 14:41 | technomancy | not as effective in the Winter though =( |
| 14:41 | dnm | fogus`: Yeah, which is very nice of them. Usually they also start too early for me to make it from work. I think lately I've seen start times of around 7 PM. I usually don't leave work until 6:30 or so, depending. |
| 14:41 | dnm | s/they/the meetups/ |
| 14:41 | sexpbot | <dnm> fogus`: Yeah, which is very nice of them. Usually the meetups also start too early for me to make it from work. I think lately I've seen start times of around 7 PM. I usually don't leave work until 6:30 or so, depending. |
| 14:42 | dnm | fogus`: One of these days, maybe. Do you know of any Arlington or D.C. proper Clojure hackers? I'd love to do something even less formal than a capital-M meetup. |
| 14:42 | fogus` | dnm: Too bad. If the time is ever not a factor then ping the meetup page. I'm certain someone will volunteer as chauffeur. ;-) |
| 14:43 | fogus` | dnm: Surprisingly DC/VA/MD seems to be a hotbed of Lispiness |
| 14:43 | chouser | Fort Wayne too |
| 14:43 | dnm | technomancy: Seattle's great attraction for me is to escape humid Virginia summers. |
| 14:43 | chouser | in my dreams |
| 14:44 | dnm | technomancy: Well, one of the great attractions anyway. |
| 14:44 | fogus` | The author of Land of Lisp lives in DC and he used to run the DC Fringe group. He might (hoping) restart those meetups again |
| 14:44 | chouser | in reality, Fort Wayne is a hotbed of military radio engineering. |
| 14:44 | dnm | Conrad, yeah! I know Conrad. FringeDC's been kinda dormant for a while. |
| 14:44 | Crowb4r | Fort Wayne IN? |
| 14:45 | chouser | yessir |
| 14:45 | dnm | The last FringeDC meeting I went to was a talk on ML from a then-local company making their product in it. That was a few years back. |
| 14:45 | Crowb4r | chouser: heh, I'm not that far from you then |
| 14:46 | Crowb4r | <- Western Michigan |
| 14:48 | chouser | Crowb4r: cool |
| 14:49 | chouser | I keep meaning to go to one of the ohio clojure meetups |
| 14:49 | Crowb4r | far in perspective to some I suppose.. |
| 14:49 | chouser | Crowb4r: this is the midwest. < 4 hours drive is close |
| 14:49 | Crowb4r | I should drive down for that. there is a Detroit group that just started. I need to look at Chicago as well. |
| 14:49 | chouser | in Europe that might require a passport, but here it's just "going in to town" |
| 14:50 | Crowb4r | yeah |
| 14:50 | chouser | Crowb4r: I talked at the Chicago one once -- nice folks. But it takes too long to do regularly |
| 14:50 | Crowb4r | I'm in Holland, right on Lake Michigan so pretty much I can only go east or south for 4 hours to hit anything (but Grand Rapids) |
| 14:51 | pjstadig | dnm: i'm also in the DC area, and i work for Sonian |
| 14:51 | dnm | pjstadig: Hi there! |
| 14:57 | dnm | fogus`: Are you in the area? |
| 14:58 | fogus` | dnm: Indeed |
| 14:59 | dnm | fogus`: Ah, neat! |
| 15:01 | pjstadig | fogus` has presented at the clojure group several times |
| 15:11 | brehaut | morning |
| 15:30 | AWizzArd | brehaut: good evening brehaut |
| 15:30 | brehaut | AWizzArd: clearly i forgot my timezone again |
| 15:30 | AWizzArd | 21:32 in Germany |
| 15:31 | brehaut | 09:32 in new zealand |
| 15:31 | AWizzArd | So, middle Earth is on the other side of the world :) |
| 15:31 | brehaut | yup :) |
| 15:32 | dnm | brehaut: Where are you in NZ? |
| 15:33 | brehaut | dnm hamilton |
| 15:33 | AWizzArd | How far away is that from Hobbingen? |
| 15:33 | dnm | Ah. I converse regularly with a Dylan developer in Wellington. |
| 15:33 | brehaut | AWizzArd: maybe half an hour |
| 15:33 | brehaut | dnm: there are still dylan developers?! |
| 15:34 | dnm | Yes. We're a rare breed, I guess ;] |
| 15:34 | brehaut | dnm: i guess. pretty cool though |
| 15:34 | dnm | Not only that, there's another Dylan developer who uses Clojure regularly. |
| 15:35 | brehaut | i guess if you are going to use one relatively unknown language, why not use 2 |
| 15:35 | dnm | Heh. |
| 15:41 | brehaut | fogus`: ping? |
| 15:44 | fogus` | pong |
| 15:45 | brehaut | fogus`: i tried to tweet a bug report at you but twitter is doing weird nonsense. anyway, xml-> is getting rendered as xml-> while -> is still -> |
| 15:47 | fogus` | brehaut: Thanks will look into that |
| 15:47 | brehaut | fogus`: ive also got a curious case where marginalia is thinking that the body of a condp is code to output verbatim in the doc side of the uberdoc |
| 15:48 | fogus` | brehaut: Do you mind creating a case at https://github.com/fogus/marginalia/issues with a link to the code you're trying to operate on? |
| 15:48 | brehaut | sure thing |
| 15:48 | fogus` | Thank you! |
| 15:48 | brehaut | not a problem |
| 15:57 | brehaut | fogus`: https://github.com/fogus/marginalia/issues/#issue/4 |
| 16:04 | fogus` | brehaut: The dangers of regex! Thanks again. Gotta run, but it should be fixed some time today |
| 16:04 | brehaut | fogus`: not a problem. cheers |
| 16:43 | brehaut | (inc tonyl) |
| 16:43 | sexpbot | ⟹ 1 |
| 17:19 | raek | oh, java... http://www.youtube.com/watch?v=wDN_EYUvUq0 |
| 17:19 | raek | interesting though... |
| 17:30 | raek | &(= (.hashCode "polygenelubricants") (Integer/MIN_VALUE)) |
| 17:30 | sexpbot | ⟹ true |
| 17:31 | brehaut | raek: what the?! |
| 17:32 | raek | (see the video...) |
| 17:32 | raek | also: |
| 17:32 | raek | (Math/abs (Integer/MIN_VALUE)) |
| 17:32 | raek | &(Math/abs (Integer/MIN_VALUE)) |
| 17:32 | sexpbot | ⟹ -2147483648 |
| 17:32 | brehaut | i havent, my internet connections incredibly lame today |
| 17:32 | raek | hrm |
| 17:34 | raek | ah, Raynes's long decorative arrow hid the minus sign... |
| 17:34 | raek | so, yupp. the abs function can return a negative value |
| 17:35 | brehaut | so strange |
| 17:35 | raek | since there are one more negative Integer than positive |
| 17:36 | brehaut | ah true |
| 17:36 | raek | hrm, why did using that static field as a method work? |
| 17:36 | raek | &(Math/abs Integer/MIN_VALUE) |
| 17:36 | sexpbot | ⟹ -2147483648 |
| 17:37 | raek | &(Integer/MIN_VALUE) |
| 17:37 | sexpbot | ⟹ -2147483648 |
| 18:08 | joshua__ | amalloy, the plugin is pretty much done =) XML worked wonderfully. The only thing that needs to be fixed at the moment is this really dumb bug. Basically there is a file where you specifcy what amounts to a config page and even though I changed that file it is still compiling as if I had not changed it.. anyways that is not why I came here.. |
| 18:08 | joshua__ | Trying to connect to mongodb is giving me a network exception error. |
| 18:09 | joshua__ | Any idea where the problem might be? |
| 18:09 | amalloy | joshua__: $ sudo mongod, is what usually fixes it for me |
| 18:09 | amalloy | ISTR i fixed something in my etc/init.d or thereabouts to get this to stop happening, let me see if i can find it |
| 18:10 | joshua__ | Wed Dec 22 15:10:50 exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating |
| 18:10 | joshua__ | That doesn't look right.. |
| 18:12 | joshua__ | It is actually happening in my command line too. |
| 18:12 | joshua__ | Not just when I start up swank |
| 18:12 | amalloy | joshua__: are you root? permission-denied errors often look like not-found errors to java |
| 18:12 | amalloy | this is to start the server, not to connect to it |
| 18:12 | joshua__ | amalloy, I didn't grok what you said? |
| 18:13 | joshua__ | oh |
| 18:13 | joshua__ | yea I rank sudo mongod |
| 18:43 | zkim | Is there any way to clone a java class in clojure? I'd like to muck with a static member on a class (specifically c.l.LispReader), but I don't want to interfere with the operation of other consumers. |
| 19:19 | programble | um |
| 19:20 | programble | cake isn't working |
| 19:20 | programble | i run it and after a while it says it's taking long to connect to the JVM, but it never starts a JVM |
| 19:21 | ninjudd | programble: i need more information than that. which version are you using? how did you install it? etc... |
| 19:22 | programble | 0.5.8 from gem |
| 19:23 | programble | oh it works if i'm not in a project dir... |
| 19:23 | programble | but fails in my clone of penumbra |
| 19:23 | ninjudd | programble: ah |
| 19:23 | ninjudd | you have to upgrade to the latest cake to use penumbra |
| 19:24 | ninjudd | i just fixed that yesterday actually |
| 19:24 | ninjudd | use the "Git repository" installation method from https://github.com/ninjudd/cake |
| 19:25 | ninjudd | lancepantz was working on adding cake tasks for the penumbra examples actually |
| 19:26 | lancepantz | jees, i can't tell if it's penumbra or cake gaining in popularity :) |
| 19:27 | lancepantz | programble: but yeah, i have some commits i'm queueing up for https://github.com/lancepantz/penumbra i'll push later today |
| 19:27 | ninjudd | programble: you're the second person to ask about using penumbra with cake in the past two days. and nobody ever asked before that |
| 19:27 | programble | well i'm just looking at penumbra cuz i'm bored |
| 19:29 | ninjudd | that explains it! |
| 19:29 | programble | and i'm using cake because it is apparently "oh so much" better than lein |
| 19:29 | programble | guys |
| 19:29 | programble | on every run of cake i get this: |
| 19:29 | programble | $ cake |
| 19:29 | programble | which: invalid option -- 's' |
| 19:30 | programble | /usr/bin/wget |
| 19:30 | ninjudd | doh |
| 19:30 | ninjudd | that's from a commit i just added. i guess that is an os x only opt |
| 19:30 | ninjudd | fixing |
| 19:31 | ninjudd | programble: fixed |
| 19:32 | programble | OH MY GOD HOW DO I CLOSE THE PONG EXAMPLE |
| 19:32 | ninjudd | hahah |
| 19:32 | ninjudd | did you start it with cake? |
| 19:32 | programble | i started it from a cake repl |
| 19:32 | ninjudd | you exited the repl? |
| 19:32 | ninjudd | 'cake kill' will work |
| 19:33 | ninjudd | on os x, clicked the 'x' on the window works too |
| 19:33 | programble | it doesn't get a window border here |
| 19:33 | ninjudd | oh no |
| 19:34 | ninjudd | ctrl-c in the repl |
| 19:34 | ninjudd | if it is still running after that, 'cake kill' |
| 19:35 | programble | do not understand opengl at all |
| 19:40 | clizzin | if i pass a lazy sequence as an argument to a function that uses it only for the first instruction, do all the realised members of the lazy sequence stay in memory until the function exits? or is the sequence garbage collected after the last use of it? |
| 19:41 | technomancy | clizzin: as long as you're on 1.2 or newer, you're clear after the last use. |
| 19:42 | technomancy | "fine-grained locals-clearing", in the vernacular |
| 19:43 | clizzin | technomancy: cool, thanks for the information. is there any way to tell the lazy seq not to bother caching realised members? |
| 19:43 | clizzin | i've got a case where the cost of computing the sequence members is cheap but there are a whole lot of them, so i don't want them to be cached in memory |
| 19:43 | technomancy | clizzin: no, you have to ensure references to the head are GC'd |
| 19:46 | clizzin | technomancy: hmm okay. what is the behaviour of a lazy sequence if iterated over using loop? are the members still cached?, e.g. (loop [i (lazy-seq foo)] ...)? |
| 19:47 | technomancy | clizzin: depends. if you recur on (rest i) you're probably clear. |
| 19:48 | technomancy | you can construct a test with an infinite seq to be sure |
| 19:51 | clizzin | technomancy: interesting. so my situation is that i'm doing (foo (lazy-seq...)) where foo is (defn foo [s] (bar s)) and bar is (defn bar [s] (loop [sequence s] ... (recur (rest s))). it sounds like keeping things decomposed into separate functions like this would result in all the members of the lazy sequence getting cached because the foo and bar scopes retain references to the head. |
| 19:51 | clizzin | so now i'm tempted to mash them all into one big function so that the lazy sequence is passed directly into the loop. |
| 19:52 | clizzin | or is clojure smart enough to figure out that this chain of calls ends with a loop that recurs on (rest s)? |
| 19:53 | mabes | how could I tell if a certain deftype/defrecord implements a fn.. you can use satisfies? to see if it "implements" the protocol, but I've noticed that def[record|type] does not enforce a method be defined for each signature |
| 19:53 | technomancy | clizzin: I suspect it will be smart enough, but you will need to confirm this with Science. |
| 19:53 | clizzin | technomancy: Science! |
| 19:53 | technomancy | clizzin: http://www.topatoco.com/merchant.mvc?Screen=PROD&Store_Code=TO&Product_Code=DC-BISCUIT&Category_Code=DC |
| 19:53 | mabes | I know you can look at the protocol and that the methods should live on it somewhere, but I'm having a hard time finding them |
| 19:53 | clizzin | alright, time to give it a shot. thanks for the help! |
| 19:54 | clizzin | technomancy: haha nice |
| 19:54 | technomancy | np |
| 19:59 | joshua__ | Is there a way to tell congomongo to declare an index on a key? |
| 19:59 | joshua__ | declare/create |
| 20:00 | joshua__ | or do I need to do that within mongodb itself |
| 20:05 | mids | joshua__: add-index! |
| 20:07 | joshua__ | thanks! |
| 20:15 | joshua__ | mids, any idea where I can get more thorough documentation of congomongo? |
| 20:22 | joshua__ | Best I've seen: http://clojuredocs.org/incanter/1.2.3-SNAPSHOT/incanter.mongodb |
| 20:35 | joshua__ | Where can I find info on query maps for mongodb? |
| 20:59 | arohner | does anyone have any good tricks for figuring out what part of performance problems are caused by cache misses? |
| 21:33 | datka | Are multimethods supposed to hold on to their dispatch fn, or is it possible to change that function dynamically. I made a change to my dispatch fn, and it wasn't picked up. (1.3) |
| 21:33 | amalloy | datka: i don't know what is "supposed" to happen, but that is the behavior in 1.2 also |
| 21:34 | datka | it's probably by design and for performance reasons, but it's a bit annoying |
| 21:34 | amalloy | agreed |
| 21:39 | pdk | oh snap is 1.3 out |
| 21:40 | tomoj | I don't see it |
| 21:40 | joshua__ | (GET "/item?id=:id" [id] (archive-item id)) Why is this not matching /item?id=2312312? |
| 21:41 | datka | I'm jumping the gun on upgrading to 1.3, it's not out yet. (unless I missed something) |
| 21:44 | joshua__ | To answer my own question the ?id is being treated as a get parameter. |
| 22:01 | brehaut | anyone here know much about moustache ? |
| 22:05 | bhenry | brehaut: depends on how much |
| 22:05 | brehaut | bhenry: how easy is it to use moustache's pattern matcher outside of moustache |
| 22:06 | bhenry | brehaut: uhh. i've only ever used it the standard way. what are you trying to do? |
| 22:06 | brehaut | bhenry: minimise the amount of repetition in a pingback implementation |
| 22:07 | brehaut | bhenry: pingback is xml-rpc which means it tunnels through http and then dispatches itself based on the method not the resource |
| 22:07 | brehaut | but pingback also has to check that the resource being pinged back exists |
| 22:09 | bhenry | brehaut: well i guess i'm not the man for this, but moustache is only one file, so you should take a look at it. https://github.com/cgrand/moustache/blob/master/src/net/cgrand/moustache.clj |
| 22:09 | brehaut | bhenry: that was my next step. |
| 22:13 | brehaut | judging by the number of private functiosn that i think i would need, i might be screwed |