position-in-ring ring item index &key test => result
position-in-ring-forward ring item index &key test => result
A ring object created by make-ring.
A non-negative integer.
A Lisp object.
A function designator for a function of two arguments.
The function position-in-ring
finds in the ring ring the first element that matches item and returns its index, or nil
if there is no match. The search starts from index index and proceeds "backward" up to the length of the ring (its current number of elements). In other words, it tests all the elements that would be returned by ring-ref with indices index, index+1, ... , length-1. It does not wrap around, so elements between indices 0 and index are not tested.
The function position-in-ring-forward
does the same except that it searches from index "forward" to the insertion point. In other words, it tests the elements that would be returned by ring-ref with indices index, index-1, ..., 0.
The comparison is done by calling test, with item as first argument and each element in the ring as the second argument. The default value of test is eql
.
In LispWorks 6.1 and earlier versions, these functions are called find-in-ring
and find-in-ring-forward
. They have been renamed to match the Common Lisp convention that a function returning an index is named position-*
. The old names are retained for backwards compatibility, but are deprecated.
LispWorks User Guide and Reference Manual - 20 Sep 2017