A start on dictionaries using srfi-69 hash tables.

This commit is contained in:
sforman 2023-08-10 21:49:37 -07:00
parent 19777a86ae
commit b6c3c364d0
1 changed files with 17 additions and 1 deletions

View File

@ -1,4 +1,5 @@
(import (chicken string))
(import srfi-69)
(define (joy stack expression dict)
(if (null? expression)
@ -81,6 +82,21 @@
(joy '() (text->expression text) '())
(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)