ecl-logo Documentation

RangeP

RangeP[min,max]pattern

generates a pattern that will match a value between the provided min and max.

RangeP[min,max,increment]pattern

generates a pattern that will match a value greater than min by a multiple of increment and also less than max.

RangeP[increment]pattern

generates a pattern that will match any value that is a multiple of increment.

Details

  • The function is unit frendly, and if provided values that match CompatibleUnitQ, will Convert to a common form before performing the check.
  • Input
    Output
    General Options

Examples

Basic Examples  (5)

Returns a pattern that matches any quantity between the given lower and upper bounds:

Also accepts numeric values:

Also accepts DateObjects:

Additionaly specify an increment:

Match match any value that's a multiple of the increment:

Additional Examples  (15)

Specify an increment in numeric case:

Specify an increment in DateObject case:

Specify an increment in DateObject case:

Pattern does not match if given quantity is outside specified range:

Can handle different Units, provided they are compatibile:

Pattern does not match if Units are incompatible:

Pattern does not match if Units are incompatible:

Equality case matches:

Numeric values and quantities are incompatible:

Does not evaluate if range ends are incompatible:

Numeric values and quantities are incompatible:

Non-matching numeric case:

Infinite bounds match any compatible value:

Infinite bounds don't match incompatible units:

Function does not evaluate on other inputs:

Options  (3)

Inclusive  (3)

By default, both ends of the interval are inclusive comparisons:

Make only left edge of interval inclusive:

Make neither end of interval inclusive:

Possible Issues  (2)

Due to machine precision rounding errors, values are rounded to within 10^-12 of the increment value when compared:

Any difference larger than that amount will trigger a failure: