Re: Idiom for array slicing

2009-08-18 Thread Andrew Baine
If coll has O(n) access and we impose the restriction that indices is increasing (or sort it up front), we can do better than this by only doing one pass through coll. On Aug 18, 10:46 am, CuppoJava wrote: > The most straight-forward answer I would have given is also: > (defn slice [indices col

Re: More SLIME woes

2009-01-23 Thread Andrew Baine
On Jan 23, 1:53 pm, Tom Emerson wrote: > Hi all, > > I updated my entire Clojure environment today to the latest in source > control: slime, swank-clojure, clojure, clojure-contrib, clojure-mode. > Now SLIME is unhappy. It appears that the swank-clojure code has been > patched appropriately. I

Re: Please submit patches as attachments to issues

2009-01-05 Thread Andrew Baine
Here: http://clojure.org/contributing On Jan 5, 3:39 pm, Andrew Baine wrote: > Where do I find the Clojure Contributor Agreement so I can submit a > patch with my issue? > > Andrew --~--~-~--~~~---~--~~ You received this message because you are subsc

Re: Please submit patches as attachments to issues

2009-01-05 Thread Andrew Baine
Where do I find the Clojure Contributor Agreement so I can submit a patch with my issue? Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou

Re: Bug in .hashCode for vectors/lists (Old subject: "Bugs in contains? (?))

2009-01-03 Thread Andrew Baine
On Sat, Jan 3, 2009 at 1:30 PM, Jason wrote: > Thanks for your posts. I think I understand what happens now, but I > still maintain that it's a bug. In particular, the Java API says: "If > two objects are equal according to the equals(Object) method, then > calling the hashCode method on each o

Re: What is this function called?

2009-01-02 Thread Andrew Baine
On Fri, Jan 2, 2009 at 8:09 AM, Perry Trolard wrote: > > I did something similar using (iterate rest coll), which I called iter- > rest: > > (defn iter-rest > "Takes the first (count coll) items from call to (iterate rest > coll). > If passed function as first argument, calls it on each invoc

What is this function called?

2009-01-01 Thread Andrew Baine
I want to get a seq of successive rests of the given seq: user> (defn f [seq] (if (empty? seq) nil (lazy-cons seq (f (rest seq) #'user/f user> (f '(1 2 3 4)) ((1 2 3 4) (2 3 4) (3 4) (4)) user> (take 10 (map #(take 5 %) (f (iterate inc 1 ((1 2 3 4 5) (2 3 4 5 6) (3 4 5 6 7) (4 5 6 7 8)

Re: containsAll patch?

2008-12-24 Thread Andrew Baine
I also uploaded the patch to this group's files: http://groups.google.com/group/clojure/web/containsAll.patch On Dec 24, 7:05 pm, Andrew Baine wrote: > Index: src/jvm/clojure/lang/PersistentQueue.java > === > --- s

containsAll patch?

2008-12-24 Thread Andrew Baine
Index: src/jvm/clojure/lang/PersistentQueue.java === --- src/jvm/clojure/lang/PersistentQueue.java (revision 1185) +++ src/jvm/clojure/lang/PersistentQueue.java (working copy) @@ -181,10 +181,10 @@ public boolean containsAll(Coll

Re: clojure.contrib.enum Exception

2008-12-22 Thread Andrew Baine
Okay, thanks Stuart. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@g

clojure.contrib.enum Exception

2008-12-20 Thread Andrew Baine
Any help is much appreciated: user> (require :verbose 'clojure.contrib.enum) (clojure.core/load "/clojure/contrib/enum") ; Evaluation aborted. java.lang.Exception: Unable to resolve symbol: gen-and-load-class in this context (enum.clj:42) [Thrown class clojure.lang.Compiler$CompilerException]

Re: subset?

2008-12-19 Thread Andrew Baine
I should note that this also works because of sets being seq-able. Since they're callable, we can use b as the predicate in every?; since they're seq-able we can use a as the coll in every?. Very cool! On Dec 19, 1:46 pm, Andrew Baine wrote: > Since sets are callable like func

subset?

2008-12-19 Thread Andrew Baine
Since sets are callable like functions, subset? can be written pretty concisely: user> (defn subset? [a b] (every? b a)) It handles the empty set cases correctly and everything. Is this already in clojure-contrib? Want it and its brethren superset? proper- subset? proper-superset? in there?

Re: confused by Vars, Refs, Agents and Atoms

2008-12-16 Thread Andrew Baine
Check out http://blip.tv/file/812787/ which is a video presentation by Rich Hickey on clojure concurrency; it ends with an description of an ant simulation that uses refs and agents -- it really helped my own intuitive feel of when to use those two constructs. Best, Andrew --~--~-~--~