summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2008-03-12 14:51:33 +0000
committerRich Hickey <richhickey@gmail.com>2008-03-12 14:51:33 +0000
commit842e6716e26fb070feeb8654a60128dbe99a538b (patch)
tree642d1fb0927635846cdd1891d5c55183886bd025
parentc51522e5fa50e9618fcaaa126376b73acdff351e (diff)
prevent take from advancing coll more than n times
-rw-r--r--src/boot.clj5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/boot.clj b/src/boot.clj
index 891dabfd..c399f0f5 100644
--- a/src/boot.clj
+++ b/src/boot.clj
@@ -1016,7 +1016,10 @@ not-every? (comp not every?))
there are fewer than n."
[n coll]
(when (and (pos? n) (seq coll))
- (lazy-cons (first coll) (take (dec n) (rest coll)))))
+ (lazy-cons (first coll)
+ (if (= 1 n)
+ nil
+ (take (dec n) (rest coll))))))
(defn take-while
"Returns a lazy seq of successive items from coll while