Wednesday, July 19, 2006

Lisp - The Language

Lisp
The functionality and structure of Lisp lends itself to AI. It's used for research and application of AI.

Other languages are more geared towards practical problem solving in industry, Lisp towards... impractical ones.

It's functional/recursive
Dynamic typing (not strong typing)
Flexibility; ease of prototyping (vs. Maintenance).

Taught at Monash because
Historical
Exposure to functional model
Exposure to prototyping

If you're worried about type, you have to do your own checking (it's called debugging!).

It's actually the third oldest language still in use today. (FORTRAN 57, COBOL 58, Lisp 1958)

There are many different versions of Lisp
Common Lisp is the common language.

GNU CLISP is what we're using in this subject.

Lisp is normally interpreted, but then compiled later.
Script for Debug, compile for testing.

At the topmost level:
loop {
read
eval
print
}

Lisp objects
s-expression
Atoms. Atoms may be either
-numbers 3, 75.23322e-38
-or symbols x, nil

Intelligence is all about symbol manipulation. (McArthy) This is a lie!(?) but we'll go on with it for a while. More on that later. Anyway

Lists are a sequence of objects inside a pair of parentheses.
(8 7 99)
((8) 7 99)

Assigning values to symbols.
x = 5
x <- 5

Lisp uses a special function called setq.
[7]> (setq x 5)

The [7]> is a prompt that tells you how many s-exp have been executed so far.

There is also setf for simple assignment.

car and cdr are non-destructive

The empty list is (), nil - the atom.

Taking Lists apart.
car operated on lists, not atoms.

caadr

(car (car (cdr 'x y z)))

yz
y - y must be a list, otherwise it's going to fail.

(cons expression list): constructs a node.

Internally, lists are represented as binary trees.

What if you layered neural networks upon neural networks?
Do we really need to know HOW something is working and learning? Build neural bacteria from genetic algorithms. That's how life began on earth, with the basics, with simple organisms which weren't intelligent, but their bodies and genetics were! You can't just try to jump to the end of evolution when trying to recreate it.

User defined functions
(defun dname (arg1 arg2 ... argn)
s-expr1
s-expr2
...
s-expr3)

In principle, Lisp doesn't believe in side effects. The core of lisp is that you invoke a function that call other functions, and then you get your answers popping back until you get a final answer to present.

/usr/bin/clisp on ra-clay. Play around with it.
Edit filename.lisp
(load "filename")
Run/test your functions
Loop back to step 1.

That should be enough to get started on Lisp.

0 Comments:

Post a Comment

<< Home