diff options
Diffstat (limited to 'mew.scm')
-rw-r--r-- | mew.scm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/mew.scm b/mew.scm index 7f491b9..4caebd1 100644 --- a/mew.scm +++ b/mew.scm @@ -11,7 +11,7 @@ imp inc inject into juxt keys - len loc + len lines loc mod negate odometer one-of op op* @@ -823,6 +823,22 @@ (read-string #f (current-input-port))))) (else (error "no slurp defined")))) + (define lines + (case-lambda + (() read-line) + ((x) (cond ((input-port? x) + (lambda () + (read-line x))) + ((string? x) + (let ((file (open-input-file x))) + (lambda () + (let ((line (read-line file))) + (when (eof-object? line) + (close-input-port file)) + line)))) + (else + (error "can't read lines")))))) + (define (hash-table->generator h) (make-for-each-generator (lambda (f t) (hash-table-for-each t (lambda (k v) |