# BooleanShiftsScans

From Kx Wiki

## Boolean Shifts and Scans

### Boolean Shifts

one and previous is one

(&)prior x

one and previous is zero

(>)prior x

zero and previous is one

(<)prior x

zero and previous is zero

not (|)prior x

previous bit is different

differ x

previous bit is same

not differ x

### Boolean Scans

ones until first zero from left

k)&\x mins x

ones after first zero from left

k)~&\x not mins x

zeros until first one from left

k)|\x maxs x

zeros after first one from left

k)~|\x not maxs x

ones until first zero from right

k)|&\|x reverse mins reverse x

ones after first zero from right

k)|~&\|x reverse not mins reverse x

zeros until first one from right

k)||\|x reverse maxs reverse x

zeros after first one from right

k)|~|\|x reverse not maxs reverse x

boolean finite state machine (switch state on 0)

k)(=)\x (=)scan x

ones and ones between ones

k)x|(~=)\x x or(<>)scan x

ones between ones

k)(~x)&(~=)\x (not x)and(<>)scan x