For your eueler problem consider using lazy functions cycle and range: user=> (take 15 (cycle (range 5))) (0 1 2 3 4 0 1 2 3 4 0 1 2 3 4) Or is there some other behavior you need to create?
Regarding proxy your main problem is that IPersistentVector is an Interface (no implementation) so you would have to specify every method. More sensibly you could proxy the concrete implementation PersistentVector, however it does not have an empty constructor so you would need to figure out exactly what you want to do. user=> (proxy [clojure.lang.PersistentVector] []) java.lang.IllegalArgumentException: No matching ctor found for class clojure.proxy.clojure.lang.PersistentVector I would advise against proxying for this problem as it is complex and not in the spirit of solving the problem in Clojure. Regards. Tim. On Mar 9, 9:13 am, Paul Mooser <taron...@gmail.com> wrote: > I was playing around with some project euler problems, and I was > thinking that the cycle function has an analog for vectors. I > implemented a short simple method with the right behavior (at a simple > surface level): > > (defn cyclic-vector [v] > (fn [x] > (v (mod x (count v))))) > > However, this obviously does not implement IPersistentVector. > > Is there any easy way to implement something like this, and delegate > the rest of the behaviors to the base vector object ? I realize this > is probably possible with proxy, but I have not successfully made it > work yet - proxying the IPersistentVector interface results in the > following for me: > > (proxy [clojure.lang.IPersistentVector] []) > > java.lang.ClassFormatError: Duplicate method name&signature in class > file clojure/proxy/java/lang/Object$IPersistentVector (NO_SOURCE_FILE: > 2) > > Is this an issue with proxy, or am I using it incorrectly ? I removed > any extraneous code of my own, since the error occurs with just the > minimal proxy usage shown above. I'm on trunk, revision 1326. --~--~---------~--~----~------------~-------~--~----~ 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...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---