<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/jvm/clojure/lang/ArrayChunk.java</filename>
    </added>
    <added>
      <filename>src/jvm/clojure/lang/ChunkedCons.java</filename>
    </added>
    <added>
      <filename>src/jvm/clojure/lang/IChunkedSeq.java</filename>
    </added>
    <added>
      <filename>src/jvm/clojure/lang/Indexed.java</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -11,6 +11,11 @@
     &lt;setting name=&quot;buildJar&quot; value=&quot;true&quot; /&gt;
     &lt;setting name=&quot;mainClass&quot; value=&quot;clojure.lang.Compiler&quot; /&gt;
   &lt;/component&gt;
+  &lt;component name=&quot;FacetManager&quot;&gt;
+    &lt;facet type=&quot;Clojure&quot; name=&quot;Clojure&quot;&gt;
+      &lt;configuration /&gt;
+    &lt;/facet&gt;
+  &lt;/component&gt;
   &lt;component name=&quot;NewModuleRootManager&quot; inherit-compiler-output=&quot;false&quot;&gt;
     &lt;output url=&quot;file://$MODULE_DIR$/classes&quot; /&gt;
     &lt;exclude-output /&gt;</diff>
      <filename>clojure.iml</filename>
    </modified>
    <modified>
      <diff>@@ -10,11 +10,9 @@ package clojure.lang;
  * You must not remove this notice, or any other, from this software.
  */
 
