Exercise 1.2.1

Strings

Strings are pretty important in programming; no matter what your program does, eventually you're going to need a string to send some information to the user of your program.

Some programming languages have a lot of different types of strings, but Lisp only has four: the standard string type, as well as simple-string, base-string, and simple-base-string types. The usage of these other string types is fairly specialized, so normally you will be using the string type itself.

Creating Strings

The simplest way to create an object of type string in Lisp is to simply type it at the REPL or in a *.lisp file, using the double-quote syntax.

Try this at the REPL:

* "this is a string"

* "this is another string"

What You Should See

When you type a string at the REPL and hit Return to evaluate it, Lisp treats the entire string as a single atom, even though underneath it is really a specialized vector of character objects. If you remember, an atom is anything that is not a Cons. String objects are also self-evaluating objects. Thus:

* "this is a string"
=> "this is a string"
* "this is another string"
=> "this is another string"

results matching ""

    No results matching ""