From acb95cd1b7165c567951406c1ce904267c3758d2 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 3 Apr 2007 22:27:21 +0000 Subject: [PATCH] added pretty-format svn: r5862 original commit: 8f51c76a7b653508c304d6563eafaf7863042366 --- collects/mzlib/pretty.ss | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/collects/mzlib/pretty.ss b/collects/mzlib/pretty.ss index e99d8eb..42ad262 100644 --- a/collects/mzlib/pretty.ss +++ b/collects/mzlib/pretty.ss @@ -31,6 +31,8 @@ pretty-print-extend-style-table pretty-print-remap-stylable + pretty-format + pretty-printing pretty-print-newline make-tentative-pretty-print-output-port @@ -1122,5 +1124,20 @@ (substring padded-s (- len 10-power) len))) ;; d has factor(s) other than 2 and 5. ;; Print as a fraction. - (number->string x)))))))]))) + (number->string x)))))))])) + + (define pretty-format + (case-lambda + [(t) (pretty-format t (pretty-print-columns))] + [(t w) + (parameterize ([pretty-print-columns w]) + (let ([op (open-output-string)]) + (pretty-print t op) + (let ([s (get-output-string op)]) + (if (eq? w 'infinity) + s + (substring s 0 (- (string-length s) 1))))))])) + + + )