Excerpted from Wikipedia, the original link is: Http://zh.wikipedia.org/zh/LISP
Because Clojure is a kind of Lisp dialect, so we can first understand the lisp of the relatively small audience of the program is what ~
---------------------------------------------------------------------------
LISP(full name LIST Processor, or list Processing language ), is a functional programming language based on the lambda calculus created by John McCarthy in about 1960 years.
There are many dialects of Lisp, and the language in each implementation is not exactly the same. 1980 's Guy L. Steele wrote Common Lisp trying to standardize, a standard that is accepted by most interpreters and compilers. In the Unix/linux system, there is also an Emacs Lisp with Emacs, which is the extension of Lisp as an extended language, and establishes its own standards.
The major modern versions of the Lisp language include Common Lisp and scheme.
Basic introduction
LISP is the first functional language, which differs from command-type programming languages such as C/java.
For historical reasons, Lisp has long been considered primarily for the AI domain, but Lisp is not designed for AI, but is a universal programming language.
Lisp's expression is an atom (atom) or a table (list), an atom (atom) and a number (number), and a table is a sequence of 0 or more expressions, separated by a space between the expressions, in a pair of parentheses, such as:
ABC () (ABC xyz) (a B (c) d)
The last table is made up of four elements, and the third element itself is a table, and this list is called a nested table (nested list).
Just as the arithmetic expression has a value of 21, the expression in Lisp also has a value, and if the expression E is the value V, we say e returns v. If an expression is a table, then we call the first element of the table an operator, and the rest of the elements are called arguments.
7 Axioms of Lisp (basic operator)
(quote x) returns x, we précis-writers ' X
> (quote a) a> ' AA
(Atom X) returns an atomic t when X is an atom or an empty table, otherwise an empty table () is returned. In Lisp we are accustomed to using atomic t to represent true, and using empty tables () for false.
> (Atom ' a) t> (Atom ' (a b C)) () > (Atom ' ()) t
Now that we have the first operator to ask for a variable value, let's take a look at the role of the quote operator--by referencing (quote) a table, we avoid it being evaluated. An unreferenced expression as an argument, atom treats it as code, for example:
> (Atom ' a) t
This is because the result (t) of (Atom ' a) is calculated and substituting (Atom (atom)) to become (Atom T), and the result of this expression is T.
Conversely, a referenced table is considered only as a table
> (Atom ' A)) ()
References look strange because it is difficult to find similar concepts in other languages, but it is this feature that forms the most distinctive feature of Lisp-code and data are represented by the same structure, and we use quote to differentiate them.
(eq x y) returns T when the value of x and Y is the same or the same as an empty table, otherwise returns an empty table ()
> (eq ' a ' a) t> (eq ' a ' B) () > (EQ ' () ' ()) t
(car x) requires X to be a table that returns the first element in X, for example:
> (car ' (a b)) a
(Cdr x) also requires that X is a table that returns a table of all the elements in x except the first element, for example:
> (CDR ' (a b c)) (b c)
(cons x Y) returns a cons cell (x y), for example:
> (cons ' a ' B) (A. B)
The second item of a cons cell if it is another cons cell, it is represented in the form of a table, for example:
A. (b. C))
is expressed as
(a B. c)
If the second item of a cons cell is empty, it is omitted, for example:
A. (b. ()))
expressed as
(a B)
In this way, the multiple cons cells form the table:
> (cons ' A (cons ' B (Cons ' C ()))) (a B C)
(Cond (P1 E1) ... (PN en)) The evaluation rules are as follows. The conditional expression P is evaluated sequentially until there is a return T. If such a P-expression can be found, the value of the corresponding "result expression E" as the return value of the entire cond expression.
> (Cond (eq ' a ' b) ' First "((Atom ' a) ' second)) second
Function
When an expression begins with five of the seven primitive operators, it always evaluates its arguments. We call this operator a function.
Introduction to Lisp language