File: pp.scm

package info (click to toggle)
slib 3c1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,076 kB
  • sloc: lisp: 29,815; makefile: 1,165; sh: 953
file content (13 lines) | stat: -rwxr-xr-x 472 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
;"pp.scm" Pretty-Print
(require 'generic-write)
;@
(define (pretty-print obj . opt)
  (let ((port (if (pair? opt) (car opt) (current-output-port))))
    (generic-write obj #f (output-port-width port)
		   (lambda (s) (display s port) #t))))
;@
(define (pretty-print->string obj . width)
  (define result '())
  (generic-write obj #f (if (null? width) (output-port-width) (car width))
		 (lambda (str) (set! result (cons str result)) #t))
  (reverse-string-append result))