Intervals

Intervals

> LeekScript

An interval [a..b] represents a set of numbers between two bounds a and b. In LeekScript, there are real intervals and integer intervals.

It can be bounded on the right and/or on the left, and closed on the right and/or on the left.

Intervals can be used to represent a continuous series of numbers in an optimized way.

Creation

Intervals are created with the following syntax:

Reading

The following functions give you information about the interval:

Search

There are two ways to check whether a number is in an interval:

Operations

Several operations are available on intervals: intersection and combination (similar to union).

Iteration

You can iterate over an interval, which lets you write a for loop in a more concise and readable way:

Equivalent to:

Conversions

You can convert an interval into a list: