Yet Another Scheme Introduction学习
Chapter 2
Function exact->inexact is to convert from fractional numbers to floating point numbers.
Formulas consisting of parentheses, tokens, and separators are called S-expressions.
Chapter 3
Cons cells are a memory spaces which storage two addresses.
Function cons allocates a memory space for two addresses. and stores the address to 1 in one part and to 2 in the other part. The part storing the address to 1 is called car part and that storing the address to 2 is called cdr part. Car and cdr are abbreviations of Contents of the Address part of the Register and Contents of the Decrement part of the Register.
Lists are (beaded) cons cells with the cdr part of the last cons cell being '(). '() is called the empty list, which is included to lists.
Data structures which do not use cons cells are called atom. Numbers, characters, strings, vectors, and '() are atom. '() is an atom and a list as well.
A special form named quote is used to protect tokens from evaluation.
Functions that returns the car part and the cdr part of a cons cell is called car and cdr, respectively.
Function list is available to make a list consisting of several elements. Function list takes arbitrary numbers of arguments and returns a list of them.
Chapter 4
You use define to bind a symbol to a value. You can define any kind of global parameters, such as numbers, characters, lists, etc. and functions by this operator.
The define is a operator to declare variables and takes two arguments. The operator declares to use the first argument as a global parameter and binds it to the second argument.
The lambda is a special form to define procedures. The lambda takes more than one arguments and the first argument is the list of parameters that the procedure takes as arguments.
Chapter 5
false is represented by #f. The representing value of true is #t.
so many operaters and functions
chapter 6
Local variables can be defined using the let expression.
(let binds body)
Variables are declared and assigned to initial values in the binds form. The body consists of arbitrary numbers of S-expressions.
[binds] → ((p1 v1) (p2 v2) ...)
Variables p1, p2 ... are declared and bind them to the initial values, v1, v2 ... The scope of variables is the body, which means that variables are valid only in the body.
The let* expression is available to refer variables which is defined in the same binding form. Actually, the let* expression is a syntax sugar of nested let expressions.