On Monday, November 18, 2013 12:29:10 AM UTC+1, reptile wrote:
#11 Count.. Sholud be 0/0N if no exist element?
thanks, there IS a question mark. yes, it is 0N(type flag here) if not exist, tests below seemed point another direction though, tying the guess game again
q)L5:(1;(100;200;(1000,2000,3000,4000)))
q)L5
1
(100;200;1000 2000 3000 4000)
q)count L5
2
q)count L5[1]
3
q)count L5[2]
1
q)count L5[3]
1
q)count L5[4]
1
q)count L5[5]
1
q)count L5[6]
1
q)count L5[7]
1
q)count L5[8]
1
q)
q)L5:(1;(100;200;(1000,2000,3000,4000)))
q)L5[7]
0N
q)count L5[7]
1
why returning 0N when not exist is a problem? don’t see obvious reasons to have it return () over 0N. (to be honest, I do see a reason and a better example to this point. but that’s out of the scope of this potential question)
q)L5:(1;(100;200;(1000;2000;3000;4000)))
q)L5
1
(100;200;1000 2000 3000 4000)
q)count L5[0]
1
q)count L5[1]
3
q)count L5[2]
1
q)count L5[3]
1
q)count L5[4]
1
q)count L5[5]
1
q)count L5[6]
1
q)count L5[7]
1
q)count L5[8]
1
q)L5[2]
0N
q)count L5[1][3]
1
q)count L5[1][2]
4
q)count L5[1][1]
1
q)count L5[1][0]
1
q)count L5[0][0]
'type
L5[0] is not a list
q)count L5[0][1]
'type
L5[0] is not a list
q)count L5[1][2]
4
q)count L5[1;2]
4
q)count L5[1;5]
1
q)count L5[1,2]
2
q)count L5[1,5]
2
q)count L5[1,1,1]
3
q)count L5[1,1,1,1]
4
q)L5[1,1,1,1]
100 200 1000 2000 3000 4000
100 200 1000 2000 3000 4000
100 200 1000 2000 3000 4000
100 200 1000 2000 3000 4000
q)L5[1,1,1,1;5]
q)count L5[1,1,1,1;5]
4
q)L5[1,1,1,1]
100 200 1000 2000 3000 4000
100 200 1000 2000 3000 4000
100 200 1000 2000 3000 4000
100 200 1000 2000 3000 4000
q)L5[1,1,1,1;5]
0N 0N 0N 0N
I think you know why the result is this, right?
q)L:(1;(100;200;(1000;2000;3000;4000)))
q)L[0]
1
q)L[1]
100
200
1000 2000 3000 4000
q)L[2]
0N
there’re only 2 elements in list L, their types are (j;J), therefore non-exist returns 0N
q)L[3]
0N
thanks for reading :)