chickadee » srfi-152 » string-unfold-right

(string-unfold-right stop? mapper successor seed [base make-final]) → stringprocedure

This is a fundamental constructor for strings. It is the same as string-unfold except the results of mapper are assembled into the string in right-to-left order, base is the optional rightmost portion of the constructed string, and make-final produces the leftmost portion of the constructed string. If mapper returns a string, the string is prepended to the constructed string (without reversal).

(string-unfold-right (lambda (n) (< n (char->integer #\A)))
                     (lambda (n) (char-downcase (integer->char n)))
                     (lambda (n) (- n 1))
                     (char->integer #\Z)
                     (lambda (n) " The English alphabet: "))
    ⇒ " The English alphabet: abcdefghijklmnopqrstuvwxyz "

(string-unfold-right null?
                     (lambda (x) (string  #\[ (car x) #\]))
                     '(#\a #\b #\c))
   ⇒ "[c|b|a]"