-public interface IPersistentVector extends Associative, Sequential, IPersistentStack, Reversible, Counted{
+public interface IPersistentVector extends Associative, Sequential, IPersistentStack, Reversible, Indexed{
 int length();
 
-Object nth(int i);
-
 IPersistentVector assocN(int i, Object val);
 
 IPersistentVector cons(Object o);</diff>
      <filename>src/jvm/clojure/lang/IPersistentVector.java</filename>
    </modified>
    <modified>
      <diff>@@ -17,6 +17,7 @@ import java.util.*;
 public final class LazySeq extends Obj implements ISeq, List{
 
 private IFn fn;
+private Object sv;
 private ISeq s;
 
 public LazySeq(IFn fn){
@@ -33,12 +34,12 @@ public Obj withMeta(IPersistentMap meta){
 	return new LazySeq(meta, seq());
 }
 
-final synchronized public ISeq seq(){
+final synchronized Object sval(){
 	if(fn != null)
 		{
 		try
 			{
-			s = RT.seq(fn.invoke());
+			sv = fn.invoke();
 			fn = null;
 			}
 		catch(Exception e)
@@ -46,13 +47,30 @@ final synchronized public ISeq seq(){
 			throw new RuntimeException(e);
 			}
 		}
+	if(sv != null)
+		return sv;
+	return s;
+}
+
+final synchronized public ISeq seq(){
+	sval();
+	if(sv != null)
+		{
+		Object ls = sv;
+		sv = null;
+		while(ls instanceof LazySeq)
+			{
+			ls = ((LazySeq)ls).sval();
+			}
+		s = RT.seq(ls);
+		}
 	return s;
 }
 
 public int count(){
 	int c = 0;
 	for(ISeq s = seq(); s != null; s = s.next())
-		++c;
+		++c;                                                                                
 	return c;
 }
 </diff>
      <filename>src/jvm/clojure/lang/LazySeq.java</filename>
    </modified>
    <modified>
      <diff>@@ -89,19 +89,24 @@ final int tailoff(){
 	return cnt - tail.length;
 }
 
-public Object nth(int i){
+public Object[] nodeFor(int i){
 	if(i &gt;= 0 &amp;&amp; i &lt; cnt)
 		{
 		if(i &gt;= tailoff())
-			return tail[i &amp; 0x01f];
+			return tail;
 		Object[] arr = root;
 		for(int level = shift; level &gt; 0; level -= 5)
 			arr = (Object[]) arr[(i &gt;&gt;&gt; level) &amp; 0x01f];
-		return arr[i &amp; 0x01f];
+		return arr;
 		}
 	throw new IndexOutOfBoundsException();
 }
 
+public Object nth(int i){
+	Object[] node = nodeFor(i);
+	return node[i &amp; 0x01f];
+}
+
 public PersistentVector assocN(int i, Object val){
 	if(i &gt;= 0 &amp;&amp; i &lt; cnt)
 		{
@@ -163,6 +168,75 @@ public PersistentVector cons(Object val){
 	return new PersistentVector(meta(), cnt + 1, newshift, newroot, new Object[]{val});
 }
 
+public IChunkedSeq chunkedSeq(){
+	if(count() == 0)
+		return null;
+	return new ChunkedSeq(this,0,0);
+}
+
+static public final class ChunkedSeq extends ASeq implements IChunkedSeq{
+
+	final PersistentVector vec;
+	final Object[] node;
+	final int i;
+	final int offset;
+
+	public ChunkedSeq(PersistentVector vec, int i, int offset){
+		this.vec = vec;
+		this.i = i;
+		this.offset = offset;
+		this.node = vec.nodeFor(i);
+	}
+
+	ChunkedSeq(IPersistentMap meta, PersistentVector vec, Object[] node, int i, int offset){
+		super(meta);
+		this.vec = vec;
+		this.node = node;
+		this.i = i;
+		this.offset = offset;
+	}
+
+	ChunkedSeq(PersistentVector vec, Object[] node, int i, int offset){
+		this.vec = vec;
+		this.node = node;
+		this.i = i;
+		this.offset = offset;
+	}
+
+	public Indexed chunkedFirst() throws Exception{
+		return new ArrayChunk(node, offset);
+		}
+
+	public ISeq chunkedNext(){
+		if(i + node.length &lt; vec.cnt)
+			return new ChunkedSeq(vec,i+ node.length,0);
+		return null;
+		}
+
+	public ISeq chunkedMore(){
+		ISeq s = chunkedNext();
+		if(s == null)
+			return PersistentList.EMPTY;
+		return s;
+	}
+
+	public Obj withMeta(IPersistentMap meta){
+		if(meta == this._meta)
+			return this;
+		return new ChunkedSeq(meta, vec, node, i, offset);
+	}
+
+	public Object first(){
+		return node[offset];
+	}
+
+	public ISeq next(){
+		if(offset + 1 &lt; node.length)
+			return new ChunkedSeq(vec, node, i, offset + 1);
+		return chunkedNext();
+	}
+}
+
 public IPersistentCollection empty(){
 	return EMPTY.withMeta(meta());
 }</diff>
      <filename>src/jvm/clojure/lang/PersistentVector.java</filename>
    </modified>
    <modified>
      <diff>@@ -494,10 +494,10 @@ static public IPersistentMap meta(Object x){
 }
 
 public static int count(Object o){
+	if(o instanceof Counted)
+		return ((Counted) o).count();
 	if(o == null)
 		return 0;
-	else if(o instanceof Counted)
-		return ((Counted) o).count();
 	else if(o instanceof IPersistentCollection) {
 		ISeq s = seq(o);
 		o = null;
@@ -712,10 +712,10 @@ static public Object dissoc(Object coll, Object key) throws Exception{
 }
 
 static public Object nth(Object coll, int n){
+	if(coll instanceof Indexed)
+		return ((Indexed) coll).nth(n);
 	if(coll == null)
 		return null;
-	else if(coll instanceof IPersistentVector)
-		return ((IPersistentVector) coll).nth(n);
 	else if(coll instanceof String)
 		return Character.valueOf(((String) coll).charAt(n));
 	else if(coll.getClass().isArray())</diff>
      <filename>src/jvm/clojure/lang/RT.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b045a379215d1f48e6a2e6cedcdb41526cd5bb25</id>
    </parent>
  </parents>
  <author>
    <name>Rich Hickey</name>
    <email>richhickey@gmail.com</email>
  </author>
  <url>http://github.com/stuarthalloway/clojure/commit/ff27522840fb3c1681c331ad1fb44a313bd44e0a</url>
  <id>ff27522840fb3c1681c331ad1fb44a313bd44e0a</id>
  <committed-date>2009-05-28T06:42:16-07:00</committed-date>
  <authored-date>2009-05-28T06:42:16-07:00</authored-date>
  <message>first cut of chunked seqs
Chunked seqs, initial Java-side support</message>
  <tree>ea768d176e1bb88323e9e62cba1db3f962a7f3d2</tree>
  <committer>
    <name>Rich Hickey</name>
    <email>richhickey@gmail.com</email>
  </committer>
</commit>
