All Manuals > LispWorks® User Guide and Reference Manual > 38 The LISPWORKS Package

split-sequence-if

split-sequence-if-not Functions

Summary

Returns a list of subsequences of a sequence, split at elements for which a predicate returns true or false.

Package

lispworks

Signatures

split-sequence-if predicate sequence &key start end key coalesce-separators count => sequences

split-sequence-if-not predicate sequence &key start end key coalesce-separators count => sequences

Arguments
predicate
A function designator.
sequence
A sequence.
start, end
Bounding index designators for sequence.
key
A function designator or nil.
coalesce-separators
A generalized boolean.
count
A positive integer, default most-positive-fixnum.
Values
sequences
A list of sequences.
Description

The function split-sequence-if returns a list of subsequences of sequence (bounded by start and end), split by where the function predicate returns true for an element.

The function split-sequence-if-not returns a list of subsequences of sequence (bounded by start and end), split by where the function predicate returns false for an element.

The structure of sequence is not changed and the elements identified by the predicate are not included in sequences.

If non-nil, the function key is applied to the elements of sequence before predicate is called.

If coalesce-separators is true, then empty sequences are omitted from sequences.

count specifies the maximum number of subsequences returned. The last subsequence consists of all the remaining elements of sequence.

Examples
(split-sequence-if 'digit-char-p "one1two2three3")
=>
("one" "two" "three" "")
 
(split-sequence-if-not 'digit-char-p "one1two2three3")
=>
("" "" "" "1" "" "" "2" "" "" "" "" "3")
See also

split-sequence


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:41