Re: sorted-set-by?

2009-02-03 Thread R. P. Dillon
> Just curious, does the key need to be in the struct? (seeing you'll > get key-value pairs anyhow if you use first/last etc - the info will > still be there) Excellent point! Given that I'll be using a sorted-map now, I don't even need the structmap! Thanks for the code...I like what you did w

Re: sorted-set-by?

2009-02-03 Thread R. P. Dillon
On further reflection, perhaps the best approach would use sorted-map: (defstruct example :msg :order) (def a (struct "there" 2)) (def b (struct "hi" 1)) (def c (struct "everyone" 3)) We want our map to be sorted on the :order key. So: (sorted-map (:order a) a (:order b) b (:order c) c) I cou

sorted-set-by?

2009-02-03 Thread R. P. Dillon
I want to create a sorted-set of structmaps that are sorted on a particular key of the structmap. The set was going to act as a queue, and initially I implemented this using a PriorityQueue with a Comparator I made using proxy. In general, I'd prefer to use pure Clojure, and sorted-set seemed lik

Re: Strange behavior of the #() macro

2008-10-23 Thread R. P. Dillon
Very clear explanation - I guess I thought that it would be possible to to do the equivalent of (constantly 3) using the macro. I was just overlooking the arity issue with the reduce call. Thanks for taking the time to explain! Cheers, Rick --~--~-~--~~~---~--~~

Strange behavior of the #() macro

2008-10-23 Thread R. P. Dillon
Using #() for "one off" functions, you get some odd behavior: (reduce #(3) (range 1 100)) throws an exception: java.lang.IllegalArgumentException: Wrong number of args passed to: eval--2365$fn as does: (reduce (fn [] 3) (range 1 100) but: (reduce (constantly 3) (range 1 100)) performs as one would

Re: packaging App (cross-platform) without scripts, only jar

2008-10-15 Thread R. P. Dillon
> Cool, thanks. That worked (http://jalat.com/static-files/ > Is it possible to have a subdirectory in the classpath > as well, or does everything have to be from the root? (Ie. Could > clojure have been in a subdirectory lib and classpath have been set to > ". lib/"?) > I tried that but it seems

Re: packaging App (cross-platform) without scripts, only jar

2008-10-14 Thread R. P. Dillon
On Oct 14, 10:04 am, Asbjørn Bjørnstad <[EMAIL PROTECTED]> wrote: > On Oct 2, 10:23 pm, Pascal <[EMAIL PROTECTED]> wrote: > > > > > Hi all, > > > for Michael Beauregard, > > > > Is there a reason why setting the "Main-Class" field in the jar's manifest > > > doesn't work. > > > It work, and since

Clojure Repl forcing lazy lists?

2008-10-11 Thread R. P. Dillon
I was noticing that a lazy list seems to get forced as soon as you create it on the Repl because printing it forces evaluation. (range 1 100), for example, produces: (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46