I have the following snippet:
(defn explode [e]
  (seq [e e e e]))
(defn f [coll]
  (when-first [e coll]
    (cons e 
          (lazy-seq (f (lazy-cat (next coll)
                                 (explode e)))))))
When I try to access an element, I get a StackOverflow error:
user=> (nth (f (seq [1 2 3])) 1000)
3
user=> (nth (f (seq [1 2 3])) 10000)
StackOverflowError   clojure.core/concat/fn--3923 (core.clj:678)
How can I structure this code in a way that doesn't blow the stack?
 
    