chickadee » srfi-135 » textual-for-each-index

(textual-for-each-index proc textual [start end]) → unspecifiedprocedure

Calls proc on each valid index of the specified subtext or substring, in increasing order, discarding the results of those calls. This is simply a safe and correct way to loop over a subtext or substring.

Example:

(let ((txt (string->text "abcde"))
      (v '()))
  (textual-for-each-index
   (lambda (cur) (set! v (cons (char->integer (text-ref txt cur)) v)))
   txt)
  v) ⇒ (101 100 99 98 97)