Yet Another Scheme Introduction學習

Chapter 2express

Function exact->inexact is to convert from fractional numbers to floating point numbers.this

Formulas consisting of parentheses, tokens, and separators are called S-expressions.atom

Chapter 3lua

Cons cells are a memory spaces which storage two addresses.spa

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.orm

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.token

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.ci

A special form named quote is used to protect tokens from evaluation.element

Functions that returns the car part and the cdr part of a cons cell is called car and cdr, respectively.rem

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.

相關文章
相關標籤/搜索