Re: Seq wrappers for arrays can morph

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 9:36 PM, Josh Daghlian wrote: > > Although I suppose this isn't too surprising: > > user> (second y) > --> ConcurrentModificationException Eeeuw. Guess it uses an Iterator to generate the elements for the lazy seq. For ArrayList, walking it by index would avoid this. For

Re: Seq wrappers for arrays can morph

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 9:31 PM, Josh Daghlian wrote: > During the Boston Lisp Users meeting last November (?) I asked Rich > about whether seq's on mutable java.util.Collections were really > immutable if the underlying object (the Collection) was mutable. He > emphatically said that no, the seq

Re: Seq wrappers for arrays can morph

2009-10-30 Thread Josh Daghlian
Although I suppose this isn't too surprising: user> (second y) --> ConcurrentModificationException --josh On Oct 30, 9:31 pm, Josh Daghlian wrote: > During the Boston Lisp Users meeting last November (?) I asked Rich > about whether seq's on mutable java.util.Collections were really > immutabl

Re: Seq wrappers for arrays can morph

2009-10-30 Thread Josh Daghlian
During the Boston Lisp Users meeting last November (?) I asked Rich about whether seq's on mutable java.util.Collections were really immutable if the underlying object (the Collection) was mutable. He emphatically said that no, the seq is still immutable, and that it caches values as it sees them.

Re: Seq wrappers for arrays can morph

2009-10-30 Thread John Harrop
On Fri, Oct 30, 2009 at 12:40 PM, John Harrop 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 a

Re: Seq wrappers for arrays can morph

2009-10-30 Thread John Newman
When someone knowingly dips into arrays, though, aren't doing so because they require java's semantics? For speed, interop, or whatever? We want to champion functional programming, but on the other hand we want to preserve the smooth java-interop use-cases. Not an easy balancing act, I suppose.

Seq wrappers for arrays can morph

2009-10-30 Thread John Harrop
user=> (def x (int-array 3)) #'user/x user=> x [0, 0, 0] user=> (def y (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) 2 Here, (first y) returned first 0, then 2 without y being rebound in b