Skip to content

IsIntervalMember ​

Tests whether x falls within the interval, honoring Open bounds.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageIntervalMemberQ✓
IsIntervalMember(Interval(lo, hi), x)True if lo (or) x (or) hi, closed by default, open where wrapped in Open(...)
Typed signatures
TypePackageApplies
(any, any) -> booleancombinatoricsalways

Domain: Collections

Details
  • Open(...) on either bound makes that side strict: IsIntervalMember(Interval(Open(1), 5), 1) is False.
  • Only a single Interval(lo, hi) -- Wolfram's union-of-intervals form Interval({a, b}, {c, d}, ...) isn't handled.
  • Bounds and x are compared as doubles (via N()) -- exact enough for membership, which only ever needs a comparison.
  • An Open(...) bound has no Wolfram transpilation: Wolfram's own Interval object is always closed (Interval[{min, max}] means min <= x <= max, with no open-bound notation at all), so an Open(...) example here stays untranslated rather than round-tripping to a Wolfram call that would silently test the wrong (closed) condition.

Examples

Basic #
live ↗
InIsIntervalMember(Interval(1,5),3)\mathrm{IsIntervalMember}(\mathrm{Interval}(1, 5), 3)OutTrue\mathrm{True}

An exact constant is tested against the endpoints: 2≤π≤52 \le \pi \le 5

live ↗
InIsIntervalMember(Interval(2,5),π)\mathrm{IsIntervalMember}(\mathrm{Interval}(2, 5), π)OutTrue\mathrm{True}
Scope #
live ↗
InIsIntervalMember(Interval(1,5),5)\mathrm{IsIntervalMember}(\mathrm{Interval}(1, 5), 5)OutTrue\mathrm{True}
live ↗
InIsIntervalMember((1,5],1)\mathrm{IsIntervalMember}((1, 5\rbrack, 1)OutFalse\mathrm{False}
live ↗
InIsIntervalMember(Interval(1,5),6)\mathrm{IsIntervalMember}(\mathrm{Interval}(1, 5), 6)OutFalse\mathrm{False}
About
Examples5
Checked againstWolfram Language 4 agree
CrosswalkWolfram Language

See also: IsTrue