In Racket (and other Schemes, from what I can tell), the only way I know of to check whether two things are not equal is to explicitly apply not
to the test:
(not (= num1 num2))
(not (equal? string1 string2))
It's obviously (not (that-big-of-deal?))
, but it's such a common construction that I feel like I must be overlooking a reason why it's not built in.
One possible reason, I suppose, is that you can frequently get rid of the not
by using unless
instead of when
, or by switching the order of the true/false branches in an if
statement. But sometimes that just doesn't mimic the reasoning that you're trying to convey.
Also, I know the negated functions are easy to define, but so is <=
, for example, and that is built in.
What are the design decisions for not having things like not-equal?
, not-eqv?
, not-eq?
and !=
in the standard library?
/=
operator for integer equality, but not an operator likenot-equal
ornequal
etc. The designers of Scheme were evidently more interested in purity of the language, those of Common Lisp in practicity, but they had to stop somewhere... – Spermicide