scheme - Why are `not-equal?` and similar negated comparisons not built into Racket? -
in racket (and other schemes, can tell), way know of check whether 2 things not equal explicitly apply not
test:
(not (= num1 num2)) (not (equal? string1 string2))
it's (not (that-big-of-deal?))
, it's such common construction feel must overlooking reason why it's not built in.
one possible reason, suppose, can rid of not
using unless
instead of when
, or switching order of true/false branches in if
statement. doesn't mimic reasoning you're trying convey.
also, know negated functions easy define, <=
, example, , built in.
what design decisions not having things not-equal?
, not-eqv?
, not-eq?
, !=
in standard library?
first, correct (not (that-big-of-a-deal?))
1
the reason racket doesn't include out of box because adds lot of primitives without benefit. admit lot of languages have !=
not equal, in java, if want deep equality check using equals()
(analogous equal?
in racket), have manually invert result !
yourself.
having both <=
, >
(as >=
, <
) convenient enough cause original designers of language include it.
so no, there isn't deep reason why there not shortcut having not-eq?
function built racket. adds more primitives , doesn't happen add benefit. still need not
exist on own anyway.
1i love pun way. have imaginary internet points.
Comments
Post a Comment