Commits

Anonymous committed 76c7c86

Remove equivalence parameterization option

  • Participants
  • Parent commits 9642b8f

Comments (0)

Files changed (1)

 (module trie
 
-(make-trie trie? trie-insert! trie-ref trie-ref* trie->list)
+(make-trie
+ trie?
+ trie-insert!
+ trie-ref
+ trie-ref*
+ trie-value
+ trie->list)
 
 (import chicken scheme)
 (use srfi-1 data-structures)
 
-(define-record trie eq? children value)
+(define-record trie children value)
 
 (define %make-trie make-trie)
 
-(define (make-trie #!optional (eq? eq?))
-  (%make-trie eq? (list) (list)))
+(define (make-trie)
+  (%make-trie (list) (list)))
 
 (define (add-child! trie key child)
   (trie-children-set!
-   trie (alist-update! key child (trie-children trie) (trie-eq? trie))))
+   trie (alist-cons key child (trie-children trie))))
 
 (define (trie-insert! trie key val)
   (let loop ((node trie)
     (if (null? key)
         (trie-value-set! node (list val))
         (let* ((ckey (car key))
-               (child (or (alist-ref ckey (trie-children node) (trie-eq? trie))
-                          (let ((child (make-trie (trie-eq? trie))))
+               (child (or (alist-ref ckey (trie-children node))
+                          (let ((child (make-trie)))
                             (add-child! node ckey child)
                             child))))
           (loop child (cdr key)))))
   (void))
 
 (define (trie-ref* trie key)
-  (alist-ref key (trie-children trie) (trie-eq? trie)))
+  (alist-ref key (trie-children trie)))
 
 (define (trie-ref trie key #!optional (default (constantly #f)))
   (let loop ((node trie)