diff options
author | Rich Hickey <richhickey@gmail.com> | 2006-08-09 13:27:47 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2006-08-09 13:27:47 +0000 |
commit | ac3c1ae28a18395a15b8a4f85ea2ad90a3e9e540 (patch) | |
tree | 60b94694426b2cff302f50b989f3dbfd0a989d01 /src | |
parent | e5fafd352e9351e1f55b1fac0de911e1dc3b632a (diff) |
removed chaining from ArraySeq.rest, changed meta handling in queue
Diffstat (limited to 'src')
-rw-r--r-- | src/cli/runtime/ArraySeq.cs | 22 | ||||
-rw-r--r-- | src/cli/runtime/PersistentQueue.cs | 20 |
2 files changed, 22 insertions, 20 deletions
diff --git a/src/cli/runtime/ArraySeq.cs b/src/cli/runtime/ArraySeq.cs index c2c56da7..144d872f 100644 --- a/src/cli/runtime/ArraySeq.cs +++ b/src/cli/runtime/ArraySeq.cs @@ -18,7 +18,7 @@ namespace clojure.lang public class ArraySeq : ASeq, IndexedSeq{
readonly Object[] array;
readonly int i;
-ISeq _rest;
+//ISeq _rest;
static public ArraySeq create(params Object[] array){
if(array.Length == 0)
@@ -29,7 +29,7 @@ static public ArraySeq create(params Object[] array){ ArraySeq(Object[] array, int i){
this.array = array;
this.i = i;
- this._rest = this;
+// this._rest = this;
}
override public Object first() {
@@ -37,13 +37,17 @@ override public Object first() { }
override public ISeq rest() {
- if(_rest == this)
- {
- if(i+1 < array.Length)
- _rest = new ArraySeq(array, i + 1);
- _rest = null;
- }
- return _rest;
+ if (i + 1 < array.Length)
+ return new ArraySeq(array, i + 1);
+ return null;
+
+// if(_rest == this)
+// {
+// if(i+1 < array.Length)
+// _rest = new ArraySeq(array, i + 1);
+// _rest = null;
+// }
+// return _rest;
}
public int index(){
diff --git a/src/cli/runtime/PersistentQueue.cs b/src/cli/runtime/PersistentQueue.cs index 3069dfd1..77b72035 100644 --- a/src/cli/runtime/PersistentQueue.cs +++ b/src/cli/runtime/PersistentQueue.cs @@ -23,16 +23,17 @@ namespace clojure.lang public class PersistentQueue : Obj, IPersistentList {
-readonly public static PersistentQueue EMPTY = new PersistentQueue(null,null);
+readonly public static PersistentQueue EMPTY = new PersistentQueue(null,null,null);
readonly ISeq f;
readonly PersistentArrayList r;
static readonly int INITIAL_REAR_SIZE = 4;
-PersistentQueue(ISeq f, PersistentArrayList r) {
+PersistentQueue(ISeq f, PersistentArrayList r, IPersistentMap meta) {
this.f = f;
this.r = r;
+ this._meta = meta;
}
public Object peek() {
@@ -50,9 +51,7 @@ public IPersistentList pop() { f1 = RT.seq(r);
r1 = null;
}
- PersistentQueue ret = new PersistentQueue(f1, r1);
- ret._meta = _meta;
- return ret;
+ return new PersistentQueue(f1, r1,_meta);
}
public int count() {
@@ -68,12 +67,11 @@ public ISeq seq() { public IPersistentCollection cons(Object o) {
PersistentQueue ret;
if(f == null) //empty
- ret = new PersistentQueue(RT.list(o), null);
+ return new PersistentQueue(RT.list(o), null,_meta);
else
- ret= new PersistentQueue(f,
- (PersistentArrayList) (r != null ? r : new PersistentArrayList(INITIAL_REAR_SIZE)).cons(o));
- ret._meta = _meta;
- return ret;
+ return new PersistentQueue(f,
+ (PersistentArrayList) (r != null ? r : new PersistentArrayList(INITIAL_REAR_SIZE)).cons(o),
+ _meta);
}
public override Obj withMeta(IPersistentMap meta)
@@ -112,7 +110,7 @@ class Seq : ASeq { }
}
-/*
+//*
public static void Main(String[] args) {
if (args.Length != 1)
{
|