golems / motion-grammar-kit

Formal Language Tools for Robots
BSD 2-Clause "Simplified" License
13 stars 5 forks source link

Trie implementation bug? #4

Closed Tarrasch closed 11 years ago

Tarrasch commented 11 years ago

Hello. I'm not entirely sure how to use the trie in src/util.lisp. Is it correct that nil is the "empty trie"? I mean does this definition make sense?

(defun trie-multiple-insert (lists)
  (fold #'trie-insert nil lists))

Using the trie I get this crash, but I'm not sure if I'm using it wrong or if the implementation is buggy.

MG> (setf my-trie (trie-insert nil '(a)))
; 
; caught WARNING:
;   undefined variable: MY-TRIE
; 
; compilation unit finished
;   Undefined variable:
;     MY-TRIE
;   caught 1 WARNING condition
(((A) NIL))
MG> my-trie 
(((A) NIL))
MG> (TRIE-INSERT my-trie '(a b)) 
error while parsing arguments to DESTRUCTURING-BIND:
  invalid number of elements in
    ()
  to satisfy lambda list
    (PREFIX &REST SUFFIXES):
  at least 1 expected, but 0 found
   [Condition of type SB-KERNEL::ARG-COUNT-ERROR]
; Evaluation aborted on NIL
ndantam commented 11 years ago

On 02/26/2013 07:51 PM, Arash Rouhani wrote:

error while parsing arguments to DESTRUCTURING-BIND: invalid number of elements in () to satisfy lambda list (PREFIX&REST SUFFIXES): at least 1 expected, but 0 found [Condition of type SB-KERNEL::ARG-COUNT-ERROR] ; Evaluation aborted on NIL

Was missing a case in trie-insert. Added that and some fuzz testing. Seems to be working now.

-ntd

Tarrasch commented 11 years ago

Seems to be working. Thanks!