take-until-sequence ( sequence-parser sequence -- sequence'/f )


Vocabulary
sequences.parser

Inputs
sequence-parsera sequence-parser
sequencea sequence


Outputs
sequence'/fa sequence or f


Definition


:: take-until-sequence
( sequence-parser sequence -- sequence'/f )
sequence-parser n>> :> saved sequence length
<growing-circular> :> growing sequence-parser [
current growing growing-circular-push
sequence growing sequence=
] take-until :> found growing sequence sequence= [
found dup length growing length 1 - - head
sequence-parser [ growing length - 1 + ] change-n drop
] [ saved sequence-parser n<< f ] if ;