Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Strings   [Contents][Index]


6.6.5.11 Mapping, Folding, and Unfolding

Scheme Procedure: string-map proc s [start [end]]
C Function: scm_string_map (proc, s, start, end)

proc is a char->char procedure, it is mapped over s. The order in which the procedure is applied to the string elements is not specified.

Scheme Procedure: string-map! proc s [start [end]]
C Function: scm_string_map_x (proc, s, start, end)

proc is a char->char procedure, it is mapped over s. The order in which the procedure is applied to the string elements is not specified. The string s is modified in-place, the return value is not specified.

Scheme Procedure: string-for-each proc s [start [end]]
C Function: scm_string_for_each (proc, s, start, end)

proc is mapped over s in left-to-right order. The return value is not specified.

Scheme Procedure: string-for-each-index proc s [start [end]]
C Function: scm_string_for_each_index (proc, s, start, end)

Call (proc i) for each index i in s, from left to right.

For example, to change characters to alternately upper and lower case,

(define str (string-copy "studly"))
(string-for-each-index
    (lambda (i)
      (string-set! str i
        ((if (even? i) char-upcase char-downcase)
         (string-ref str i))))
    str)
str ⇒ "StUdLy"
Scheme Procedure: string-fold kons knil s [start [end]]
C Function: scm_string_fold (kons, knil, s, start, end)

Fold kons over the characters of s, with knil as the terminating element, from left to right. kons must expect two arguments: The actual character and the last result of kons’ application.

Scheme Procedure: string-fold-right kons knil s [start [end]]
C Function: scm_string_fold_right (kons, knil, s, start, end)

Fold kons over the characters of s, with knil as the terminating element, from right to left. kons must expect two arguments: The actual character and the last result of kons’ application.

Scheme Procedure: string-unfold p f g seed [base [make_final]]
C Function: scm_string_unfold (p, f, g, seed, base, make_final)
Scheme Procedure: string-unfold-right p f g seed [base [make_final]]
C Function: scm_string_unfold_right (p, f, g, seed, base, make_final)

Next: , Previous: , Up: Strings   [Contents][Index]