summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2009-01-21 22:55:49 +0000
committerRich Hickey <richhickey@gmail.com>2009-01-21 22:55:49 +0000
commit96bdcae07e1807e86ee866ee0dfda9588ee07eec (patch)
tree4b30dff7d6846897b46b22cba6ac1c82f552ece5
parent0859070dd1909f3e56b99b54c79aa4d7aaca8f74 (diff)
made AStream Sequential
made *io-context* public
-rw-r--r--src/clj/clojure/core.clj13
-rw-r--r--src/jvm/clojure/lang/AStream.java2
-rw-r--r--src/jvm/clojure/lang/RT.java4
3 files changed, 15 insertions, 4 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 482a1790..6527f926 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -1299,7 +1299,7 @@
(. ref (touch))
(. ref (get)))
-(def #^{:private true :tag clojure.lang.Closer} *io-context* nil)
+(def #^{:tag clojure.lang.Closer} *io-context* nil)
(defmacro sync
"transaction-flags => TBD, pass nil for now
@@ -1437,6 +1437,17 @@
eos
(apply f xs)))))))))
+(defn map
+ "Returns a lazy seq consisting of the result of applying f to the
+ set of first items of each coll, followed by applying f to the set
+ of second items in each coll, until any one of the colls is
+ exhausted. Any remaining items in other colls are ignored. Function
+ f should accept number-of-colls arguments."
+ ([f coll] (seq (map-stream f coll)))
+ ([f c1 c2] (seq (map-stream f c1 c2)))
+ ([f c1 c2 c3] (seq (map-stream f c1 c2 c3)))
+ ([f c1 c2 c3 & colls] (seq (apply map-stream f c1 c2 c3 colls))))
+
(defn mapcat
"Returns the result of applying concat to the result of applying map
to f and colls. Thus function f should return a collection."
diff --git a/src/jvm/clojure/lang/AStream.java b/src/jvm/clojure/lang/AStream.java
index c0fabb29..32bb661f 100644
--- a/src/jvm/clojure/lang/AStream.java
+++ b/src/jvm/clojure/lang/AStream.java
@@ -12,7 +12,7 @@
package clojure.lang;
-final public class AStream implements Seqable, Streamable {
+final public class AStream implements Seqable, Streamable, Sequential {
static final ISeq NO_SEQ = new Cons(null, null);
diff --git a/src/jvm/clojure/lang/RT.java b/src/jvm/clojure/lang/RT.java
index 5b7df45b..0e75b311 100644
--- a/src/jvm/clojure/lang/RT.java
+++ b/src/jvm/clojure/lang/RT.java
@@ -720,7 +720,7 @@ static public Object nth(Object coll, int n){
else if(coll instanceof Sequential)
{
- ISeq seq = ((IPersistentCollection) coll).seq();
+ ISeq seq = RT.seq(coll);
coll = null;
for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest())
{
@@ -783,7 +783,7 @@ static public Object nth(Object coll, int n, Object notFound){
}
else if(coll instanceof Sequential)
{
- ISeq seq = ((IPersistentCollection) coll).seq();
+ ISeq seq = RT.seq(coll);
coll = null;
for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest())
{