add dictionary.scm

This commit is contained in:
Yuichi Nishiwaki 2014-07-13 12:18:39 +09:00
parent 88593b1f9d
commit 71677d3e85
2 changed files with 32 additions and 0 deletions

View File

@ -1,5 +1,6 @@
list(APPEND PICLIB_SCHEME_LIBS
${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/8.scm
${PROJECT_SOURCE_DIR}/piclib/srfi/26.scm

View File

@ -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))