Intervals

Intervals

> LeekScript

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

It can be right- and/or left-bounded and right- and/or left-closed.

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

Creation

Intervals are created using the following syntax:

Reading

The following functions are used to retrieve information about the interval:

Search

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

Operations

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

Iteration

It's possible to iterate over an interval, allowing you to write a for loop in a more concise and readable way: ``leekscript for (var x in [3..10[) { debug(x) // displays 3, 4, 5, 6, 7, 8, 9 (because 10 is excluded) }

Conversions

It is possible to convert an interval into a list: