File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -75,11 +75,24 @@ rules provided in the r7rs-small specification.
75
75
(t (eq x y))))
76
76
77
77
; ;; TODO: Must always terminate even if the list is circular.
78
- ; ;;
79
- ; ;; TODO: recursively compare sequences
78
+ (defun list-equal? (x y)
79
+ (or (and (null x) (eql x y))
80
+ (and (equal? (car x) (car y))
81
+ (list-equal? (cdr x) (cdr y)))))
82
+
83
+ (defun vector-equal? (x y)
84
+ (and (typep y (type-of x))
85
+ (= (length x) (length y))
86
+ (loop :for a :across x
87
+ :for b :across y
88
+ :always (equal? a b))))
89
+
90
+ ; ;; TODO: use a sequence-generic comparison when extensible-sequences is used
80
91
(defun equal? (x y)
81
- ; ; TODO: Stub
82
- (eqv? x y))
92
+ (typecase x
93
+ (list (and (listp y) (list-equal? x y)))
94
+ (vector (and (vectorp y) (vector-equal? x y)))
95
+ (t (eqv? x y))))
83
96
84
97
(defun coerce-subseq (sequence result-type &optional start end)
85
98
" Coerces a subsequence into the result type"
You can’t perform that action at this time.
0 commit comments