: p= ( p p -- ? ) pextend = ;
: ptrim ( p -- p )
- dup length 1 = [ [ zero? ] right-trim ] unless ;
+ dup length 1 = [ [ zero? ] trim-right ] unless ;
: 2ptrim ( p p -- p p ) [ ptrim ] bi@ ;
: p+ ( p p -- p ) pextend v+ ;
"\0" read-until [ drop f ] unless ;
: read-c-string* ( n -- str/f )
- read [ zero? ] right-trim dup empty? [ drop f ] when ;
+ read [ zero? ] trim-right dup empty? [ drop f ] when ;
: (read-128-ber) ( n -- n )
read1
parsers>> 0 swap seq>list
[ parse ] lazy-map-with lconcat ;
-: left-trim-slice ( string -- string )
+: trim-left-slice ( string -- string )
#! Return a new string without any leading whitespace
#! from the original string.
dup empty? [
- dup first blank? [ rest-slice left-trim-slice ] when
+ dup first blank? [ rest-slice trim-left-slice ] when
] unless ;
TUPLE: sp-parser p1 ;
M: sp-parser parse ( input parser -- list )
#! Skip all leading whitespace from the input then call
#! the parser on the remaining input.
- >r left-trim-slice r> p1>> parse ;
+ >r trim-left-slice r> p1>> parse ;
TUPLE: just-parser p1 ;
: source-059 ( -- seq )
"resource:extra/project-euler/059/cipher1.txt"
- ascii file-contents [ blank? ] right-trim "," split
+ ascii file-contents [ blank? ] trim-right "," split
[ string>number ] map ;
TUPLE: rollover seq n ;
[ 2 <clumps> [ = not ] assoc-filter values ] [ first ] bi prefix ;
: first>upper ( seq -- seq' ) 1 head >upper ;
-: trim-first ( seq -- seq' ) dup first [ = ] curry left-trim ;
+: trim-first ( seq -- seq' ) dup first [ = ] curry trim-left ;
: remove-zeroes ( seq -- seq' ) CHAR: 0 swap remove ;
: remove-non-alpha ( seq -- seq' ) [ alpha? ] filter ;
: pad-4 ( first seq -- seq' ) "000" 3append 4 head ;
: typeflag-L ( header -- )
drop ;
! <string-writer> [ read-data-blocks ] keep
- ! >string [ zero? ] right-trim filename set
+ ! >string [ zero? ] trim-right filename set
! filename get tar-prepend-path make-directories ;
! Multi volume continuation entry