add dictionary.scm
This commit is contained in:
parent
88593b1f9d
commit
71677d3e85
|
@ -1,5 +1,6 @@
|
||||||
list(APPEND PICLIB_SCHEME_LIBS
|
list(APPEND PICLIB_SCHEME_LIBS
|
||||||
${PROJECT_SOURCE_DIR}/piclib/built-in.scm
|
${PROJECT_SOURCE_DIR}/piclib/built-in.scm
|
||||||
|
${PROJECT_SOURCE_DIR}/piclib/picrin/dictionary.scm
|
||||||
${PROJECT_SOURCE_DIR}/piclib/srfi/1.scm
|
${PROJECT_SOURCE_DIR}/piclib/srfi/1.scm
|
||||||
${PROJECT_SOURCE_DIR}/piclib/srfi/8.scm
|
${PROJECT_SOURCE_DIR}/piclib/srfi/8.scm
|
||||||
${PROJECT_SOURCE_DIR}/piclib/srfi/26.scm
|
${PROJECT_SOURCE_DIR}/piclib/srfi/26.scm
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
(define-library (picrin dictionary)
|
||||||
|
(import (scheme base))
|
||||||
|
|
||||||
|
(define (dictionary->plist dict)
|
||||||
|
(error "not implemented"))
|
||||||
|
|
||||||
|
(define (plist->dictionary plist)
|
||||||
|
(let ((dict (make-dictionary)))
|
||||||
|
(do ((kv plist (cddr kv)))
|
||||||
|
((null? kv)
|
||||||
|
dict)
|
||||||
|
(dictionary-set! dict (car kv) (cadr kv)))))
|
||||||
|
|
||||||
|
(define (dictionary->alist dict)
|
||||||
|
(error "not implemented"))
|
||||||
|
|
||||||
|
(define (alist->dictionary alist)
|
||||||
|
(let ((dict (make-dictionary)))
|
||||||
|
(do ((kv alist (cdr kv)))
|
||||||
|
((null? kv)
|
||||||
|
dict)
|
||||||
|
(dictionary-set! dict (car kv) (cdr kv)))))
|
||||||
|
|
||||||
|
(define (dictionary . plist)
|
||||||
|
(plist->dictionary plist))
|
||||||
|
|
||||||
|
(export dictionary
|
||||||
|
dictionary->plist
|
||||||
|
plist->dictionary
|
||||||
|
dictionary->alist
|
||||||
|
alist->dictionary))
|
Loading…
Reference in New Issue