chickadee » srfi-130 » string-for-each-cursor

string-for-each-cursorprocedure

Apply proc to each cursor of s, in order, excluding the post-end cursor. 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 ((s "abcde") (v '()))
  (string-for-each-cursor
    (lambda (cur) (set! v (cons (char->integer (string-ref/cursor s cur)) v)))
    s)
  v) => (101 100 99 98 97)