Others view: Matrix ♦ Dot-Bracket Notation ♦ welcome ♦ Welcome ♦ Nussinov algorithm ♦ Ray diagram ♦ rss.xml ♦ mandelbrot set ♦

**Lisp** is a programming language with the list oriented, parentheses - centric syntax.

Lisp makes no difference between statements and expressions; everything is a list. The list is space delimited and surrounded by parenthesis. If the list is a function call, then the first element is the function name and other elements are the function parameters, for instance

(times 3 2)

computes 3 * 2 = 6. Lists can be nested, for instance

(times (plus 1 3 2) (plus 4 5) )

computes ( 3 + 1 + 2) * ( 4 + 5 ) = 6 * 9 = 54.

The second example also shows that some functions (*plus*, *times*, *max*, etc) can accept three and more parameters as well. It is relatively easy to learn building quite complex expressions this way, and the notation is actually very easy for a machine to interpret and execute. Surely the "real world" Lisp also has much more standard capabilities as well as dialect-specific extensions. Most of the recent dialects allow to use arithmetic symbols like + - * / instead of words *plus, minus, time* and *quotient*, so (times 3 2) can be abbreviated to (* 3 2).

Evaluating expressions is not enough, need to build expression abstractions that could be reused in the future. Functions are defined with **defun** keyword:

(defun double (x) (* x 2))

In the above, we define a function named *double*, which returns twice the value of its input argument x. Now we can call it to compute *double(7) = 14*:

(double 7)

Functions can then be involved into expressions, calling other functions as well as the same function recursively, for instance *double(double(1+1)) = 2*2*(1+1) = 8*:

(double (double (+ 1 1)))

Many tasks require conditional construct. In List, it is similar to the C ternary operator: **if** *(condition, ifyes, ifno)*, for instance

(if (> 3 2 ) 333 111 )

returns 333 as 3 is more than 2. To have **if** useful, it must be combined with recursion.

Using **if**, you can write your first useful function, factorial that is relatively easy to implement in Lisp:

(defun factorial (N) (if (= N 1) 1 (* N (factorial (- N 1)))))

Factorial is implemented through recursion. Factorial of N is computed using the following rules:

- if N = 1, the
*factorial(N) = 1*. - otherwise, the
*factorial(N) = N * factorial(N-1)*

For instance

(factorial 6)

prints 720.

This is of course not all but should satisfy the requirement to give the brief introduction that the language is look like. The applet supports everything that is described so far or is highly similar. However it may not handle more complex constructs properly so after you have the idea, it is better to use standalone interpreter, like one from the ^{[2]}. To continue, please follow the proposed references.

- http://gigamonkeys.com/book/ - Practical Common Lisp, a good classic Lisp manual, available online for free.
- http://www.ayc.unavarra.es/orduna/iap/Tutoriales/lisp_01.pdf Detailed tutorial on industrial Lisp by David R. Pierce and Stuart C. Shapiro, .pdf.
- http://www.cs.sfu.ca/CC/310/pwfong/Lisp/1/tutorial1.html Shorter, web based tutorial.

*This article is not finished.*