Commits

Moritz Heidkamp  committed 48ab239

Improve lazy-seq record printer

  • Participants
  • Parent commits 52618ca

Comments (0)

Files changed (1)

File lazy-seq.scm

 
 (define-record-printer (lazy-seq seq out)
   (display "#<lazy-" out)
-  (cond ((lazy-null? seq)
-         (display "null>" out))
-        ((lazy-seq-realized? seq)
+  (cond ((not (lazy-seq-realized? seq))
          (display "seq ...>" out))
+        ((lazy-null? seq)
+         (display "null>" out))
         (else
-         (fprintf out "seq ~S ...>" (lazy-head seq)))))
+         (display "seq" out)
+         (let loop ((seq seq))
+           (if (lazy-seq-realized? seq)
+               (if (lazy-null? seq)
+                   (display ">" out)
+                   (begin
+                     (display " " out)
+                     (write (lazy-head seq) out)
+                     (loop (lazy-tail seq))))
+               (display " ...>" out))))))
 
 (define (lazy-seq-realized? seq)
   (not (lazy-seq-body seq)))