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

split-sequence Function

Summary

Returns a list of subsequences of a sequence, split at specified separator elements.

Package

lispworks

Signature

split-sequence separator-bag sequence &key start end test key coalesce-separators count => sequences

Arguments
separator-bag
A sequence.
sequence
A sequence.
start, end
Bounding index designators for sequence.
test
A function designator.
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 returns a list of subsequences of sequence (bounded by start and end), split when an element in the sequence separator-bag is found. The structure of sequence is not changed and the elements matching separator-bag are not included in sequences.

The function test, which defaults to eql, is used to compare the elements of sequence and the elements of separator-bag.

If true, the function key, is applied to the elements of sequence before test 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 '(#\space) "one two three")
=>
("one" "two" "three")
 
(split-sequence '(#\space) "one two three" :count 2)
=>
("one" "two three")
See also

split-sequence-if


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