/usr/lib/s9fes/string-reverse.scm is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010
; See the LICENSE file of the S9fES package for terms of use
;
; (string-reverse string) ==> string
; (string-reverse! string) ==> unspecific
;
; Create a fresh string and fill it with the characters of
; STRING, but in reverse order. STRING-REVERSE! reverses the
; characters of STRING in situ, overwriting the original
; string.
;
; Example: (string-reverse "rats live on no evil star")
; ==> "rats live on no evil star"
(define (string-reverse! s)
(let* ((k (string-length s))
(m (quotient k 2)))
(do ((i 0 (+ 1 i))
(j (- k 1) (- j 1)))
((= i m))
(let ((c (string-ref s i)))
(string-set! s i (string-ref s j))
(string-set! s j c)))))
(define (string-reverse s)
(let ((n (string-copy s)))
(string-reverse! n)
n))
|