diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-03-12 14:51:33 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-03-12 14:51:33 +0000 |
commit | 842e6716e26fb070feeb8654a60128dbe99a538b (patch) | |
tree | 642d1fb0927635846cdd1891d5c55183886bd025 | |
parent | c51522e5fa50e9618fcaaa126376b73acdff351e (diff) |
prevent take from advancing coll more than n times
-rw-r--r-- | src/boot.clj | 5 |
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 |