summaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/runtime/Associative.cs21
-rw-r--r--src/cli/runtime/Cons.cs6
-rw-r--r--src/cli/runtime/IPersistentCollection.cs2
-rw-r--r--src/cli/runtime/IPersistentMap.cs11
-rw-r--r--src/cli/runtime/PersistentArray.cs4
-rw-r--r--src/cli/runtime/RT.cs5
-rw-r--r--src/cli/runtime/Sequential.cs18
-rw-r--r--src/cli/runtime/Tuple.cs4
8 files changed, 60 insertions, 11 deletions
diff --git a/src/cli/runtime/Associative.cs b/src/cli/runtime/Associative.cs
new file mode 100644
index 00000000..3f14089a
--- /dev/null
+++ b/src/cli/runtime/Associative.cs
@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) Rich Hickey. All rights reserved.
+ * The use and distribution terms for this software are covered by the
+ * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+ * which can be found in the file CPL.TXT at the root of this distribution.
+ * By using this software in any fashion, you are agreeing to be bound by
+ * the terms of this license.
+ * You must not remove this notice, or any other, from this software.
+ */
+
+using System;
+namespace clojure.lang
+ {
+ public interface Associative
+ {
+ bool contains(object key);
+ IMapEntry find(object key);
+ object get(object key);
+ IPersistentMap put(object key, object val);
+ }
+ }
diff --git a/src/cli/runtime/Cons.cs b/src/cli/runtime/Cons.cs
index 18c2a656..cd5291db 100644
--- a/src/cli/runtime/Cons.cs
+++ b/src/cli/runtime/Cons.cs
@@ -43,13 +43,17 @@ public ISeq rest()
#endregion
-#region ISequential Members
+#region IPersistentCollection Members
public ISeq seq()
{
return this;
}
+public int count() {
+ return 1 + RT.count(_rest);
+}
+
#endregion
}
diff --git a/src/cli/runtime/IPersistentCollection.cs b/src/cli/runtime/IPersistentCollection.cs
index d908b7fb..6746240b 100644
--- a/src/cli/runtime/IPersistentCollection.cs
+++ b/src/cli/runtime/IPersistentCollection.cs
@@ -16,6 +16,8 @@ namespace clojure.lang
public interface IPersistentCollection
{
+ int count();
+
ISeq seq();
}
diff --git a/src/cli/runtime/IPersistentMap.cs b/src/cli/runtime/IPersistentMap.cs
index c91d3aa8..df91a08a 100644
--- a/src/cli/runtime/IPersistentMap.cs
+++ b/src/cli/runtime/IPersistentMap.cs
@@ -14,22 +14,13 @@ using System.Collections;
namespace clojure.lang
{
-public interface IPersistentMap : IEnumerable, IPersistentCollection{
+public interface IPersistentMap : Associative, IEnumerable, IPersistentCollection{
-int count();
-
-bool contains(Object key);
-
-IMapEntry find(Object key);
IPersistentMap add(Object key, Object val);
-IPersistentMap put(Object key, Object val);
-
IPersistentMap remove(Object key);
-Object get(Object key);
-
int capacity();
}
diff --git a/src/cli/runtime/PersistentArray.cs b/src/cli/runtime/PersistentArray.cs
index 73b7a369..2cabe49e 100644
--- a/src/cli/runtime/PersistentArray.cs
+++ b/src/cli/runtime/PersistentArray.cs
@@ -257,6 +257,10 @@ public PersistentArray(IArray init) :this(init.length()) {
data.master.load = load;
}
+virtual public int count(){
+return data.master.array.Length;
+}
+
virtual public int length(){
return data.master.array.Length;
}
diff --git a/src/cli/runtime/RT.cs b/src/cli/runtime/RT.cs
index 23cb34b3..ed6bfffe 100644
--- a/src/cli/runtime/RT.cs
+++ b/src/cli/runtime/RT.cs
@@ -379,5 +379,10 @@ static public Object setValues(params Object[] vals)
return null;
}
+public static int count(Object o) {
+ if(o == null)
+ return 0;
+ return ((IPersistentCollection)o).count();
+}
}
} \ No newline at end of file
diff --git a/src/cli/runtime/Sequential.cs b/src/cli/runtime/Sequential.cs
new file mode 100644
index 00000000..a8b48e96
--- /dev/null
+++ b/src/cli/runtime/Sequential.cs
@@ -0,0 +1,18 @@
+/**
+ * Copyright (c) Rich Hickey. All rights reserved.
+ * The use and distribution terms for this software are covered by the
+ * Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
+ * which can be found in the file CPL.TXT at the root of this distribution.
+ * By using this software in any fashion, you are agreeing to be bound by
+ * the terms of this license.
+ * You must not remove this notice, or any other, from this software.
+ */
+
+namespace clojure.lang
+{
+
+
+public interface Sequential {
+}
+
+}
diff --git a/src/cli/runtime/Tuple.cs b/src/cli/runtime/Tuple.cs
index 59799b30..7c6c2f02 100644
--- a/src/cli/runtime/Tuple.cs
+++ b/src/cli/runtime/Tuple.cs
@@ -29,6 +29,10 @@ public Tuple(params Object[] init){
this.array = init;
}
+public int count() {
+ return array.Length;
+}
+
public int length() {
return array.Length;
}