between

Syntax

between(X, Y)

Arguments

X is a scalar/pair/vector/matrix.

Y is a pair indicating a range.

Details

Check if each element of X is between the pair indicated by Y (both boundaries are inclusive). The result is of the same dimension as X.

Examples

between([1, 5.5, 6, 8], 1:6);
// output
[1,1,1,0] // 1, 5.5 and 6 are between 1 and 6, but 8 is not.

between(1 2.4 3.6 2 3.9, 2.4:3.6);
// output
[0,1,1,0,0]

between can be used with select to filter columns:

t = table(`abb`aac`aaa as sym, 1.8 2.3 3.7 as price);
select * from t where price between 1:3;
sym price
abb 1.8
aac 2.3

The following example explains how NULL values of Y are handled.

If the configuration parameter nullAsMinValueForComparison is set to true, NULL values are treated as the minimum value of the current data type. Otherwise NULL values are processed as NULL and the comparison returns NULL.

between can also be used with template nullCompare, and the result of comparison involving NULL is always NULL, regardless of the nullAsMinValueForComparison setting.

between(10,:10)
// output
true      // when nullAsMinValueForComparison=true

between(10,:10)
// output
NULL     // when nullAsMinValueForComparison=false

nullCompare(between, 10, :10)
// output
NULL