Strings

  Strings, similarly to symbols, numbers, lists and other simple types, are the basic type of data, in work with which the elementary primitive functions and predicates are used. Besides strings inherit all set of methods of the parental type True.

Characters and strings

  The string can be divided into letters (char). The character also is type of data. Its objects unlike atoms which name consists of one letter, are represented in the form of

  #\x

  In this record x is a letter represented by given record or a word in case of the special letter which is usually not having the printed image. For example:

#\e ; small e
#\T ; big t
#\Tab ; tabulation

  Value of a letter, as well as at constants, the letter is:

>#\e
#\e

  Whether is lisp object a letter, it is possible to check up a predicate (nil charp x).
  In string letters enter the name in sequence one after another for which restriction from both parties as the terminator the sign " is used, for example:

  "It is a string"
  "(2 + 3)"
  "\""
; the string consisting of one terminator

  If a string to enter into the interpreter as result we shall receive the same string. The string cannot represent something, except for itself. It is the same constant, as numbers and logic values:

>"It is a string"
"It is a string"
>"(2 + 3)"
"(2 + 3)"
>(nil list "abc" "def")
("abc" "def")
; the list of strings

  The function checking, whether has object type of a string, is (nil stringp x) which value will be x if x is a string.

Working with strings

  In work with strings functions at least for reading elements of a string, change of these elements and for comparison of two strings are necessary.
  The any element of a string can be read through function elt:

  (string elt n)

  Let's give an example:

>("Cat" elt 0) ; indexation begins with 0
#\C

  The element of a string can be changed by means of function of giving setelt, for example:

>("Cat" setelt 0 #\R)
"Rat"

  Strings can be compared by means of a predicate =:

  (x = y)

  This predicate checks identity of two strings.

>("Cat" = "cat")
FALSE
>("Cat" = "Cat")
"Cat"