How to get range of elements in a list in KDB?
问题 For example, I have this list: test:(8;12;15;19;10) How may I select elements 2 to 4? When I try list[2;4] it doesn't work for me. 回答1: indexing a list is by far the fastest way. q)a 8 1 9 5 4 6 6 1 8 5 4 9 2 7 0 1 9 2 1 8 8 1 7 2 4 5 4 2 7 8 5 6 4 1 3 3 7 8 2.. q)\t do[100000;2 3 sublist a] 109 q)\t do[100000;a 2 3 4] 15 So just follow your list with a list of indexes. BTW you can create indexes with til q)til 2 0 1 q)2+til 2 2 3 回答2: You can use sublist for this test:(8;12;15;19;10); 2 3