DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(r5rs.info.gz) Strings

Info Catalog (r5rs.info.gz) Characters (r5rs.info.gz) Other data types (r5rs.info.gz) Vectors
 
 6.3.5 Strings
 -------------
 
 Strings are sequences of characters.  Strings are written as sequences
 of characters enclosed within doublequotes (`"').  A doublequote can be
 written inside a string only by escaping it with a backslash (\), as in
 
 
      "The word \"recursion\" has many meanings."
 
 A backslash can be written inside a string only by escaping it with
 another backslash.  Scheme does not specify the effect of a backslash
 within a string that is not followed by a doublequote or backslash.
 
 A string constant may continue from one line to the next, but the exact
 contents of such a string are unspecified.
 
 The _length_ of a string is the number of characters that it contains.
 This number is an exact, non-negative integer that is fixed when the
 string is created.  The "valid indexes" of a string are the exact
 non-negative integers less than the length of the string.  The first
 character of a string has index 0, the second has index 1, and so on.
 
 In phrases such as "the characters of STRING beginning with index START
 and ending with index END," it is understood that the index START is
 inclusive and the index END is exclusive.  Thus if START and END are
 the same index, a null substring is referred to, and if START is zero
 and END is the length of STRING, then the entire string is referred to.
 
 Some of the procedures that operate on strings ignore the difference
 between upper and lower case.  The versions that ignore case have
 "`-ci'" (for "case insensitive") embedded in their names.
 
  -- procedure: string? obj
      Returns #t if OBJ is a string, otherwise returns #f.
 
  -- procedure: make-string K
  -- procedure: make-string K char
      `Make-string' returns a newly allocated string of length K.  If
      CHAR is given, then all elements of the string are initialized to
      CHAR, otherwise the contents of the STRING are unspecified.
 
 
  -- library procedure: string char ...,
      Returns a newly allocated string composed of the arguments.
 
 
  -- procedure: string-length string
      Returns the number of characters in the given STRING.
 
  -- procedure: string-ref string K
      K must be a valid index of STRING.  `String-ref' returns character
      K of STRING using zero-origin indexing.
 
  -- procedure: string-set! string k char
      K must be a valid index of STRING .  `String-set!' stores CHAR in
      element K of STRING and returns an unspecified value.
 
      (define (f) (make-string 3 #\*))
      (define (g) "***")
      (string-set! (f) 0 #\?)                ==>  _unspecified_
      (string-set! (g) 0 #\?)                ==>  _error_
      (string-set! (symbol->string 'immutable)
                   0
                   #\?)                      ==>  _error_
 
 
  -- library procedure: string=? string1 string2
  -- library procedure: string-ci=? string1 string2
      Returns #t if the two strings are the same length and contain the
      same characters in the same positions, otherwise returns #f.
      `String-ci=?' treats upper and lower case letters as though they
      were the same character, but `string=?' treats upper and lower
      case as distinct characters.
 
 
  -- library procedure: string<? string1 string2
  -- library procedure: string>? string1 string2
  -- library procedure: string<=? string1 string2
  -- library procedure: string>=? string1 string2
  -- library procedure: string-ci<? string1 string2
  -- library procedure: string-ci>? string1 string2
  -- library procedure: string-ci<=? string1 string2
  -- library procedure: string-ci>=? string1 string2
      These procedures are the lexicographic extensions to strings of the
      corresponding orderings on characters.  For example, `string<?' is
      the lexicographic ordering on strings induced by the ordering
      `char<?' on characters.  If two strings differ in length but are
      the same up to the length of the shorter string, the shorter string
      is considered to be lexicographically less than the longer string.
 
      Implementations may generalize these and the `string=?' and
      `string-ci=?' procedures to take more than two arguments, as with
      the corresponding numerical predicates.
 
 
  -- library procedure: substring string start end
      STRING must be a string, and START and END must be exact integers
      satisfying
 
                 0 <= START <= END <= (string-length STRING).
 
      `Substring' returns a newly allocated string formed from the
      characters of STRING beginning with index START (inclusive) and
      ending with index END (exclusive).
 
  -- library procedure: string-append STRING ...,
      Returns a newly allocated string whose characters form the
      concatenation of the given strings.
 
 
  -- library procedure: string->list string
  -- library procedure: list->string list
      `String->list' returns a newly allocated list of the characters
      that make up the given string.  `List->string' returns a newly
      allocated string formed from the characters in the list LIST,
      which must be a list of characters. `String->list' and
      `list->string' are inverses so far as `equal?' is concerned.
 
 
  -- library procedure: string-copy string
      Returns a newly allocated copy of the given STRING.
 
 
  -- library procedure: string-fill! string char
      Stores CHAR in every element of the given STRING and returns an
      unspecified value.
 
 
Info Catalog (r5rs.info.gz) Characters (r5rs.info.gz) Other data types (r5rs.info.gz) Vectors
automatically generated byinfo2html