change dictionary interface
This commit is contained in:
+1
-1
Submodule extlib/benz updated: 8c174cd505...dd80aff03a
@@ -441,8 +441,7 @@
|
||||
dictionary-ref
|
||||
dictionary-set!
|
||||
dictionary-delete
|
||||
dictionary-size
|
||||
dictionary-for-each)
|
||||
dictionary-size)
|
||||
|
||||
(export make-record
|
||||
record?
|
||||
|
||||
@@ -1,22 +1,6 @@
|
||||
(define-library (picrin dictionary)
|
||||
(import (picrin base))
|
||||
|
||||
(define (dictionary-map proc dict)
|
||||
(let ((kvs '()))
|
||||
(dictionary-for-each
|
||||
(lambda (key val)
|
||||
(set! kvs (cons (proc key val) kvs)))
|
||||
dict)
|
||||
(reverse kvs)))
|
||||
|
||||
(define (dictionary->plist dict)
|
||||
(let ((kvs '()))
|
||||
(dictionary-for-each
|
||||
(lambda (key val)
|
||||
(set! kvs (cons val (cons key kvs))))
|
||||
dict)
|
||||
(reverse kvs)))
|
||||
|
||||
(define (plist->dictionary plist)
|
||||
(let ((dict (make-dictionary)))
|
||||
(do ((kv plist (cddr kv)))
|
||||
@@ -24,12 +8,6 @@
|
||||
dict)
|
||||
(dictionary-set! dict (car kv) (cadr kv)))))
|
||||
|
||||
(define (dictionary->alist dict)
|
||||
(dictionary-map
|
||||
(lambda (key val)
|
||||
(cons key val))
|
||||
dict))
|
||||
|
||||
(define (alist->dictionary alist)
|
||||
(let ((dict (make-dictionary)))
|
||||
(do ((kv alist (cdr kv)))
|
||||
@@ -40,9 +18,12 @@
|
||||
(define (dictionary . plist)
|
||||
(plist->dictionary plist))
|
||||
|
||||
(export dictionary
|
||||
dictionary-map
|
||||
dictionary->plist
|
||||
(export dictionary?
|
||||
dictionary
|
||||
make-dictionary
|
||||
dictionary-ref
|
||||
dictionary-set!
|
||||
dictionary-delete
|
||||
dictionary-size
|
||||
plist->dictionary
|
||||
dictionary->alist
|
||||
alist->dictionary))
|
||||
|
||||
Reference in New Issue
Block a user