Permalink
Browse files

add `lazy-cat`

  • Loading branch information...
1 parent 5bfeabf commit 07f11ecb2dea56c3be627e569c3ae532eb39ba86 @swannodette swannodette committed May 4, 2013
Showing with 10 additions and 0 deletions.
  1. +8 −0 src/clj/cljs/core.clj
  2. +2 −0 test/cljs/cljs/core_test.cljs
@@ -1336,3 +1336,11 @@
~@body)
(cljs.core/str sb#)))
+(defmacro lazy-cat
+ "Expands to code which yields a lazy sequence of the concatenation
+ of the supplied colls. Each coll expr is not evaluated until it is
+ needed.
+
+ (lazy-cat xs ys zs) === (concat (lazy-seq xs) (lazy-seq ys) (lazy-seq zs))"
+ [& colls]
+ `(concat ~@(map #(list `lazy-seq %) colls)))
@@ -1864,5 +1864,7 @@
(assert (= (hash 'foo) (hash (symbol "foo"))))
(assert (= (hash 'foo/bar) (hash (symbol "foo" "bar"))))
+ (assert (= (lazy-cat [1] [2] [3]) '(1 2 3)))
+
:ok
)

0 comments on commit 07f11ec

Please sign in to comment.