File: pp.scm

package info (click to toggle)
slib 2d2-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,468 kB
  • ctags: 1,726
  • sloc: lisp: 20,736; makefile: 333; sh: 158
file content (15 lines) | stat: -rw-r--r-- 510 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
;"pp.scm" Pretty-Print
(require 'generic-write)

(define (pp: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))

(define pretty-print pp:pretty-print)