item | an item to be found |
sequence | a sequence to be searched |
test | function key and item comparison |
from-end | direction of search, default is NIL - forward |
start | starting position for search, default is 0 |
end | final position for search, default is NIL - end of sequence |
key | function for extracting value before test |
POSITION function searches for an element (item) satisfying the test. Return value is index of such item or NIL if item is not found. Index is relative to start of the sequence regardless of arguments. See also POSITION-IF, FIND, FIND-IF and MEMBER.
(position #\s "Some sequence") => 5 (position #\s "Some sequence" :key #'char-downcase) => 0 (position #\s "Some sequence" :key #'char-downcase :start 1) => 5 (position #\x "Some sequence") => NIL (position '(1 2) #(9 3 (1 2) 6 7 8)) => NIL (position '(1 2) #(9 3 (1 2) 6 7 8) :test #'equal) => 2 (position 1 #(0 1 0 0 0 1 0) :from-end t) => 5