2022.10.11 03:55 AM
In the below code, I can understand the meaning of (<), but cannot understand the meaning of (';~:;<). Why line 3 keeps 4 rows, while line 4 keeps 6 rows? What is the meaning of "~:" here?
t:([] c1:`a`b`c`d`e`f; c2:1 1 1 2 2 2; c3:10 20 30 40 50 60);
?[t;enlist((<);`c3;(44));0b;`symbol$()]; // I can understand this
?[t;enlist((';~:;<);`c3;({y-x};(min;15 25 35 45);44));0b;`symbol$()]; // why keep 4 rows?
?[t;enlist((';~:;<);`c3;({y-x};(min;35 45);44));0b;`symbol$()]; // why keep 6 rows?
2022.10.11 04:14 AM
The queries are the functional equivalents of:
select from t where c3<44
select from t where c3>={y-x}[min 15 25 35 45;44]
select from t where c3>={y-x}[min 35 45;44]
In the 2nd example, min 15 25 35 45 evaluates to 15, {y-x}[15;44] is 29, and the condition c3>=29 is true for 4 rows.
In the 3rd example, min 35 45 is 35, {y-x}[35;44] is 9 and all rows satisfy c3>=9.
In the functional form, (';~;<) is just the representation of >=. If you type >= at the console, you can see it comes back as ~<, which is the composition of the operators ~ (not) and < (less than). The functional form includes the ' (composition) operator.
2022.10.11 04:14 AM
The queries are the functional equivalents of:
select from t where c3<44
select from t where c3>={y-x}[min 15 25 35 45;44]
select from t where c3>={y-x}[min 35 45;44]
In the 2nd example, min 15 25 35 45 evaluates to 15, {y-x}[15;44] is 29, and the condition c3>=29 is true for 4 rows.
In the 3rd example, min 35 45 is 35, {y-x}[35;44] is 9 and all rows satisfy c3>=9.
In the functional form, (';~;<) is just the representation of >=. If you type >= at the console, you can see it comes back as ~<, which is the composition of the operators ~ (not) and < (less than). The functional form includes the ' (composition) operator.
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.