I recently took the time to read this film, and relived the movie "matrix of the hacker ".ProgramInspired by the design, I want to give a simple explanation of scheme and its position in programming languages before talking about it. lisp is a very old language, it is said that only Fortran is better than others. After years of success, LISP suddenly shines brightly. The latest popular languages continue to absorb nutrients and thrive. For example, C # is added to lambda expressions and JS closures, garbage collection and so on. Why is it so proud that lisp has a large number of dialects and is not well organized and maintained. Now I will take notes on some of my understanding to facilitate further study and query.
I like scheme because it is small and pure. I don't expect to use lisp for some practical development, but I just want it to start my thinking. Many people think it is very difficult to get started with lisp, or the starting point of this book is too high, just because our foundation is too poor. I believe that if we had the basis of Discrete Mathematics and mathematical logic, we would be familiar with it, because it is better than computers.Programming Language, Lisp is more like mathematics. It is more basic and primitive than C/C ++, just like Donald E. according to knuth, computer science is just a beautiful coat of mathematics, without basic mathematical knowledge such as discrete mathematics, composite mathematics, probability theory, abstract algebra, and basic calculus, the Direct Reading of "computer programming art" is not only very difficult, but also has little effect, so before reading this set of computer science classics, it is best to first look at the author's another book "Specific mathematics", this is a digression. Now I want to prove to you why lisp is more primitive than C. to exaggerate, it is closer to the essence of truth.
Which of the following values is one meter per second and one 1 kg? What do you think is the relationship between number 1 and the + operator? You may say that you are not an idiot. How can you draw an analogy between two completely different things? What I want to say is, don't be like a "matrix" slave, to learn "Neo", try to see the world as much as possible. Many people believe that truth is simple, and I also believe it. Several hundred years ago, no one thought we were the same as plants. Now we know that we are very similar. They all transmit genetic information by DNA/RNA, and they all contain cells; decades ago, no one thought we were the same with water. Now we know that we are actually composed of limited elements. Einstein invented the energy equation to unify energy and quality. Quality and energy may actually be just different forms of things. Do not be confused by all beautiful appearances. Borrow lines from the matrix, what is truth? What do you see? What you smell? These are just the responses of your brain. However, all current knowledge models are likely to be overturned in the future until truth is found.
Here is an observability and measurable concept, such as Newton's Universal Gravitation. Newton does not know what universal gravitation is. He just found its law of action, before finding the truth, all knowledge is just an approximate abstract model of things. Many concepts we are accustomed to are not so obvious. For example, what is the number '0'? How should we strictly define it? Don't tell me that a circle is nothing, and I don't know, but I know that this problem is not so obvious. For example, if a "thing" and any other thing product is itself, it is zero, so as long as one thing meets this constraint, it will be "0", which exactly shows the interpretation of the order pair in Chapter Two of SiC, no matter how the order pair is organized below, I only need one method that can generate a sequence pair and two methods that can retrieve the elements before and after the sequence. The display of SiC displays the data in a process completely, which is surprising, what we care about is that we can truly touch the interface that produces results. Anything that cannot be observed is meaningless to us (see the "invisible Dragon" story ), the world is filled with a rule. All objects in the world are made aware of the outside through interfaces that can interact with the outside world. All we know is these interfaces, the internal truth cannot be seen.
Now let's get down to it. Let's take a look at exercise 2.6. The whole scheme is built on the only rule: Lambda algorithm. The inventor is Alonzo church, a famous mathematical logic scientist. He has proved that lambda calculus is completely Turing, to a certain extent, Lambda-based scheme is equivalent to the C language computing capability based on machine models. Data and operations in C language are strictly differentiated. static data and dynamic operations are rooted in our minds. However, according to the above discussion, I can think, as long as you can invent something that fully satisfies the definition of a number, it can completely replace the number (essentially). lambda calculus actually has this ability to implement data through operations. The following concepts may involve real analysis in Mathematics (we recommend a book Tao zhexuan real analysis. You can see how to use basic rules to form a complex mathematical building). If there is no theoretical basis for real analysis, there are some obstacles to reading data abstraction. The example in SiC is very simple. We need to use lambda calculus to establish a (integer) Natural Number System and a natural number addition rule.
It first defines the number 0:
(Define zero (lambda (f) (lambda (x) X )))
Then the auto-increment 1 operation is defined:
(Define (add-1 N)
(Lambda (f) (lambda (x) (f (n f) X )))))
Obviously, with these two rules, other natural numbers can be defined:
1 = (add-1 zero)
2 = (add-1 (add-1 zero ))
3 = (add-1 (add-1 (add-1 zero )))
...
This indicates that it is not direct enough, and the change is as follows:
(Define one (lambda (f) (lambda (x) (f x ))))
(Define two (lambda (f) (lambda (x) (f (f x )))))
(Define three (lambda (f) (lambda (x) (f (f x ))))))
As you can see, any natural number is defined as a process. We then define the equivalent four arithmetic operations in these processes, and then provide a method to convert them to the Arabic natural number space, we have established our own natural number system. Here, we can define a native addition based on Lambda natural numbers. It is very simple. The addition effect of A + B only needs to be equivalent to 0 auto-increment A + B, to make it easier to check whether the results are accurate or not, first implement a simple method from lambda's Natural Number System to the Arabic Natural Number System:
(Define (print-x n)
(Define (Mark X)
(Display "0 "))
(N mark) 0 ))
The usage is as follows:
(Print-X three) => 000
Three '0' characters will be printed, so that we can know that the lambda number corresponds to the natural number 3. This is the same as the baseline count when the original person does not have a number concept :)
Addition is defined as follows:
(Define (LMD-Add a B)
(Lambda (f) (lambda (X)
(A f) (B f) X )))))
The test is correct:
(Print-X (LMD-add two three) = & gt; 00000
(Print-X (add-1 (add-1 (add-1 (add-1 (add-1 zero) => 00000
If you are interested, you can add negative number definitions and addition operations.
Scheme can use a rule to export numbers, four operators, and even conditional statements and cyclic statements, in the C language, we can see that the atomic numbers, operators, and flow control keywords can be further decomposed into finer granularity. In the example, numbers and addition, it's just Lambda's beautiful syntax. (as in matrix 1, Neo saw the appearance of the world and found that the world is actually code ).
Lisp will not decline, but it will only evolve, because it is a mathematical logic developed by mathematicians, a Lambda algorithm equivalent to Turing, to put it bluntly, we define the Turing machine in a more concise way. At a deeper level, LISP represents an idea for analyzing and solving problems. It is basically the same as the mathematical principle based on C language, but in a different form, scheme must rely heavily on Recursive forms. Its core idea is to combine complex rules with simple rules and abstract complex Symptom Analysis into simple rule recursion, this is very similar to the analysis of practical problems by the human brain. (If you are very interested, please refer to the book Geb, a golden belt, which won the Best Award.) this is very different from the idea that C-like imperative languages emphasize module governance. I think the concept of lisp is very similar to that of fragment. It is widely used in complex problem solving, such as compilation and theorem proof. Of course, the hierarchy and modularity of the problem do not conflict with the abstraction of concise rules of things, on the contrary, these two ideas must work closely together to minimize the processing information and optimize the solution to the problem. In addition, LISP gave me an obvious reminder that programmers without a good mathematical foundation cannot go far (you can read the book programming essence and I believe everyone will understand this point of view ).
The story of quantum physics:
"I have a firehose in my garage !" Karl Sagan claims this. "Too rare !" His friends rushed to the garage, but did not see the dragon. "Where is Dragon ?" "Oh," Sagan said. "I forgot to explain that this is an invisible dragon ." Some friends are skeptical, but he suggested that some powder can be sprinkled on the ground to see if the dragon's fingerprint will appear. But Sagan claimed that the dragon was floating in the air. "So since this dragon is burning, we use an infrared detector for a hot scan ?" "Neither ." "The invisible fire has no temperature," said Sagan ." "Either spray paint the dragon to make it visible ?" -- "This dragon is non-material, slide without a hand, And the paint is stuck everywhere ." No physical method can detect the existence of this dragon. Sagen finally asked: "This is an invisible, non-physical dragon that floats in the air with no heat, and a dragon that no instrument can detect, what is the difference between it and 'no long? ".