An edge detector detects transitions between two symbols in the input sequence, say 0 and 1.
It outputs 0 as long as the most recent input symbol is the same as the previous one.
However, when the most recent one differs from the previous one, it outputs a 1.
By convention, the edge detector always outputs 0 after reading the very first symbol.
(let ((previous)) (defun edge-detector (input) (let ((output 0)) (when (and (not (null previous)) (/= previous input)) (setf output 1)) (setf previous input) (return-from edge-detector output))))