in(X, Y)


X is a scalar/vector.

Y is a scalar, vector, dictionary, in-memory table with one column, keyed table, or indexed table.


If Y is a scalar:

  • If Y is of temporal types, check if each element in X is equal to Y;

  • If Y is a scalar of other data types, check if X and Y are equal.

If Y is a NULL value, return false.

If Y is a vector, check if each element of X is an element in Y.

If Y is a dictionary, check if each element of X is a key in the dictionary Y.

If Y is an in-memory table with one column, check if each element of X appears in the column of Y. Note the column cannot be of array vector form.

If Y is a keyed table or an indexed table, check if each element of X is a key of Y. The number of elements in X must equal the number of key columns of Y.


in(3 3 5 2, 2 3);
// output

x[1, 2, 3]=[4.5, 6.6, 3.2];
// output

in(1..6, x);
// output

t = table(1 3 5 7 9 as id)
2 3 in t
// output

kt = keyedTable(`name`id,1000:0,`name`id`age`department,[STRING,INT,INT,STRING])
insert into kt values(`Tom`Sam`Cindy`Emma`Nick, 1 2 3 4 5, 30 35 32 25 30, `IT`Finance`HR`HR`IT)
in((`Tom`Cindy, 1 3), kt);
// output

t1 = indexedTable(`sym`side, 10000:0, `sym`side`price`qty, [SYMBOL,CHAR,DOUBLE,INT])
insert into t1 values(`IBM`MSFT`GOOG, ['B','S','B'], 10.01 10.02 10.03, 10 10 20)
in((`IBM`MSFT, ['S','S']), t1);
// output

When X is a floating-point number and Y is an integer, X will be converted to the data type of Y.

in(10, NULL)
// output
in('a', 97)
// output
in(1, 1.1 1.2 1.3)
// output
in(float(1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8), 1..9)
// output

in can be used with select for range filtering.

select * from kt where name in [`Tom, `Cindy];
name id age department
Tom 1 30 IT
Cindy 3 32 HR

Related functions: find, binsrch.