divide/list returns empty list for pure hash tables with one entry
Closed this issue · 3 comments
divide returns nil as the first value and the hash table's single entry as the second value, but it looks like divide/list assumes the opposite: https://github.com/fare/lisp-interface-library/blob/master/pure/hash-table-implementation.lisp#L128-L129
Test to demonstrate:
DalekBaldwin@de1d566
Oops. Can you send me a patch, including adding a regression test to the test suite?
I'm not familiar enough with the internals to be confident fixing it by myself. It looks like this would work:
(defmethod divide/list ((i <hash-table>) map)
(let ((list (divide/list (hashmap-interface i) map)))
(if (cdr list)
list
(multiple-value-bind (a b) (divide i map)
(declare (ignore a))
(if (empty-p (hashmap-interface i) b)
nil
(list b))))))
But I don't know for certain if the nil value will always be the first value, or if there are rare cases where this won't work.
ignoring a is obviously wrong. I reimplemented that method to use divide/list on the bucketmap where appropriate.
I added better tests for divide and divide/list, and also found and fixed issues with dividing trie's.
Finally, I improved the docstring for divide.