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

Collection equality koan is confusing #158

Open
rosschapman opened this issue Sep 4, 2020 · 1 comment
Open

Collection equality koan is confusing #158

rosschapman opened this issue Sep 4, 2020 · 1 comment

Comments

@rosschapman
Copy link

rosschapman commented Sep 4, 2020

I was a bit confused by the koan here because switching the value order of the list elements causes the test to fail. I'd like to propose either changing the koan to reflect the Clojure guides more closely by saying "Equality with sequential collections is in terms of value and order" or add distinct challenges for both ordered and unordered lists. What do you think?

@nihilismus
Copy link

I would put it as "Equality between a list and a vector depends on the value and position of their elements".

Maps and Hashes can also be treated sequentially (map, filter & reduce), but their semantic when it comes to equality does not depend on position.

user=> (map identity (hash-map 10 20 30 40 50 60))
([50 60] [30 40] [10 20])
user=> (map identity (hash-set 10 20 30 40 50 60))
(20 60 50 40 30 10)
user=> (= (hash-map 10 20 30 40 50 60) (hash-map 30 40 10 20 50 60))
true
user=> (= (hash-set 10 20 30 40 50 60) (hash-set 30 50 10 20 40 60))
true
user=> (= (list 10) (hash-set 10))
false
user=> (= (vector 10) (hash-set 10))
false
user=> (= (list 10 20) (hash-map 10 20))
false
user=> (= (vector 10 20) (hash-map 10 20))
false
user=> (= (vector 10 20) (hash-map 0 10 1 20))
false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants