initial item of each prior ': match

https://learninghub.kx.com/forums/topic/initial-item-of-each-prior-match

the example is taken from the Q for mortals each prior section:


q)(~':) 1 1 1 2 2 3 4 5 5 5 6 6 

011010001101b


was wondering why the first out is 0b instead of integer 1, given each prior returns initial item of the input list? or it is 0b since there is nothing to compare 1 to?


in general, is it the case (~':) list  always output 0 as the first element of the output?


thanks!

Printing the values being passed each time you can see a null 0N is passed for the first value of y

q)({-1 .Q.s1 (x;y;x~y);x~y}':) 1 1 1 2 2 3 4 5 5 5 6 6
(1;0N;0b)
(1;1;1b)
(1;1;1b)
(2;1;0b)
(2;2;1b)
(3;2;0b)
(4;3;0b)
(5;4;0b)
(5;5;1b)
(5;5;1b)
(6;5;0b)
(6;6;1b)
011010001101b

We can also we with prev and next that nulls are padded as needed:

q)prev 1 2 3
0N 1 2
q)next 1 2 3
2 3 0N

I see, thanks!