[Snow-users-list] srfi-1 list= bug
Shiro Kawai
shiro at lava.net
Sat Aug 18 02:30:10 EDT 2007
Hi there,
Recently a user of Gauche pointed out a bug of list=, which
is actually originated from the reference implementation of
srfi-1. I think the same bug is still in snow's srfi1
package (1.0.15). Try this:
(list= = '(1 2 3) '(1 2 3) '(1 2 3))
Here's a fixed version in Gauche. The point is that you have
to preserve either list-a or list-b in order to loop over
lp1 again.
(define (list= = . lists)
(or (null? lists) ; special case
(let lp1 ((list-a (car lists))
(others (cdr lists)))
(or (null? others)
(let ((list-b (car others))
(others (cdr others)))
(if (eq? list-a list-b)
(lp1 list-b others)
(let lp2 ((list-a list-a) (list-c list-b))
(if (null-list? list-a)
(and (null-list? list-c)
(lp1 list-b others))
(and (not (null-list? list-c))
(= (car list-a) (car list-c))
(lp2 (cdr list-a) (cdr list-c)))))))))))
--shiro
More information about the Snow-users-list
mailing list