Skip to content

Commit

Permalink
Fix Exercise 2.54 (thanks to Assem Medhat)
Browse files Browse the repository at this point in the history
  • Loading branch information
mk12 committed Feb 15, 2024
1 parent 23d9e05 commit 1837877
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions docs/exercise/2/3.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/sicp/chapter-2.ss
Original file line number Diff line number Diff line change
Expand Up @@ -1690,14 +1690,14 @@ one-through-four => '(1 2 3 4)
(Exercise ?2.54)

(define (equal? list1 list2)
(let ((null1 (null? list1))
(null2 (null? list2)))
(or (and null1 null2)
(and (not (or null1 null2))
(eq? (car list1) (car list2))
(equal? (cdr list1) (cdr list2))))))
(cond ((null? list1) (null? list2))
((not (pair? list1)) (eq? list1 list2))
(else (and (pair? list2)
(equal? (car list1) (car list2))
(equal? (cdr list1) (cdr list2))))))

(equal? '(this is a list) '(this is a list)) => #t
(equal? '(this (is a) list) '(this (is a) list)) => #t
(equal? '(this is a list) '(this (is a) list)) => #f

(Exercise ?2.55)
Expand Down

0 comments on commit 1837877

Please sign in to comment.