EXAMPLE: Suppose you had a variable:
a = (the everyday traps)
you can use it in this way:
And now, let suppose that a = (the everyday traps) , if what we really want
is to produce a list with the word "a" at the beginning of the list
and the rest equal to the a list. How would you do that using CONS?
TRY:
ASSIGNMENT
Those facilities allow the value of a variable to be altered.
Here, form1 is evaluated and the result is stored in the variable var1, then form2 is evaluated and the result is stored in var2 and so forth.
SETQ returns the last value assigned.
EXAMPLE:
Note, the first assignment is perform before the second form is calculated
allowing that form2 can use the new value of var1.
Like in the following example:
It is like SETQ form, except that the assignment is made in parallel.
EXAMPLE:
It is almost the same as SETQ, except that it evaluates its first argument and the value of this first arguments must be an atom, the value of this atom is changed to be the value of the evaluation of the form.
EXAMPLE:
Besides, this function allows alterations of the value of a dynamic variable.
EXAMPLE:
It allows you to define your own command. Takes three arguments; the parameter is a literal atom which appears in the command part of a function and which is worked on by the function's command. The command part may contain and work on several parameters, and each must be declared in parameter-list, which is a list of such atoms. When does not exist parameter is represented by the null list.
EXAMPLE:
Suppose that we want to define the simplest function that give us the second element of a list:
TRY:
Function can be defined recursively and in terms of each other. Each definition of a function is of the form:
(DEFINE function-name LAMBDA-expression ) where LAMBDA-expression is of the form: (list-lambda-variables body-of-the-function )
Function-name is an alpha atom. The list-lambda-variables is a list of different alpha atoms enclosed in parentheses which are the dummy variables (arguments) of the function-name. The body-of-the-function is a program whose value is the value of the function. The value of the variable are call by value.
EXAMPLE:
(COND (cond1 command1)This function allows to specify which one of several commands in a lisp statement is to be executed. It is also equivalent to:
(cond2 command2)
.......
( ) )
The IF corresponds to the If-Then-Else construct found in most algebraic programming languages. First condition is evaluated, if the result is not nil, then the then-part is selected otherwise the else-part is selected, and returns the evaluation of the selected part.
This function is equivalent to:
(COND ( condition then-part )
( t else-part ) )
EXAMPLE: