These functions search for elements or subsequences in a sequence.
cl-assoc; see Lists.)
This function searches seq for an element matching item. If it finds a match, it returns the matching element. Otherwise, it returns
nil. It returns the leftmost match, unless
:from-endis true, in which case it returns the rightmost match. The
:endarguments may be used to limit the range of elements that are searched.
This function is like
cl-find, except that it returns the integer position in the sequence of the matching item rather than the item itself. The position is relative to the start of the sequence as a whole, even if
:startis non-zero. The function returns
nilif no matching element was found.
This function returns the number of elements of seq which match item. The result is always a nonnegative integer.
functions are defined similarly.
This function compares the specified parts of seq1 and seq2. If they are the same length and the corresponding elements match (according to
:key), the function returns
nil. If there is a mismatch, the function returns the index (relative to seq1) of the first mismatching element. This will be the leftmost pair of elements that do not match, or the position at which the shorter of the two otherwise-matching sequences runs out.
:from-endis true, then the elements are compared from right to left starting at
). If the sequences differ, then one plus the index of the rightmost difference (relative to seq1) is returned.
An interesting example is
(cl-mismatch str1 str2 :key 'upcase), which compares two strings case-insensitively.
This function searches seq2 for a subsequence that matches seq1 (or part of it specified by
:end1). Only matches that fall entirely within the region defined by
:end2will be considered. The return value is the index of the leftmost element of the leftmost match, relative to the start of seq2, or
nilif no matches were found. If
:from-endis true, the function finds the rightmost matching subsequence.