add check for empty second list in list= (fixes issue #407)

This commit is contained in:
Alex Shinn 2017-05-08 12:04:13 +09:00
parent fad9e4ca8b
commit 779c60ac35
2 changed files with 4 additions and 1 deletions

View file

@ -29,7 +29,8 @@
(if (null? ls1) (if (null? ls1)
(and (null? ls2) (and (null? ls2)
(lp1 (cdr lists))) (lp1 (cdr lists)))
(and (eq (car ls1) (car ls2)) (and (pair? ls2)
(eq (car ls1) (car ls2))
(lp2 (cdr ls1) (cdr ls2)))))))) (lp2 (cdr ls1) (cdr ls2))))))))
(define (length+ x) (define (length+ x)

View file

@ -32,6 +32,8 @@
(test #f (pair? 'a)) (test #f (pair? 'a))
(test #t (list= eq?)) (test #t (list= eq?))
(test #t (list= eq? '(a))) (test #t (list= eq? '(a)))
(test #f (list= = '(1 2) '(1 2 3)))
(test #f (list= = '(1 2 3) '(1 2)))
(test 'a (car '(a b c))) (test 'a (car '(a b c)))
(test '(b c) (cdr '(a b c))) (test '(b c) (cdr '(a b c)))
(test '(a) (car '((a) b c d))) (test '(a) (car '((a) b c d)))