1. A method for generating a result vector, comprising: receiving an input vector and a predicate vector, each including N elements; and generating the result vector, wherein generating the result vector comprises, for each element in a set of elements in the input vector for which a corresponding element of the predicate vector is active, determining if at least one of the elements in the set of elements precedes the element in the input vector and contains a different value than the element in the input vector; and if so, writing an identifier for a closest preceding active element that contains the different value into a corresponding element of a result vector; and if not, writing a zero in the corresponding element of the result vector.