Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify array equality #803

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions exercises/concept/key-comparison/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,21 @@ because even with an equality predicate that will look inside of a cons, it may

## 6. The maze of arrays

This maze is simpler with only two rooms. The first needs a key that checks if the arrays contain the equal contents. The second needs a key that is more flexible about checking equality of numbers.
This maze is simpler with only two rooms.
The first needs a key that checks if the arrays are the same arrays.
The second needs a key that will check the contents of the arrays.

For example:

```lisp
a ; => #[13 23]
b ; => #[13 23.0]
b ; => #[13 23]
c ; => #[13 23.0]

(key-arrays a b) ; => NIL
(key-arrays a c) ; => NIL
(key-arrays-loosely a b) ; => T
(key-arrays-loosely a c) ; => T
```

because a permissive equality predicate will not consider numeric type when comparing the contents of an array.
because only very permissive equality checkers will check that if the contents of the array are equal.
2 changes: 1 addition & 1 deletion exercises/concept/key-comparison/key-comparison-test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
finally (return 'room-explodes))))

(defparameter +an-array+ #(1 2 3))
(defparameter +a-similar-but-different-array+ #(1 2 3))
(defparameter +a-similar-but-different-array+ #(1 2.0 3))
(defparameter +a-different-array+ #(1 2 4))

(defparameter +rooms+
Expand Down