diff options
author | Leah Neukirchen <leah@vuxu.org> | 2022-10-12 23:42:39 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-10-12 23:42:39 +0200 |
commit | 3ca5a64ec4b2d2cbabc597d68cb7da756a720bf4 (patch) | |
tree | 29499aa9671e16e71fba2afbff3390e7edf0ecc2 | |
parent | ca502244997f84361700223291614a67578fd53c (diff) | |
download | mew-3ca5a64ec4b2d2cbabc597d68cb7da756a720bf4.tar.gz mew-3ca5a64ec4b2d2cbabc597d68cb7da756a720bf4.tar.xz mew-3ca5a64ec4b2d2cbabc597d68cb7da756a720bf4.zip |
add keys, vals, keyvals
-rw-r--r-- | mew.scm | 9 | ||||
-rw-r--r-- | mew.svnwiki | 12 |
2 files changed, 19 insertions, 2 deletions
diff --git a/mew.scm b/mew.scm index 63fe266..f2d94b5 100644 --- a/mew.scm +++ b/mew.scm @@ -1,11 +1,13 @@ -(module mew (at dec def div empty? esc fin get inc loc mod nth op prn puts rep str tbl while until) +(module mew (at dec def div empty? esc fin get inc keys keyvals loc mod nth op prn puts rep str tbl while until vals) (import scheme (rename (chicken base) (print puts)) (chicken module) (chicken port) srfi-17 - srfi-69 + (rename (srfi-69) + (hash-table-keys keys) + (hash-table-values vals)) matchable) (reexport @@ -155,6 +157,9 @@ (define (tbl . kvs) (alist->hash-table (kvs->alist kvs))) + (define (keyvals h) + (reverse (hash-table-fold h (lambda (k v l) (cons v (cons k l))) '()))) + (define (empty? o) (or (null? o) (equal? o "") diff --git a/mew.svnwiki b/mew.svnwiki index add3bb4..a12c64d 100644 --- a/mew.svnwiki +++ b/mew.svnwiki @@ -133,6 +133,18 @@ hash-tables, strings. Construct a hash-table; using {{equal?}}. +<procedure>(keys <hash-table>)</procedure> + +Alias for {{hash-table-keys}}. + +<procedure>(vals <hash-table>)</procedure> + +Alias for {{hash-table-values}}. + +<procedure>(keyvals <hash-table>)</procedure> + +Return a list of alternating keys and values of the hash table. + <procedure>(empty? <obj>)</procedure> Test if {{<obj>}} is an empty list/string/vector/hash-table. |