diff options
author | Rich Hickey <richhickey@gmail.com> | 2007-10-20 21:34:56 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2007-10-20 21:34:56 +0000 |
commit | 1bf3aaff908cf57c8193e6edf9f7be81d8dae102 (patch) | |
tree | db9d8b3c856a10b308e08bb71215b1bf44e8585c /src | |
parent | fe567065b55b47705a6292e6f993001e4ef31997 (diff) |
added range
Diffstat (limited to 'src')
-rw-r--r-- | src/boot.clj | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/boot.clj b/src/boot.clj index 20e7702f..e381bfdc 100644 --- a/src/boot.clj +++ b/src/boot.clj @@ -466,6 +466,11 @@ (defn iterate [f x] (lazy-cons x (iterate f (f x)))) +(defn range + ([end] (take end (iterate inc 0))) + ([start end] (take (- end start) (iterate inc start))) + ([start end step] + (take-while (appl (if (pos? step) > <) end) (iterate (appl + step) start)))) (defn merge [& maps] (reduce conj maps)) @@ -614,7 +619,7 @@ every not-every any not-any map mapcat filter take take-while drop drop-while zipmap - cycle split-at split-with repeat replicate iterate + cycle split-at split-with repeat replicate iterate range dolist dotimes eval import unimport refer unrefer in-namespace unintern into-array array |