USING: kernel math sequences ; IN: splitting.extras : split*-when ( ... seq quot: ( ... elt -- ... ? ) -- ... pieces ) [ subseq ] (split*) ; inline : split*-when-slice ( ... seq quot: ( ... elt -- ... ? ) -- ... pieces ) [ ] (split*) ; inline : split* ( seq separators -- pieces ) [ member? ] curry split*-when ; inline : split*-slice ( seq separators -- pieces ) [ member? ] curry split*-when-slice ; inline : split-find ( seq quot: ( seq -- i ) -- pieces ) [ dup empty? not ] swap [ [ dup ] ] dip [ [ [ 1 ] when-zero cut-slice swap ] [ f swap ] if* ] compose compose produce nip ; inline = [ drop f ] when ] curry [ unless* ] curry compose [ [ dup ] if dup ] curry [ dup ] prepose ] [ pick swap curry [ keep swap ] curry -rot [ not ] compose [ find-from drop ] 2curry [ 1 + ] prepose [ dip ] curry compose ] 3bi produce 2nip ; inline PRIVATE> : split-when-harvest ( ... seq quot: ( ... elt -- ... ? ) -- ... pieces ) [ subseq ] (split-harvest) ; inline : split-when-slice-harvest ( ... seq quot: ( ... elt -- ... ? ) -- ... pieces ) [ ] (split-harvest) ; inline : split-harvest ( seq separators -- pieces ) [ member? ] curry split-when-harvest ; inline