chickadee » srfi-13 » string-reverse

(string-reverse s [start end]) -> stringprocedure
(string-reverse! s [start end]) -> unspecifiedprocedure

Reverse the string.

string-reverse returns the result string and does not alter its S parameter. string-reverse! is the in-place side-effecting variant.

(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 S would come out before B in the reversed result.