clojure

István Karaszi 2026-03-09T13:04:06.639249Z

https://clojure.atlassian.net/browse/CLJ-2747 - (distinct) on sets

István Karaszi 2026-03-10T10:36:33.132459Z

@nbtheduke I voted already :)

👍 1
István Karaszi 2026-03-10T13:16:10.278099Z

On the map question, I would be fine returning the MapEntry entries, I don’t mind. I am more worried about the set usage

István Karaszi 2026-03-09T13:05:11.732099Z

I would argue that this is not an improvement but a bug

István Karaszi 2026-03-09T13:06:53.360939Z

The documentation of (distinct) says that it accepts a collection

István Karaszi 2026-03-09T13:07:08.133689Z

Set is a collection:

(coll? #{:foo :bar})
;; => true

István Karaszi 2026-03-09T13:08:32.339389Z

I guess the Alternative 2 is a better solution because that should be faster for large sets

István Karaszi 2026-03-09T13:12:55.841569Z

I just ran into this today that my function was expecting a collection and when it received a set then it failed

István Karaszi 2026-03-09T16:56:08.853159Z

Of course map is also a collection but there I understand that we (distinct) does not accept that

István Karaszi 2026-03-09T16:56:43.106149Z

Although with the Alternative 1 that would return a list of MapEntry items

Yevgeni Tsodikov 2026-03-09T20:48:11.170539Z

> The documentation of (distinct) says that it accepts a collection Alternative 3: update the docstring 🙃

2026-03-09T22:19:32.447869Z

> Of course map is also a collection but there I understand that we (distinct) does not accept that What?! If we are going to stand on principle, let's not exempt maps. After all, what is a set but a degenerate map?! P.S. have you tried benchmarking distinct rewritten to use first (which is set-compatible) instead of destructuring to nab the first item?