[bugfix] interleave newline

This commit is contained in:
Yuichi Nishiwaki 2014-07-29 15:57:26 +09:00
parent 1a891036f2
commit 48b5d6b578
1 changed files with 9 additions and 3 deletions

View File

@ -6,13 +6,19 @@
(scheme eval)
(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)
(with-input-from-file file
(lambda ()
(let loop ((line (read-line)))
(let loop ((line (read-line)) (acc '()))
(if (eof-object? line)
""
(string-append line (loop (read-line))))))))
(join "\n" (reverse acc))
(loop (read-line) (cons line acc)))))))
(define (print obj . port)
(let ((port (if (null? port) (current-output-port) (car port))))