Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

+9 votes
in Syntax and reader by

= has a single arity returning true. Should it also have a 0 arity returning true as well?

This would be in line with the results of (and), (or), (every? odd []). And would make (apply = coll) safe in all cases, even when coll was empty.

From slack:
> Agreed - I had an #(->> xs ... (apply =)) in a fdef spec and it was failing in the case when xs is empty, forcing me to write a more verbose function.

by
I like that! "For all a, b in c, a = b" is vacuously true for c = empty.
Also presumeably `not=` would also have a zero-arity (and return false)

1 Answer

0 votes
by

What does it mean to compare 0 things?

by
How is this different from adding, and-ing or or-ing 0 things?
by
edited by
Reminds me of an old Swedish joke. Roughly translates to:

- What's the difference between a fish?
- It can neither ride a bicycle!
by
All elements in a empty collection is as equal all elements in a collection of one. Nothing is compared. All elements are as ordered as in a empty collections as in a collection of one. Nothing is compared. I think = < > <= >= should be true on nothing.
...