clojure 2025-11-19

grumble grumble grumble, there’s no 0-ary version of distinct? so (apply distinct? some-list) fails if some-list is empty.

What should a hypothetical 0-arity distinct? return?

> arguments are not distinct if there is a repetition. there is no duplicate in an empty list So true I assume.

πŸ‘ 1
πŸ‘πŸ» 1

Yeah, plenty of such cases. But it makes sense, there's no identity element for distinct?. (+) returns 0 because it's its identity element, same for (*) and 1. Or (and) and true, or (or) and nil.

hmmm. not sure it makes sense. arguments are not distinct if there is a repetition. there is no duplicate in an empty list.

βž• 1

functions like every behave correctly on an empty sequence

i’m only using this for debugging so no great harm done.

on the other hand = cannot be called with 0 arguments

at least according to the documentation

I guess it could be argued any way. Maybe I'm wrong and identity values are completely irrelevant since distinct? is not an algebraic operation but a relational predicate, similar to =. In any case, if you'd like to see (distinct?) working, the best thing to do would be to create a post at https://ask.clojure.org. > functions like every behave correctly on an empty sequence every? is a sequence-function, not an item-based function, it doesn't require apply. And it's almost the same as (apply and (map pred coll)), and and has an identity value which is also true. Same with some - it works with empty colls and returns nil.

you probably have an alternative, but just in case, (if-let [l (seq some-list)] (apply distinct? l) true)

why request a core feature instead of just writing a helper fn

β€’ If it makes sense from the language design perspective, the language will become better β€’ If others need it, nobody will have to write the helper function anymore

πŸ‘ 3

Or (apply distinct? (or (seq some-list) [1]))

☝️ 1

I'd go with

((some-fn empty? (partial apply distinct?)) [])
true