The -search- command discussed in Chapter 8 is character-string oriented and will locate `dog' even across variable or word boundaries: the “d” might be at the end of one word and the “og” at the beginning of the next word. The -find- command, in contrast, is word oriented. It will find which word contains a certain number or character string:
If n1 contains 372, n125 will return the value 0; if n2 is the first word which contains 372, n125 will be 1; etc. If none of the 50 words contains 372, n125 will be set to -1. Notice that in -search- the return is 1, not 0, if the string is found immediately. This is due to the fact that in character strings we start numbering with character number 1. On the other hand, here the first word is n(1+0).
Do not use v-variables in the first two arguments of -find- because -find- makes its comparisons by integer operations. The first argument can be a character string such as `dog' or “dog”. You can look at every 3rd word by specifying an optional increment:
This will look for “cat” in nl, n4, n7, etc., and n125 would be returned 0, or 3, or 6, etc. Negative increments can be used to search backwards from the end of the list.
You can also specify that a “masked equality search” be made:
In this case, n125 will be zero if [(n1 $diff$ “cat”) $mask$ o777700] is zero. The mask specifies that only a part of the word will be examined. The increment must be specified, even if it is one, to avoid ambiguity.
There is a -findall- command which will produce a list of all of the locations where something was found, rather than producing locations one at a time.