From ec48bdc0e9949d44e2b704fd389e246a7d7a09eb Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 3 Apr 2003 20:33:53 +0000 Subject: [PATCH] . original commit: 93f501a9322730ac38e3a8bb0ec1d63b9efda70a --- collects/mzlib/pretty.ss | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/collects/mzlib/pretty.ss b/collects/mzlib/pretty.ss index c5578d1..a5875b7 100644 --- a/collects/mzlib/pretty.ss +++ b/collects/mzlib/pretty.ss @@ -272,7 +272,8 @@ (and (or (vector? obj) (pair? obj) (box? obj) - (and (struct? obj) print-struct?)) + (and (struct? obj) print-struct?) + (and (hash-table? obj) print-hash-table?)) (or (hash-table-get table obj (lambda () #f)) (begin (hash-table-put! table obj #t) @@ -291,7 +292,16 @@ [(box? obj) (loop (unbox obj))] [(struct? obj) (ormap loop - (vector->list (struct->vector obj)))])]) + (vector->list (struct->vector obj)))] + [(hash-table? obj) + (let/ec esc + (hash-table-for-each + obj + (lambda (v k) + (when (or (loop v) + (loop k)) + (esc #t)))) + #f)])]) (hash-table-remove! table obj) cycle))))))) @@ -301,7 +311,8 @@ (if (or (vector? obj) (pair? obj) (box? obj) - (and (struct? obj) print-struct?)) + (and (struct? obj) print-struct?) + (and (hash-table? obj) print-hash-table?)) ; A little confusing: use #t for not-found (let ([p (hash-table-get table obj (lambda () #t))]) (when (not (mark? p)) @@ -321,7 +332,13 @@ [(box? obj) (loop (unbox obj))] [(struct? obj) (for-each loop - (vector->list (struct->vector obj)))])) + (vector->list (struct->vector obj)))] + [(hash-table? obj) + (hash-table-for-each + obj + (lambda (k v) + (loop k) + (loop v)))])) (begin (hash-table-put! table obj (make-mark #f (box #f)))))))))))