From a13ea07a3696d61b45b61b52d23c7085e3918e64 Mon Sep 17 00:00:00 2001 From: Mark Simpson Date: Wed, 3 Apr 2024 19:23:48 -0400 Subject: [PATCH 1/2] Make test inputs for array equality less similar Having `+an-array+` and `+a-similar-but-different-array+` *looking* like the same array led to the possible misconception that anything other than `equalp` would work `eq`, `eql` and `equal` all treat arrays as equal only if they `eq`. `equalp` treat arrays as equal if they are of the same size and their elements are `equalp`. So only `equalp` would work since `+an-array+` and `+a-similar-but-different-array+` were not `eq` even though they looked the same. Making them *more* dissimilar removes the possible confusion. --- exercises/concept/key-comparison/key-comparison-test.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/concept/key-comparison/key-comparison-test.lisp b/exercises/concept/key-comparison/key-comparison-test.lisp index dd7e1069..9c2337dd 100644 --- a/exercises/concept/key-comparison/key-comparison-test.lisp +++ b/exercises/concept/key-comparison/key-comparison-test.lisp @@ -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+ From 56199c766518edcfa183e39dfbf46d67ee100aa3 Mon Sep 17 00:00:00 2001 From: Mark Simpson Date: Wed, 3 Apr 2024 19:34:01 -0400 Subject: [PATCH 2/2] Clarifying the instructions for array equality --- .../concept/key-comparison/.docs/instructions.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/exercises/concept/key-comparison/.docs/instructions.md b/exercises/concept/key-comparison/.docs/instructions.md index 4516a817..85ea8cb1 100644 --- a/exercises/concept/key-comparison/.docs/instructions.md +++ b/exercises/concept/key-comparison/.docs/instructions.md @@ -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.