replaced by @var{char2}.
@end deffn
-@deffn procedure reverse-string string
-Returns a newly allocated string with the same characters as
-@var{string} but in the reverse order.
-
-@example
-@group
-(reverse-string "foo bar baz") @result{} "zab rab oof"
-(reverse-string (string-slice "foo bar baz" 4 7)) @result{} "rab"
-@end group
-@end example
-@end deffn
-
@node Searching Strings, Matching Strings, Strings, Strings
@section Searching Strings
@cindex searching, of string
prog))
((bit-string? obj)
(build/string stackify-opcode/push-bit-string
- (reverse-string
- (number->string
- (bit-string->unsigned-integer obj)
- 16))
+ (list->string
+ (reverse
+ (string->list
+ (number->string
+ (bit-string->unsigned-integer obj)
+ 16))))
(build/push-nat (bit-string-length obj) prog)))
((scode/primitive-procedure? obj)
(let ((arity (primitive-procedure-arity obj))
make-string
make-vector-8b
random-byte-vector
- reverse-string
- reverse-string!
- reverse-substring
- reverse-substring!
set-string-length!
string
string->list
(substring string-copy)
list->string
make-string
- reverse-string
string
string*
string->list
(define (%bm-substring-search-backward text tstart tend pattern pstart pend)
(let ((m (fix:- pend pstart))
(pend-1 (fix:- pend 1))
- (rpattern (reverse-string (string-slice pattern pstart pend))))
+ (rpattern (reverse-pattern pattern pstart pend)))
(let ((tstart+m (fix:+ tstart m))
(lambda* (compute-last-occurrence-function rpattern 0 m))
(gamma
(define (compute-good-suffix-function pattern pstart pend gamma0)
(let ((m (fix:- pend pstart)))
(let ((pi
- (compute-prefix-function
- (reverse-string (string-slice pattern pstart pend))
- 0 m))
+ (compute-prefix-function (reverse-pattern pattern pstart pend)
+ 0
+ m))
(gamma (make-vector m gamma0))
(m-1 (fix:- m 1)))
(do ((l 0 (fix:+ l 1)))
(vector-set! pi q k)
(outer k (fix:+ q 1)))))
pi))
+
+(define (reverse-pattern pattern pstart pend)
+ (let ((builder (string-builder)))
+ (do ((i (fix:- pend 1) (fix:- i 1)))
+ ((not (fix:>= i pstart)))
+ (builder (string-ref pattern i)))
+ (builder)))
\f
;;;; Guarantors
;;
(define (burst-string string delimiter allow-runs?)
((string-splitter delimiter allow-runs?) string))
-\f
+
(define (string-replace string char1 char2)
(guarantee bitless-char? char1 'string-replace)
(guarantee bitless-char? char2 'string-replace)
(string-map (lambda (char)
(if (char=? char char1) char2 char))
string))
-
-(define (reverse-string string)
- (let ((builder (string-builder)))
- (do ((i (fix:- (string-length string) 1)
- (fix:- i 1)))
- ((not (fix:>= i 0)))
- (builder (string-ref string i)))
- (builder)))
\f
(define (string-8-bit? string)
(receive (string start end) (translate-slice string 0 (string-length string))