On Fri, Oct 30, 2009 at 12:40 PM, John Harrop <jharrop...@gmail.com> wrote:
> (defn lazy-array-seq > ([arr] > (lazy-array-seq arr 0)) > ([arr from-idx] > (lazy-array-seq arr 0 (count arr))) > ([arr from-idx end-idx] > (if-not (= from-idx end-idx) > (lazy-seq (aget arr from-idx) (lazy-array-seq arr (inc from-idx) > end-idx))))) > Pardon me. I was in a bit of a hurry just on my way out the door. Try: (defn lazy-array-seq ([arr] (lazy-array-seq arr 0)) ([arr from-idx] (lazy-array-seq arr 0 (count arr))) ([arr from-idx end-idx] (lazy-seq (if-not (= from-idx end-idx) (cons (aget arr from-idx) (lazy-array-seq arr (inc from-idx) end-idx)))))) user=> (def x (int-array 3)) #'user/x user=> x [0, 0, 0] user=> (def y (lazy-array-seq x)) #'user/y user=> (first y) 0 user=> (aset x 1 3) 3 user=> x [0, 3, 0] user=> (second y) 3 user=> (aset x 0 2) 2 user=> x [2, 3, 0] user=> (first y) 0 user=> y (0 3 0) --~--~---------~--~----~------------~-------~--~----~ 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 Note that posts from new members are moderated - please be patient with your first post. 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 -~----------~----~----~----~------~----~------~--~---