Next: , Previous: String Predicates, Up: Strings


5.5.5.3 String Constructors

The string constructor procedures create new string objects, possibly initializing them with some specified character data. See also See String Selection, for ways to create strings from existing strings.

— Scheme Procedure: string char...

Return a newly allocated string made from the given character arguments.

          (string #\x #\y #\z) => "xyz"
          (string)             => ""
     
— Scheme Procedure: list->string lst
— C Function: scm_string (lst)

Return a newly allocated string made from a list of characters.

          (list->string '(#\a #\b #\c)) => "abc"
     
— Scheme Procedure: reverse-list->string lst
— C Function: scm_reverse_list_to_string (lst)

Return a newly allocated string made from a list of characters, in reverse order.

          (reverse-list->string '(#\a #\B #\c)) => "cBa"
     

— Scheme Procedure: make-string k [chr]
— C Function: scm_make_string (k, chr)

Return a newly allocated string of length k. If chr is given, then all elements of the string are initialized to chr, otherwise the contents of the string are unspecified.

— C Function: SCM scm_c_make_string (size_t len, SCM chr)

Like scm_make_string, but expects the length as a size_t.

— Scheme Procedure: string-tabulate proc len
— C Function: scm_string_tabulate (proc, len)

proc is an integer->char procedure. Construct a string of size len by applying proc to each index to produce the corresponding string element. The order in which proc is applied to the indices is not specified.

— Scheme Procedure: string-join ls [delimiter [grammar]]
— C Function: scm_string_join (ls, delimiter, grammar)

Append the string in the string list ls, using the string delim as a delimiter between the elements of ls. grammar is a symbol which specifies how the delimiter is placed between the strings, and defaults to the symbol infix.

infix
Insert the separator between list elements. An empty string will produce an empty list.
string-infix
Like infix, but will raise an error if given the empty list.
suffix
Insert the separator after every list element.
prefix
Insert the separator before each list element.