summaryrefslogtreecommitdiff
path: root/src/clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/clj')
-rw-r--r--src/clj/clojure/core.clj38
-rw-r--r--src/clj/clojure/core_print.clj12
2 files changed, 29 insertions, 21 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index d95e3972..3d13eba0 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -407,32 +407,36 @@
[first-expr & rest-expr]
(list 'new 'clojure.lang.LazyCons (list `fn (list [] first-expr) (list* [(gensym)] rest-expr))))
+
+(defmacro lazy-seq
+ "Takes a body of expressions that returns an ISeq or nil, and yields
+ a Seqable object that will invoke the body only the first time seq
+ is called, and will cache the result and return it on all subsequent
+ seq calls. Any closed over locals will be cleared prior to the tail
+ call of body."
+ [& body]
+ (list 'new 'clojure.lang.Delay$Seq (list* '#^{:once true} fn* [] body)))
+
(defn concat
- "Returns a lazy seq representing the concatenation of the elements in the supplied colls."
+ "Returns a lazy sequence representing the concatenation of the elements in the supplied colls."
([] nil)
([x] (seq x))
([x y]
- (if (seq x)
- (lazy-cons (first x) (concat (rest x) y))
- (seq y)))
+ (lazy-seq
+ (if (seq x)
+ (cons (first x) (concat (more x) y))
+ (seq y))))
([x y & zs]
(let [cat (fn cat [xys zs]
- (if (seq xys)
- (lazy-cons (first xys) (cat (rest xys) zs))
- (when zs
- (recur (first zs) (rest zs)))))]
+ (lazy-seq
+ (if (seq xys)
+ (cons (first xys) (cat (more xys) zs))
+ (when zs
+ (seq (cat (first zs) (rest zs)))))))]
(cat (concat x y) zs))))
;;;;;;;;;;;;;;;;at this point all the support for syntax-quote exists;;;;;;;;;;;;;;;;;;;;;;
-(defmacro lazy-seq
- "Takes a body of expressions that returns an ISeq or nil, and yields
- a Seqable object that will invoke the body only the first time seq
- is called, and will cache the result and return it on all subsequent
- seq calls. Any closed over locals will be cleared prior to the tail
- call of body."
- [& body]
- (list 'new 'clojure.lang.Delay$Seq (list* `#^{:once true} fn* [] body)))
(defmacro delay
"Takes a body of expressions and yields a Delay object that will
@@ -3726,7 +3730,7 @@
the coordination overhead."
([f coll]
(let [n (inc (.. Runtime getRuntime availableProcessors))
- agents (doall (map #(agent (f %)) (take n coll)))
+ agents (doall (map #(send (agent %) f) (take n coll)))
wget (fn [a] (await1 a) @a)
step (fn step [[x & xs :as s]
[a & as :as acycle]]
diff --git a/src/clj/clojure/core_print.clj b/src/clj/clojure/core_print.clj
index 7a79a903..59b045b3 100644
--- a/src/clj/clojure/core_print.clj
+++ b/src/clj/clojure/core_print.clj
@@ -128,14 +128,18 @@
(defmethod print-dup clojure.lang.Var [#^clojure.lang.Var o, #^Writer w]
(.write w (str "#=(var " (.name (.ns o)) "/" (.sym o) ")")))
-(defmethod print-method clojure.lang.ISeq [o, #^Writer w]
+(defmethod print-method clojure.lang.Sequence [o, #^Writer w]
(print-meta o w)
(print-sequential "(" pr-on " " ")" o w))
-(defmethod print-dup clojure.lang.ISeq [o w] (print-method o w))
+(defmethod print-dup clojure.lang.Sequence [o w] (print-method o w))
(defmethod print-dup clojure.lang.IPersistentList [o w] (print-method o w))
-(prefer-method print-method clojure.lang.IPersistentList clojure.lang.ISeq)
-(prefer-method print-dup clojure.lang.IPersistentList clojure.lang.ISeq)
+(prefer-method print-method clojure.lang.IPersistentList clojure.lang.Sequence)
+(prefer-method print-dup clojure.lang.IPersistentList clojure.lang.Sequence)
+(prefer-method print-method clojure.lang.Sequence clojure.lang.IPersistentCollection)
+(prefer-method print-dup clojure.lang.Sequence clojure.lang.IPersistentCollection)
+(prefer-method print-method clojure.lang.Sequence java.util.Collection)
+(prefer-method print-dup clojure.lang.Sequence java.util.Collection)
(defmethod print-method clojure.lang.IPersistentList [o, #^Writer w]
(print-meta o w)