;; see OnLisp, Chp. 19. ;;(defvar hash (make-table string-hash #'equal)) ; hash-fun compare-fun ;;;; make-weak-table: members are subject to garbage collection ;;(table-set hash "aap" "noot") ;;(table-set hash "mies" "wim") ;;(table-set hash "zus" "jet") ;;(table-set hash "teun" "vuur") ;;(puts (table-ref hash "aap")) ; noot ;;(puts (table-bound-p hash "mies")) ; t ;;(table-unset hash "teun") ; remove entry ;;(table-walk ;; (lambda (key value) ;; (printf "%s -> %s\n" key value)) ;; hash) (require 'rep.data.tables) (defun make-db () (make-table symbol-hash #'equal)) (defvar *default-db* (make-db)) (defmacro db-query (key) `(table-ref ,*default-db* ,key)) (defun db-push (key val) (table-set *default-db* key val)) (defmacro fact (pred #!rest args) `(progn (db-push ',pred ',args) ',args)) ;; XXX incomplete and incorrect