2010-05-31
| 04:33 | LauJensen | Morning all |
| 04:34 | Quiesce | Hello |
| 04:37 | bobo_ | is there any webframework for clojure that separates the view as strongly as lift/wicket? ie, you cant write any logic at al in it. |
| 04:39 | Fossi | why can't you do that in wicket? |
| 04:39 | Fossi | you mean the html template? |
| 04:39 | bobo_ | yeh, you can separate it entierly if you want to |
| 04:40 | Fossi | hmmm. haven't seen a templating framework yet |
| 04:42 | bobo_ | could probably use wicket, i think il have a look at that |
| 04:46 | Fossi | bobo_: if you do i'd be interested how that feels |
| 04:46 | tomoj | with enlive, you have the html in a separate file |
| 04:46 | tomoj | then write some clojure which transforms the html |
| 04:47 | tomoj | no clojure in the html files at all |
| 04:47 | LauJensen | Fossi: Did you see my latest blogpost? |
| 04:47 | LauJensen | I've built bestinclass.dk entirely on Enlive templates and the Moustache micro-webframework, meaning 100% separation of logic and html/css |
| 04:47 | Fossi | LauJensen: nope, could you link? |
| 04:48 | LauJensen | http://bestinclass.dk/index.clj/2010/05/refresh-your-cache--best-in-class-has-been-baked.html |
| 04:50 | Fossi | jupp found it :) |
| 04:50 | Fossi | looks sane |
| 04:50 | LauJensen | Thats a plus |
| 04:51 | Fossi | but still i wonder what wicket feels like from clojure. i used them both for zuite a while, but never together |
| 04:51 | Fossi | *quite |
| 04:51 | unfo- | LauJensen, oh cool! thanks for link |
| 04:52 | LauJensen | np |
| 04:52 | LauJensen | And I really should hurry up and opensource the code, it has a Wordpress -> Hthml converter, Atom feed generator, backend for posting and moderating comments |
| 04:56 | unfo- | what was this format-> [:body :> any-node] |
| 04:57 | LauJensen | Its selectors, similar to CSS but prefixed with :, so body > any-nody, means match any node directly under a body tag |
| 04:58 | unfo- | aaah css-style |
| 04:58 | LauJensen | http://enlive.cgrand.net/syntax.html |
| 04:59 | unfo- | ah thanks |
| 04:59 | unfo- | and also... my clj-fu has been written to swap in mah brainz |
| 04:59 | unfo- | >_> |
| 05:00 | unfo- | need to reapply learning ^_^ |
| 05:20 | rava | greetings programs |
| 08:49 | dnolen | hmm if I want to extend-type int[] how can I refer to that as a class ? |
| 08:59 | spariev | hi, I need a function which takes a list of pairs on ints and 'concat' neighbour pairs together, ie ([0 2] [2 4]) becomes ([0 4]) |
| 08:59 | spariev | here's my take http://gist.github.com/419810 |
| 09:00 | spariev | could it be made more simpler ? |
| 09:04 | candera | spariev: You could partition and then do a destructuring binding against the result. |
| 09:04 | candera | Although I'm not entirely sure what algorithm you're trying to implement. |
| 09:05 | Licenser_ | spariev: you don't have all specs, what happens if neighboring pairs do not match? |
| 09:07 | spariev | Licenser_: you just leave them as they were, ie ([2 4] [6 7]) => ([2 4] [6 7]) |
| 09:11 | candera | So is it equivalent to flattening it and then removing any duplicates? Or will you ever wind up with pairs that have two elements the same? |
| 09:13 | spariev | I need this to corrently build a Lucene query with OR clauses. I have a vector with conditions, which can contain :or , like ["foo" "bar" :or "baz" :or "biz" "chunky bacon"] |
| 09:14 | spariev | So I have to structure this vector into something like ["foo" [:or "bar" "baz" "biz"] "chunky bacon"] |
| 09:15 | bartj | spariev: I thought ([2 4] [6 7]) would give ([2 7] [4 6]) - care to explain the definition of "neighbourhood"? |
| 09:20 | spariev | bartj: it seems like I was quite unclear, my apologies. by the "neighbour pairs" I meant pairs like [2 4][4 6] , where the last item of first pair is equal to the first item of next pair |
| 09:21 | spariev | candera: yep, you are right, flatten and remove duplicates will suffice |
| 09:21 | spariev | thanks all, sorry for the unclear question |
| 09:23 | candera | spariev: Are you sure? If you flatten and remove dups from [0 2] [2 4] [4 4] [4 6], you'll get [0 6] |
| 09:23 | candera | Is that what you want? |
| 09:23 | spariev | yes, there wont be pairs like [4 4] |
| 09:24 | candera | OK. Was playing with the underlying problem (queries with :or) but didn't get anywhere. |
| 09:29 | spariev | candera: thanks. my idea is to find indices of all conditions with :or near them, so ["foo" "bar" :or "baz" :or "biz" "chunky bacon"] will give [1 3] [3 5] |
| 09:29 | candera | I see. |
| 09:30 | candera | I was going at it from the direction of partitioning the original sequence with overlap, and looking at whether the subsequence has :or in it. |
| 09:31 | candera | Yours makes sense to me. But then again I fully expect someone else to say, "Oh, you just call these two functions on the original sequence." :) |
| 09:32 | spariev | candera: heh, completely forgot about overlap param in partition. that's the solution I'm looking for :) thanks |
| 09:33 | candera | I'll be curious to see your final code. |
| 09:34 | spariev | ok, I'll update gist when it will be ready |
| 10:33 | lessthantristan | i'm putting together a job queue. i have a ref counting the number of running jobs, and a (ref []) for the queue of waiting jobs. since i'm doing things like (if (> max-jobs @running-jobs) ... (dosync (alter ...))) in my add-job and finish-job, i should be wrapping the whole function in a dosync rather than just the bits where the refs are altered, correct? |
| 10:34 | opqdonut | yeah |
| 10:35 | opqdonut | otherwise you can accidentally go over the maximum job number |
| 10:39 | lessthantristan | cool thanks. are all dosync calls linked, or is each one managed separately? i'm worried that my different add and finish job functions, which both read and manipulate the refs still might cause concurrency issues |
| 10:40 | lessthantristan | hmm. maybe some testing is required, i'm seeing lots of possible future problems with what i'm trying to do :) |
| 10:48 | Licenser_ | lessthantristan: if you have multuiple dosync calls within eachothyer they all count as one transaction |
| 10:58 | spariev | candera: here's what I finally came up with - http://gist.github.com/419810 |
| 10:58 | spariev | feels kinda wordy, but works |
| 10:58 | spariev | I tried to do it via partition with overlap, but decided to stick with my original idea in the end |
| 10:58 | Chousuke | more succinctly put: transactions have dynamic scope |
| 12:09 | SinDoc | [naïve] How can I use the bindings provided e.g. here [1] in another file? |
| 12:09 | SinDoc | [1] http://github.com/sindoc/algorithms/blob/master/src/main/clojure/whiteboard/y2010/hide-adt-state/datatype-01.clj |
| 12:27 | cgrand | SinDoc: add (:require [com.khakbaz.algorithms.clojure.whiteboard.y2010.hide-adt-state.datatype-01 :as d]) to the ns declaration in your other file |
| 12:27 | cgrand | then d/op-a will reference op-a etc. |
| 12:28 | SinDoc | How does Clojure know where to find the file where that namespace is defined? |
| 12:29 | bozhidar | same way as for java packages |
| 12:29 | cgrand | they must be on your classpath |
| 12:29 | bozhidar | the namespace reflects a particular |
| 12:29 | bozhidar | directory structure |
| 12:30 | bozhidar | the root of which should be available in the classpath |
| 12:30 | bozhidar | unless you have jar packaged code that is |
| 12:32 | SinDoc | Thank you, cgrand and bozhidar. |
| 12:48 | noidi | d |
| 12:49 | noidi | oops, didn't mean to write that :P |
| 13:14 | LaPingvino | hello |
| 13:14 | LaPingvino | hello Lau |
| 13:15 | LaPingvino | what was the date of that european Clojure stuff again, and where? |
| 13:15 | LauJensen | LaPingvino: June 23-25 in Brussels - All the details incl. schedule are on conj-labs.eu |
| 13:16 | hugod | I'm having problems modifying code at the repl - Could someone try entering http://gist.github.com/420007 at a 1.2-master-SNAPSHOT repl and comment on the result |
| 13:16 | LaPingvino | LauJensen: tnx :) |
| 13:18 | LauJensen | LaPingvino: np - Let me know if you need anything else :) |
| 13:18 | LauJensen | |
| 13:18 | LauJensen | |
| 13:18 | LauJensen | hugod: I see 'b' |
| 13:19 | hugod | LauJensen: thanks, what is the date on you snapshot? |
| 13:19 | LauJensen | hugod: can the repl tell me ? |
| 13:20 | LauJensen | Its 20100427.170231-51 |
| 13:20 | hugod | LauJensen: I'm seeing this on shapshots after around 20100521 |
| 13:22 | LauJensen | hugod: Time to roll out --bisect |
| 13:25 | hugod | LauJensen: thanks :) I'm also having issues with redefining multimethods; presumably related somehow |
| 13:26 | LauJensen | hmm |
| 13:26 | LauJensen | Fortunately you've got a simple way to test, so a bisect run shouldn't take long |
| 13:26 | hugod | Lunch first :) |
| 13:37 | Licenser | cooookies! |
| 13:51 | naeu | I'm just having a play with reify. I'm trying to reify a particular interface: http://users.frii.com/jarvi/rxtx/doc/gnu/io/SerialPortEventListener.html |
| 13:52 | naeu | However, I don't seem to be having much luck with the following: (reify gnu.io.SerialPortEventListener (serialEvent [e] (println "hi"))) |
| 13:53 | naeu | I get the error: "Can't define method not in interfaces: serialEvent" |
| 13:55 | LauJensen | hugod: HTH, bisect log http://gist.github.com/420075 |
| 14:13 | naeu | is there any way to inspect a Java interface from Clojure |
| 14:13 | naeu | it would be nice to see how Clojure sees a particular interface, i.e. what methods it thinks it requires to be implemented... |
| 14:13 | LauJensen | naeu: You can inspect anything Java using C-c I |
| 14:14 | tomoj | clojure.contrib.repl-utils/show |
| 14:14 | naeu | LauJensen: how cool is that! |
| 14:15 | LauJensen | naeu: Its pretty high on the list :) |
| 14:16 | naeu | OK, so it still doesn't explain why I can't reify this particular interface - the emacs inspection gizmo says that the interface has one method: serialEvent and my reification form just contains that |
| 14:17 | LauJensen | naeu: but its not your method being run ? |
| 14:18 | naeu | LauJensen: I'm trying to reify this: http://users.frii.com/jarvi/rxtx/doc/gnu/io/SerialPortEventListener.html |
| 14:18 | naeu | using this form: (reify gnu.io.SerialPortEventListener (serialEvent [e] (println "hi"))) |
| 14:18 | tomoj | naeu: the inspection gismo says serialEvent takes one param? |
| 14:18 | naeu | the gizmo says this: public abstract void gnu.io.SerialPortEventListener.serialEvent(gnu.io.SerialPortEvent) |
| 14:18 | tomoj | oh, maybe you need a self param for reify? |
| 14:19 | naeu | tomoj: that didn't fail... |
| 14:19 | LauJensen | Its been changed not too long ago I think, but reify takes an explicit this argument now |
| 14:19 | tomoj | I mean, try (serialEvent [l e] ...) |
| 14:19 | hugod | LauJensen: thanks for the bisect |
| 14:20 | LauJensen | n |
| 14:20 | LauJensen | p |
| 14:20 | naeu | interesting, it doesn't appear to be in the docs... |
| 14:20 | naeu | tomoj: heay, i tried (serialEvent [_ e] ...) |
| 14:21 | naeu | tomoj: s/heay/yeah |
| 14:21 | LauJensen | naeu: How are you determining that you're failing ? |
| 14:21 | naeu | LauJensen: Emacs is complaining when I eval it in slime |
| 14:22 | naeu | but if I add an initial anonymous param like tomoj suggested the eval completes successfully |
| 14:22 | tomoj | naeu: same error? |
| 14:22 | tomoj | ah, yes |
| 14:22 | LauJensen | naeu: tomojs suggestion is the correct form |
| 14:22 | tomoj | then what's the problem? :) |
| 14:22 | naeu | none, now, it seems :-) |
| 14:22 | naeu | i said it didn't fail :-) |
| 14:22 | tomoj | ah, I see |
| 14:22 | tomoj | the first parameter is the object itself |
| 14:22 | naeu | sure a this/self param |
| 14:22 | tomoj | the one which will have a .serialEvent method I mean |
| 14:23 | mrTrololo | Hi! Tell me please how can I use my "do" if I have something like this: (let [do println] ...) |
| 14:23 | naeu | right, i'm off out for a walk now, i'll get back to this later |
| 14:23 | naeu | thanks so much for the help LauJensen and tomoj |
| 14:23 | LauJensen | np |
| 14:23 | LauJensen | $(let [do println] (do "hello")) |
| 14:23 | sexpbot | => "hello" |
| 14:24 | mrTrololo | I mean do will work as println inside binding |
| 14:24 | LauJensen | Thats right |
| 14:25 | tomoj | no.. |
| 14:25 | tomoj | $(let [do +] (do 1 2)) |
| 14:25 | sexpbot | => 2 |
| 14:26 | tomoj | also.. |
| 14:26 | LauJensen | hmm |
| 14:26 | tomoj | $(let [do 3] do) |
| 14:26 | sexpbot | => nil |
| 14:26 | tomoj | :) |
| 14:26 | tomoj | I can explain the former but not the latter |
| 14:26 | LauJensen | I dont get that |
| 14:26 | tomoj | do is a special form |
| 14:27 | tomoj | so you can't replace it with let |
| 14:27 | tomoj | not sure why a lone do is allowed inside let, though.. I remember it being discussed here before but don't remember the explanation |
| 14:27 | tomoj | $(let [] do 3) |
| 14:27 | sexpbot | => 3 |
| 14:28 | tomoj | something to do with the implicit do I guess |
| 14:28 | LauJensen | I didn't consider that its a special form |
| 14:28 | LauJensen | And Im not sure why it needs to be |
| 14:28 | LauJensen | ,source do |
| 14:28 | clojurebot | java.lang.Exception: Unable to resolve symbol: source in this context |
| 14:28 | LauJensen | $source do |
| 14:28 | sexpbot | Command not found. No entiendo lo que estás diciendo. |
| 14:29 | tomoj | hrmmm |
| 14:29 | tomoj | $(let [let 3] let) |
| 14:29 | sexpbot | => 3 |
| 14:29 | tomoj | wat? |
| 14:29 | clojurebot | For Jswat: start clojure with -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888 |
| 14:29 | tomoj | let is a special form too |
| 14:29 | tomoj | so "do is a special form" is not an explanation |
| 14:29 | tomoj | $(let [let +] (let 1 2)) |
| 14:29 | sexpbot | java.lang.IllegalArgumentException: let requires a vector for its binding |
| 14:29 | tomoj | well, that works for me in 1.2 |
| 14:29 | tomoj | (i.e. it returns 3) |
| 14:30 | mrTrololo | really strange |
| 14:30 | kotarak | LauJensen: I think you need proxy to handle abstract methods. But I'm not sure. |
| 14:31 | LauJensen | kotarak: re the reify issue? |
| 14:31 | kotarak | tomoj: It should work, because the "real" let special form is let*. Not so for do. |
| 14:31 | kotarak | LauJensen: yes |
| 14:31 | tomoj | kotarak: aha |
| 14:32 | kotarak | tomoj: let is macro adding destructuring and stuff. |
| 14:32 | kotarak | tomoj: but it should be treated as special form |
| 14:32 | LauJensen | kotarak: Ah I think you're right actually |
| 14:32 | tomoj | ?def let |
| 14:33 | kotarak | ~source let |
| 14:35 | tomoj | strange |
| 14:35 | tomoj | so (doc let) special cases it and calls it a special form, I guess? |
| 14:36 | tomoj | even though it's really a macro |
| 14:36 | kotarak | tomoj: it should be treated as special form |
| 14:44 | kotarak | LauJensen: hmmm.... Why should the interface have an abstract method? I don't think, that's what happens. There is something else going on. |
| 14:47 | Borkdude | Is there something like with fn (foo [coll] ...), (op foo x1 x2), op like apply, but the other way around? |
| 14:48 | raek | the other way around? can you show an example? |
| 14:49 | tomoj | (foo [x1 x2]) ? |
| 14:49 | Borkdude | I mean, foo expects a coll |
| 14:49 | Borkdude | but I don't want to wrap x1 and x2 inside a coll |
| 14:49 | Borkdude | like with apply, when it the fn does not want a coll, but direct args |
| 14:50 | tomoj | why don't you want to wrap? just curious |
| 14:50 | Borkdude | because I'm too lazy |
| 14:50 | kotarak | (defn unspread [f & args] (f args)) (unspread foo 1 2 3) |
| 14:51 | Borkdude | for example I want to do this: (merge-with (fn [r l] r) {:foo "Lucy"} {:bar "Ethel"} {:bar "Ricky"})... I can't pass just the first function, because first expects a coll |
| 14:51 | Borkdude | and or isn't a function, so that doesn't work either |
| 14:52 | tomoj | interesting |
| 14:53 | tomoj | so with (defn unspread [f] (fn [& args] (f args))), (unspread first) would work? |
| 14:54 | Borkdude | This works: (merge-with (partial unspread first) {:foo "Lucy"} {:bar "Ethel"} {:bar "Ricky"}) |
| 14:54 | kotarak | (apply merge (reverse {:foo "Lucy"} {:bar "Ethel"} {:bar "Ricky"})) |
| 14:55 | tomoj | (partial merge-with (partial unspread first)) == merge, I think |
| 14:57 | Borkdude | (defn unspread [f] |
| 14:57 | Borkdude | (fn [& args] |
| 14:57 | Borkdude | (f args))) |
| 14:57 | kotarak | tomoj: merge merges left to right. So right wins. So probably (partial merge-with (partial unspread second)) => merge |
| 14:57 | Borkdude | (merge-with (unspread first) {:foo "Lucy"} {:bar "Ethel"} {:bar "Ricky"}) |
| 14:57 | tomoj | oh, yeah |
| 14:58 | tomoj | that unspread is kind of interesting |
| 15:04 | Borkdude | I'm not sure about the name though |
| 15:06 | Borkdude | why not unapply? |
| 15:06 | Borkdude | or deply? :) |
| 15:09 | Borkdude | uncoll |
| 15:10 | Borkdude | I think I like that one |
| 15:11 | Borkdude | because usually the argname in things like first is coll |
| 15:11 | Borkdude | and it sounds a bit like 'uncall' which is close to 'unapply' in meaning |
| 15:17 | Borkdude | tnx for the help. gtg again |
| 17:42 | Raynes | technomancy: Ping. |
| 17:44 | technomancy | Raynes: sorry, I'm on the phone |
| 17:45 | technomancy | a github message is good |
| 17:45 | Raynes | technomancy: It's cool. I'll just reply on github. :p |
| 18:04 | zakwilson | I'm trying to use lein remote-swank. It looks like it's working, but no java process is running on the remote machine. |
| 19:34 | Ankou | hi, I have a map with a :type metadata and I defined a print-method on it. So when I now write (print m) it prints correctly but when I write (print (with-meta m {:type nil})) I get an clojure.lang.LazySeq cannot be cast to clojure.lang.IFn exception. How can this be? |
| 19:35 | Ankou | I mean, I thought print should always print something and never throw an exception like this one? |
| 19:40 | Ankou | anyone? |
| 21:52 | jweiss | hi, i keep trying to use map, when not all the data i need to process is in the seq i'm passing to map. for instance, i want to add metadata to each item in a seq, but the metadata obviously isn't in the seq, it's in a different one. what's the functional way to do this |
| 21:57 | zakwilson | jweiss: pass both seqs and a function that takes two args to map. |
| 21:58 | jweiss | zakwilson: ah yes, i keep forgetting that map can take more than 1 coll :) thanks |
| 22:26 | mebaran151 | I just reinstalled my linux installation and am having a little bit of trouble re-setting up emacs |
| 22:26 | mebaran151 | I'd like to set up Clojure Slime to work with the new Clojure 1.2, but even the release versions are throwing strange errors |
| 22:27 | mebaran151 | particularly wrong number of args passed to basic$eval#compile-file-for-emacs |
| 22:36 | bhenry | membran151 what linux installation? |