Skip to content

Latest commit

 

History

History
39 lines (23 loc) · 1.03 KB

File metadata and controls

39 lines (23 loc) · 1.03 KB

Chapter 01

The purpose of this chapter is to introduce foundational data structures we use to compute things.

If you had any previous experience with Lisp like languages you might already know that it all starts with an S-expression.

S-expression is one of:

  • an atom
  • list of atom

Examples of an atom:

  • “a”
  • 2
  • #f

Example of a list:

  • (1 “a” #t)

You cannot split the atom but you can combine multiple atoms into lists. They can be nested as much as you’d like. For example:

  • (one (one two) (one (one two three)))

atom is one of:

  • a character
  • a number
  • a boolean statement (#t, #f)

Two essential functions we can use on the lists:

  • car - take the first item (first in Racket)
  • cdr - take all the items but first (rest in Racket)

We can also compare non-numeric atoms with eq?

This minimal set of rules and data definitions provides us with quite a powerful toolset. Its power is not apparent yet, we need one more ingredient recursion. See chapter 02 for more information.