modern.slices: Add a way to push characters back to the buffer.

modern-harvey2
Doug Coleman 2017-12-03 18:31:08 -06:00
parent 411c2376c7
commit 06e40a39bc
1 changed files with 7 additions and 0 deletions

View File

@ -219,3 +219,10 @@ ERROR: subseq-expected-but-got-eof n string expected ;
dup length 1 = [ dup length 1 = [
-1 modify-to [ 1 - ] 2dip -1 modify-to [ 1 - ] 2dip
] unless ; ] unless ;
: rewind-slice ( n string slice -- n' string )
pick [
length swap [ - ] dip
] [
[ nip ] dip [ [ length ] bi@ - ] 2keep drop
] if ; inline