collapse ( ... seq quot: ( ... elt -- ... ? ) elt -- ... seq' )


Vocabulary
sequences.extras

Inputs
seqa sequence
quota quotation with stack effect ( ... elt -- ... ? )
eltan object


Outputs
seq'a sequence


Word description
Generate a new sequence where all runs of elements for which the predicate returns true are replaced by a single instance of elt.

See also
compact

Examples
Collapse multiple spaces in a string down to a single space
USING: kernel prettyprint sequences.extras ; " Hello, crazy world " [ CHAR: \s = ] " " collapse .
" Hello, crazy world "


Definition