![]() | ![]() | ![]() | counted-delete | ![]() |
|
| item sequence
&key from-end test test-not start end count key
=> result-sequence, count | [Function] |
Purpose
A version of delete that returns the number of items
that were deleted as a second value.
Package :gbbopen-tools
Module :gbbopen-tools
Arguments and values
| item | An object | |
| sequence | A proper sequence | |
| from-end | A generalized boolean (default is nil)
| |
| test | A function of two arguments that returns a
generalized boolean (default is #'eql)
| |
| test-not | A function of two arguments that returns a
generalized boolean (use of :test-not is deprecated)
| |
| start | Starting index into sequence (default is 0)
| |
| end | Ending index into sequence (default is nil, meaning
end of sequence)
| |
| count | An integer or nil (default is nil)
| |
| key | A function of one argument, or nil (default is nil)
| |
| result-sequence | A sequence |
Returns
Two values:
nilDescription
Returns a sequence from which elements that satisfy the
test have been deleted. The supplied sequence may be modified
in constructing the result; however, modification of the supplied
sequence itself is not guaranteed.
Specifying a from-end value of true matters only when the count is provided, and in that case only the rightmost count elements satisfying the test are deleted.
See also
atomic-delete
Examples
> (counted-delete 'a '(a b c a b c)) (b c b c) 2 > (counted-delete #\a "abcabc") "bcbc" 2 > (counted-delete 'z '(a b c a b c)) (a b c a b c) 0 > (counted-delete #\a "abcabc" :from-end 't :count 1) "abcbc" 1 >
Note
This is what delete should have been (and was on the
Lisp Machines).
The GBBopen Project
![]() | ![]() | ![]() | counted-delete | ![]() |