A start on dictionaries using srfi-69 hash tables.
This commit is contained in:
parent
19777a86ae
commit
b6c3c364d0
|
|
@ -1,4 +1,5 @@
|
||||||
(import (chicken string))
|
(import (chicken string))
|
||||||
|
(import srfi-69)
|
||||||
|
|
||||||
(define (joy stack expression dict)
|
(define (joy stack expression dict)
|
||||||
(if (null? expression)
|
(if (null? expression)
|
||||||
|
|
@ -81,6 +82,21 @@
|
||||||
(joy '() (text->expression text) '())
|
(joy '() (text->expression text) '())
|
||||||
(joy-expression->string stack)))
|
(joy-expression->string stack)))
|
||||||
|
|
||||||
(display (doit "ab cd [[ ]] 23 4 - [true] false"))
|
|
||||||
|
(define (initialize defs dict)
|
||||||
|
(map (lambda (def) (add-def dict def)) (string-split defs "\n")))
|
||||||
|
|
||||||
|
(define (add-def def dict)
|
||||||
|
(let ((def_list (text->expression def)))
|
||||||
|
(hash-table-set! dict (car def_list) (cdr def_list))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(display (doit "ab cd [[ ]] 23 4 - dup - [true] false"))
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue