diff options
Diffstat (limited to 'chicanery.extras.scm')
-rw-r--r-- | chicanery.extras.scm | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/chicanery.extras.scm b/chicanery.extras.scm index dac823f..f264424 100644 --- a/chicanery.extras.scm +++ b/chicanery.extras.scm | |||
@@ -113,17 +113,26 @@ | |||
113 | (eval sym (interaction-environment)) | 113 | (eval sym (interaction-environment)) |
114 | #t))))) | 114 | #t))))) |
115 | 115 | ||
116 | (define (displayed x) | 116 | (define (with-output-to-string thunk) |
117 | (call-with-port (open-output-string) | 117 | (call-with-port (open-output-string) |
118 | (lambda (port) | 118 | (lambda (port) |
119 | (display x port) | 119 | (parameterize ((current-output-port port)) |
120 | (thunk)) | ||
120 | (get-output-string port)))) | 121 | (get-output-string port)))) |
121 | 122 | ||
122 | (define (written x) | 123 | (define (with-input-from-string s thunk) |
123 | (call-with-port (open-output-string) | 124 | (call-with-port (open-input-string s) |
124 | (lambda (port) | 125 | (lambda (port) |
125 | (write x port) | 126 | (parameterize ((current-input-port port)) |
126 | (get-output-string port)))) | 127 | (thunk))))) |
128 | |||
129 | (define (displayed x) | ||
130 | (with-output-to-string | ||
131 | (lambda () (display x)))) | ||
132 | |||
133 | (define (written x) | ||
134 | (with-output-to-string | ||
135 | (lambda () (write x)))) | ||
127 | 136 | ||
128 | (define (print . xs) | 137 | (define (print . xs) |
129 | (for-each display xs) | 138 | (for-each display xs) |