summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2010-03-01 08:52:59 -0500
committerRich Hickey <richhickey@gmail.com>2010-03-01 08:52:59 -0500
commitb497cbba5547535e0b360a869381a02996c80635 (patch)
tree6234fda4cc1be78fb48a476780cb060380fd0c3e /src
parent45255d5c87f4fcfa48c13889a912c225dafc0ee4 (diff)
added n arg to repeatedly
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/core.clj8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index b3b01ba8..bec3f2af 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -3593,9 +3593,11 @@
(if ((mk-bound-fn sc end-test end-key) e) s (next s))))))
(defn repeatedly
- "Takes a function of no args, presumably with side effects, and returns an infinite
- lazy sequence of calls to it"
- [f] (lazy-seq (cons (f) (repeatedly f))))
+ "Takes a function of no args, presumably with side effects, and
+ returns an infinite (or length n if supplied) lazy sequence of calls
+ to it"
+ ([f] (lazy-seq (cons (f) (repeatedly f))))
+ ([n f] (take n (repeatedly f))))
(defn add-classpath
"DEPRECATED