     (loop []
       (if (and (not (nil? (.-stepper lt)))
                (.hasNext iter))
-        (when-not (reduced? (xform lt (.next iter)))
+        (if (reduced? (apply xform (cons lt (.next iter))))
+          (when-not (nil? (.-rest lt))
+            (set! (.. lt -rest -stepper) nil))
           (recur))))
     (when-not (nil? (.-stepper lt))
       (xform lt))))

(defn array-iter [x]
  (ArrayIter. x 0))

(deftype SeqIter [^:mutable seq]
  Object
  (hasNext [_] (not (nil? seq)))
  (next [_]
    (let [first (first seq)]
      (set! seq (next seq))
      first))
  (remove [_] (js/Error. "Unsupported operation")))

(defn seq-iter [seq]
  (SeqIter. seq))

(defn iter [coll]
  (cond
    (nil? coll) (nil-iter)
    (string? coll) (string-iter coll)
    (array? coll) (array-iter coll)
    :else (seq-iter (seq coll))))

(declare LazyTransformer)


    (loop []
      (if (and (not (nil? (.-stepper lt)))
               (.hasNext iter))
        (if (reduced? (xform lt (.next iter)))
          (when-not (nil? (.-rest lt))
            (set! (.. lt -rest -stepper) nil))
          (recur))))
    (when-not (nil? (.-stepper lt))
      (xform lt))))
