diff options
author | Leah Neukirchen <leah@vuxu.org> | 2022-10-14 21:37:59 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-10-14 21:37:59 +0200 |
commit | 5e457544ba598a20b07b4506146363556e2bb435 (patch) | |
tree | 8aa49ca7b2f83d07d6d5cd18caf55ceeea237a6d /mew.scm | |
parent | 552e8c98e555d7784d2c145956324ea1b3b288fa (diff) | |
download | mew-5e457544ba598a20b07b4506146363556e2bb435.tar.gz mew-5e457544ba598a20b07b4506146363556e2bb435.tar.xz mew-5e457544ba598a20b07b4506146363556e2bb435.zip |
add gen
Diffstat (limited to 'mew.scm')
-rw-r--r-- | mew.scm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/mew.scm b/mew.scm index 8de6ed5..0cfe2f2 100644 --- a/mew.scm +++ b/mew.scm @@ -4,7 +4,7 @@ dec def div empty? eof esc fin final for generic-for-each - get gfix giterate gmatch gsplit gwindow + get gen gfix giterate gmatch gsplit gwindow inc keys keyvals len loc @@ -37,6 +37,7 @@ matchable) (reexport srfi-1) + (reexport srfi-69) (reexport srfi-158) (reexport (rename (srfi-158) @@ -391,4 +392,17 @@ (read-string #f (current-input-port))))) (else (error "no slurp defined")))) + (def (hash-table->generator h) + (make-for-each-generator (lambda (f t) + (hash-table-for-each t (lambda (k v) + (f (list k v))))) + h)) + + (def (gen o . rest) + (cond ((list? o) (apply list->generator o rest)) + ((vector? o) (apply vector->generator o rest)) + ((string? o) (apply string->generator o rest)) + ((hash-table? o) (apply hash-table->generator o rest)) + ((procedure? o) o) + (else (error "no gen defined")))) ) |