chickadee » srfi-13 » string-for-each-index

(string-for-each-index proc s [start end]) -> unspecifiedprocedure

Apply PROC to each index of S, in order. The optional START/END pairs restrict the endpoints of the loop. This is simply a method of looping over a string that is guaranteed to be safe and correct. Example:

(let* ((len (string-length s))
       (ans (make-string len)))
      (lambda (i) (string-set! ans (- len i) (string-ref s i)))