| string-map(3scm) | Scheme Programmer's Manual | string-map(3scm) |
NAME
string-map - map a procedure over the characters in stringsLIBRARY
(import (scheme base)) ;R7RS
SYNOPSIS
(string-map proc string1 string2 ...)
DESCRIPTION
The string-map procedure applies proc element-wise to the elements of the strings and returns a string of the results, in order.If more than one string is given and not all strings have the same length, string-map terminates when the shortest string runs out.
The dynamic order in which proc is applied to the elements of the strings is unspecified.
If multiple returns occur from string-map, the values returned by earlier returns are not mutated.
RETURN VALUES
Returns a single string object.EXAMPLES
(string-map char-foldcase "AbdEgH")
=> "abdegh"
(string-map
(lambda (c)
(integer->char (+ 1 (char->integer c))))
"HAL")
=> "IBM"
; Demonstrates how it ends on the shortest string
(string-map
(lambda (c k)
((if (eqv? k #) char-upcase char-downcase)
c))
"studlycaps xxx"
"ululululul")
=> "StUdLyCaPs"
ERRORS
It is an error if proc does not accept as many arguments as there are strings or does not return a single character. It is likewise an error if there are fewer than two arguments or if one of the arguments is outside its domain. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.It is also an error for proc to return a character which the implementation does not support. 7-bit ASCII (except #\null) must be supported. Any other character is optional and potentially an error (as described above). You can use the full-unicode feature identifier in cond-expand(3scm) to check if all of Unicode 6.0 is supported.
SEE ALSO
map(3scm)STANDARDS
R7RSHISTORY
This procedure also appears in SRFI-13.AUTHORS
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.| 2022-03-29 |