'How does the scan operator help to identify indices where a rule holds for 2 observations in a row?

A boolean vector has been created based on some rule and we need to identify the indices where the rule holds for 2 observations in a row. The following code does that

indices:0101001101b
runs:{0 x\x}"f"$;
where 2=runs indices

Could you please help me understand how the scan operator is used in the definition of the runs function? Appreciate your help.

kdb


Solution 1:[1]

Terry has answered your question about how runs works.

Comparing adjacent items is common. You might prefer to use the prior keyword. Certainly easier to see what it is doing.

q)where (and) prior indices
,7

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SJT