between(X, Y)


X is a scalar/pair/vector/matrix.

Y is a pair indicating a range.


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.


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

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.

// output
true      // when nullAsMinValueForComparison=true

// output
NULL     // when nullAsMinValueForComparison=false

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