# Book: The Little Schemer, by Friedman, D.

This book is focused on the Scheme programming language, and follows an interesting writing style, where questions are asked on the left panel and answered on the right. It is akin to how a children would learn a new skill, by trial an error and with an explanation of the solution.

With the book there are also certain laws and commandments that are given as a ground truth for reference when coding.

## Laws

• All strings including symbols, numbers and special characters other than `(` or `)` are atoms.
• All atoms, lists are S-expr.
• Law of `car`: `car` is defined only on non-empty lists.
• Law of `cdr`: `cdr` is defined only on non-empty lists. `cdr` returns another list.
• Law of `cons`: `cons` take two arguments, the second being a list. The result is a list.
• Law of `null?`: `null?` is only defined for lists.
• Law of `eq?`: `eq?` takes two atoms (non numeric?).

## Commandments

• First commandment: Always ask `null?` as first question when recurring a list of atoms. When recurring on a number ask `zero?` as the first question.
• Second commandment: Use `cons` to build lists.
• Third commandment: When building a list, describe the typical element and then `cons` it onto the natural recursion.
• Fourth commandment: Always change at least one argument when recurring. It must be changed to be closer to termination. The changing argument must be tested in the termination condition.
• Fifth commandment: When building value with `+` (sum), use 0 for value of terminating condition. When building with `x` (multipy), always use 1 for the value of the terminating condition. With `const`, use `'()` as the value of the terminating condition.