(define (null-list? l)
(cond ((pair? l) #f)
((null? l) #t)
(else (error "null-list?: argument out of domain" l))))
(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) ; EQ? => LIST=
(lp1 list-b others)
(let lp2 ((list-a list-a) (list-b list-b))
(if (null-list? list-a)
(and (null-list? list-b)
(lp1 list-b others))
(and (not (null-list? list-b))
(= (car list-a) (car list-b))
(lp2 (cdr list-a) (cdr list-b)))))))))))
(list= eq? '(a) '(a))
;Value: #t
(list= eq? '(a) '(a) '(a))
;Value: #f
(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) ; EQ? => LIST=
(lp1 list-b others)
(let lp2 ((list-a-1 list-a) (list-b-1 list-b))
(if (null-list? list-a-1)
(and (null-list? list-b-1)
(lp1 list-b others))
(and (not (null-list? list-b-1))
(= (car list-a-1) (car list-b-1))
(lp2 (cdr list-a-1) (cdr list-b-1)))))))))))
(list= eq? '(a) '(a))
;Value: #t
(list= eq? '(a) '(a) '(a))
;Value: #t