2022.10.11 07:34 AM
In below code, a1 doesn't work. Any ideas why?
myObj: (5 7; (`a; `b ; (4 5)));
a3:.[myObj; 1 2 1; {count x}]; // i.e. ((5 7);(`a;`b;4 1))
a2:.[myObj; 1 2; {count x}]; // i.e. ((5 7);(`a;`b;2))
a1:.[myObj; 1; {count x}]; // i.e. it doesn't work
a0:.[myObj; (); {count x}]; // i.e. 2
2022.10.11 07:45 AM
It's because the dot operator always requires a list as the index. 1 2 1, 1 2 and () are lists, 1 is not. It works if you enlist it.
a1:.[myObj; enlist 1; {count x}];
2022.10.11 07:45 AM
It's because the dot operator always requires a list as the index. 1 2 1, 1 2 and () are lists, 1 is not. It works if you enlist it.
a1:.[myObj; enlist 1; {count x}];
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.