3 ms·
It's all about programming practice. I do like the suggestion `between(x1, x2)`.
by david90 11y ago
It's all about programming practice. I do like the suggestion `between(x1, x2)`.
- yitchelle 11y agoWhen someone says that, I always get confuse as to whether you meant an inclusive or an exclusive between. I think the mathematicians uses the square brackets to indicate that intention.
- Freak_NL 11y agoThat is exactly why we have <, <= (≤), >, and >= (≥) in programming languages. It is a lot less verbose than saying exclusiveBetween(x, 5, 10).
- Shengbo 11y agoThat could actually be an interesting linguistics problem. In spoken languages, "between" is usually inclusive unless context suggests otherwise. It can easily be a source of misunderstanding if the context clues are insufficient or the recipient has trouble picking up on them. I wonder if there are any languages that have different words for inclusive/exclusive "between" so people don't have to rely on implicit clues.
- mc808 11y agoOne possible convention would be to use "in-between" for the exclusive between. It's probably impossible to convince the whole English-speaking world to adopt it, but it would be more natural than "exclusive between" in code.
- TheAndruu 11y agoAgree. Perhaps it be better-named 'betweenInclusive(firstValue, secondValue)' and 'betweenExclusive(firstValue, secondValue)'
- agentultra 11y agoThere are a few notations for intervals in maths; https://en.wikipedia.org/wiki/Interval_%28mathematics%29 https://en.wikipedia.org/wiki/Interval_%28mathematics%29 There are arithmetic operators for intervals and IEEE standards! https://en.wikipedia.org/wiki/Interval_arithmetic#Elementary_functions https://en.wikipedia.org/wiki/Interval_arithmetic#Elementary...
- carlob 11y agohttps://reference.wolfram.com/language/ref/Between.html https://reference.wolfram.com/language/ref/Between.html Which is particularly useful for symbolically representing queries for entities. EntityClass["Element", "AtomicNumber" -> Between[{2, 3}]]