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

lispworks

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`

predicate⇩ |
A function designator. |

sequence⇩ |
A sequence. |

Bounding index designators for sequence. | |

key⇩ |
A function designator or `nil` . |

coalesce-separators⇩ |
A generalized boolean. |

count⇩ |
A positive integer, default most-positive-fixnum. |

sequences⇩ |
A list of sequences. |

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`.

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

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