[bugfix] interleave newline
This commit is contained in:
parent
1a891036f2
commit
48b5d6b578
|
@ -6,13 +6,19 @@
|
||||||
(scheme eval)
|
(scheme eval)
|
||||||
(scheme process-context))
|
(scheme process-context))
|
||||||
|
|
||||||
|
(define (join sep strs)
|
||||||
|
(let loop ((result (car strs)) (rest (cdr strs)))
|
||||||
|
(if (null? rest)
|
||||||
|
result
|
||||||
|
(loop (string-append result sep (car rest)) (cdr rest)))))
|
||||||
|
|
||||||
(define (file->string file)
|
(define (file->string file)
|
||||||
(with-input-from-file file
|
(with-input-from-file file
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let loop ((line (read-line)))
|
(let loop ((line (read-line)) (acc '()))
|
||||||
(if (eof-object? line)
|
(if (eof-object? line)
|
||||||
""
|
(join "\n" (reverse acc))
|
||||||
(string-append line (loop (read-line))))))))
|
(loop (read-line) (cons line acc)))))))
|
||||||
|
|
||||||
(define (print obj . port)
|
(define (print obj . port)
|
||||||
(let ((port (if (null? port) (current-output-port) (car port))))
|
(let ((port (if (null? port) (current-output-port) (car port))))
|
||||||
|
|
Loading…
Reference in New Issue