sublist on an array

Hi KDB Group,

I am try to get a extract a subset of a list using sublist but it doesn’t works for a list with size greater than 1 if I specifly sublist[start, length]

For instance if I want to extract the first 2 number from the list it works

2 sublist (1 2 3 4)>> 1 2i2 sublist ' (1 2 3 4; 5 6 7 8)>> (1 2; 5 6)

However if I use the second argument it doesn’t work
2 2 sublist (1 2 3 4)>> 2 3i / works!2 2 sublist ' (1 2 3 4; 5 6 7 8)>> (1 2; 5 6) / incorrect - was expecting (2 3; 6 7)

for larger list it returns an error

2 2 sublist ' (1 2 3 4; 5 6 7 8; 9 10 11 12)>> 'length

of course I could use the take and drop

2# ' 1_ ' (1 2 3 4;5 6 7 8;9 10 11 12)>> (2 3; 5 6; 10 11)

However I think it is probably more optimized and clearer code using sublist.

Can anyone help?

Thanks

David

You need each-right (/:) not each both (')

2 2 sublist/: (1 2 3 4;5 6 7 8)

’ can sometimes tell what you want to do but not here

|

From: David Bieber

Sent: Tuesday, June 14, 2016 13:05

To: Kdb+ Personal Developers

Reply To: personal-kdbplus@googlegroups.com

Subject: [personal kdb+] sublist on an array

|

Hi KDB Group,

I am try to get a extract a subset of a list using sublist but it doesn’t works for a list with size greater than 1 if I specifly sublist[start, length]

For instance if I want to extract the first 2 number from the list it works

2 sublist(1234)>>12i2 sublist' (1 2 3 4; 5 6 7 8)>> (1 2; 5 6)

However if I use the second argument it doesn’t work
22 sublist(1234)>>23i/ works!22 sublist' (1 2 3 4; 5 6 7 8)>> (1 2; 5 6) / incorrect - was expecting (2 3; 6 7)

for larger list it returns an error

22 sublist' (1 2 3 4; 5 6 7 8; 9 10 11 12)>> 'length

of course I could use the take and drop

2# ' 1_ ' (1 2 3 4;5 6 7 8;9 10 11 12)>>(23;56;1011)

However I think it is probably more optimized and clearer code using sublist.

Can anyone help?

Thanks

David


Submitted via Google Groups

Many thanks. Perfect. D