The
vl-some function will evaluate a predicate function on every item in a given list (or lists) with a syntax similar to
mapcar, however,
vl-some will cease evaluation when the predicate function returns a non-nil value - at which point
vl-some will return this value, e.g.:
Iterate over a list until an item is equal to 3:
Adding a
print expression to demonstrate the function evaluation:
Iterating over two lists until the items in the same position in both lists are equal to 5:
Or, as a simplified example, testing whether two lists contain equal items at the same index:
_$
(vl-some '
= '
(0 1 4 3 6) '
(7 2 5 3 2))T
Returning the item itself to demonstrate that
vl-some returns the value of the predicate function:
_$
(vl-some '
(lambda ( x
) (if (= (cdr x
) "c") x
)) '
((1 .
"a") (2 .
"b") (3 .
"c") (4 .
"d")))(3 . "c")
Finally, here is the formal documentation for
vl-some:
http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6882.htm