0

What languages (if any) support the syntax:

a < b < c

where this evaluates as "a is less than b and b is less than c"?

Why do so many languages lack this feature?

A Frayed Knot
  • 476
  • 5
  • 20
  • Possible duplicate of [Why are interval comparisons (e.g: x < variable < y) not supported in most "mainstream" languages?](https://stackoverflow.com/questions/11468317/why-are-interval-comparisons-e-g-x-variable-y-not-supported-in-most-main) – A Frayed Knot Jun 13 '19 at 18:21

1 Answers1

1

Python is definitely one!
And Clojure according to https://til.hashrocket.com/posts/tceb6f2vxe-interval-comparison-in-javascript
See How do I check whether an int is between the two numbers? => this is called "interval comparison."
See also Why are interval comparisons (e.g: x < variable < y) not supported in most "mainstream" languages?

B. Go
  • 1,436
  • 4
  • 15
  • 22
  • Thanks! I just flagged my question as a duplicate of the one you linked. Had I known to call it "interval comparisons" I would have found it. – A Frayed Knot Jun 13 '19 at 18:23