Next: srfi strings spec fold, Previous: srfi strings spec case-map, Up: srfi strings spec [Index]
Reverse the string; return the result string and does not alter its str argument.
Examples:
(string-reverse "Able was I ere I saw elba.")
⇒ ".able was I ere I saw elbA"
;;; In-place rotate-left, the Bell Labs way:
(lambda (s i)
(let ([i (modulo i (string-length s))])
(string-reverse! s 0 i)
(string-reverse! s i)
(string-reverse! s)))
Unicode note Reversing a string simply reverses the sequence of code–points it contains. So a zero–width accent character a coming after a base character b in string str would come out before b in the reversed result.
In–place side–effecting variant.
Return a newly allocated string whose characters form the concatenation of the given strings.
Append the elements of string-list together into a single string. Guaranteed to return a freshly allocated string.
Note that the (apply string-append string-list) idiom is not
robust for long lists of strings, as some Scheme implementations limit
the number of arguments that may be passed to an n–ary procedure.
These two procedures are variants of string-concatenate and
string-append that are permitted to return results that share
storage with their parameters. In particular, if
string-append/shared is applied to just one argument, it may
return exactly that argument, whereas string-append is required
to allocate a fresh string.
With no optional arguments, this function is equivalent to:
(string-concatenate (reverse string-list))
If the optional argument final-string is specified, it is consed
onto the beginning of string-list before performing the
list-reverse and string-concatenate operations.
If the optional argument end is given, only the first end characters of final-string are added to the string list, thus producing:
(string-concatenate
(reverse (cons (substring/shared final-string 0 end)
string-list)))
Example:
(string-concatenate-reverse '(" must be" "Hello, I")
" going.XXXX"
7)
⇒ "Hello, I must be going."
This procedure is useful in the construction of procedures that accumulate character data into lists of string buffers, and wish to convert the accumulated data into a single string when done.
Unicode note Reversing a string simply reverses the sequence of code–points it contains. So a zero–width accent character
accoming after a base characterbcin string str would come out beforebcin the reversed result.
Variant which is permitted to return results that share storage with its arguments.
Next: srfi strings spec fold, Previous: srfi strings spec case-map, Up: srfi strings spec [Index]