User Tools


Function SEARCH

Syntax

  • search sequence-1 sequence-2 &key from-end test test-not key start1 start2 end1 end2position

Arguments and Values

Description

Searches sequence-2 for a subsequence that matches sequence-1.

The implementation may choose to search sequence-2 in any order; there is no guarantee on the number of times the test is made. For example, when start-end is true, the sequence might actually be searched from left to right instead of from right to left (but in either case would return the rightmost matching subsequence). If the search succeeds, search returns the offset into sequence-2 of the first element of the leftmost or rightmost matching subsequence, depending on from-end; otherwise search returns nil.

If from-end is true, the index of the leftmost element of the rightmost matching subsequence is returned.

Examples

(search "dog" "it's a dog's life")

7

(search '(0 1) '(2 4 6 1 3 5) :key #'oddp)

2

Side Effects

None.

Affected By

None.

Exceptional Situations

None.

See Also

  • {\secref\TraversalRules}

Notes

The :test-not argument is deprecated.

\issue{SUBSEQ-OUT-OF-BOUNDS} \issue{RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL} \issue{MAPPING-DESTRUCTIVE-INTERACTION:EXPLICITLY-VAGUE} \issue{TEST-NOT-IF-NOT:FLUSH-ALL}