racket/collects/scribble/text/output.ss
Eli Barzilay 26b9bd6c3d * Added text utilities
* begin/collect, and a begin/text that is based on it (ignoring
  inter-defns spaces)
* include/text, available as `include' in the scribble/text langauge
* tests, only for begin/collect for now

svn: r11772
2008-09-16 00:46:35 +00:00

21 lines
715 B
Scheme

#lang scheme/base
(require scheme/promise)
(provide output)
(define (output x [p (current-output-port)])
(let loop ([x x])
(cond [(or (void? x) (not x) (null? x)) (void)]
[(pair? x) (loop (car x)) (loop (cdr x))]
[(promise? x) (loop (force x))]
[(keyword? x) (loop (keyword->string x))]
[(and (procedure? x) (procedure-arity-includes? x 0)) (loop (x))]
[(bytes? x) (write-bytes x p)]
[(string? x) (write-string x p)]
[(char? x) (write-char x p)]
[(number? x) (write x p)]
[(symbol? x) (display x p)]
;; generic fallback
[else (error 'output "don't know how to render value: ~v" x)]))
(void))