change dictionary interface
This commit is contained in:
parent
8b9a3f513a
commit
1ac0ccb05e
|
@ -1 +1 @@
|
|||
Subproject commit 8c174cd505aa4fc3b7937819506423b39b405216
|
||||
Subproject commit dd80aff03ab36fea0633e0e449c71fd489bc738a
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue