{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# lisp-i - L ISP What is LISP A LISt Processing language The...

This preview shows pages 1–9. Sign up to view the full content.

LISP    What is LISP? A LISt Processing language The basic data structure is linked list A functional programming language Each expression in LISP is a function that returns a value A good LISP program should avoid too many side effects An interpretive language Running LISP programs involves interacting with the LISP interpreter LISP programs can also be compiled, but most of the time we don’t …

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
LISP    Why LISP for Symbolic Programming? LISP supports symbol manipulation better Symbols are the basic entities of the language The interpretive nature makes it easy to “try a new idea’’ and prototype Functions are in the form of linked lists Easier to think about the programs Historical Reason Most AI programs in the U.S. have been developed in LISP However, most AI programs in Europe have been developed in PROLOG
LISP    Functions Lisp is a functional language – So everything is a function -> Functions in other languages var sum := sqrt(x) Print sum In lisp this function is: -> (sqrt x) Most LISP functions require you to think and use Prefix Notation – you have to think backwards (print (+ 5 (sqrt 6))) Lisp is Interpretive And there are primary effects and side effects In ‘pure’ Lisp, we ONLY get values by executing a function. We DON’T set a variable to a new value INSIDE a function….that is a side effect of executing a function. (You all probably do that all the time in Java or C++)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
LISP    How the Lisp Functions work – The read-eval loop Evaluation process starts with an “S” expression (i.e., a function and operands to that function) This one adds two numbers…. (+ 3 4) Parentheses – Notification to evaluate Function name – Go get function (in this case ‘+’ is the add function) space - separator operands -- value for function Parentheses – stop evaluation and return the answer
LISP    Doing Lisp on CSP Machines Log into your account Type clisp You are now in the Lisp Interpreter and you can begin writing functions – but you can’t save them. If you do not have an account on the CSP machines, then see the computer manager for the department. If you are not going to use the lisp on the CSP machines, then you can still hand in your code and it will run on the CSP machines.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
LISP    Let’s start with the math functions There are many many built in arithmetic functions You then put these arithmetic functions together
LISP    Arithmetic Functions (+ numbers…) -- adding (- numbers…) -- subtracting (* numbers…) -- multiplication (/ numbers…) -- division (1+ number) – plus 1 (this is hard to read) (1- number) – minus 1 (abs number) etc….. (acos number)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
LISP    (atan <number1> <number2>) (cos ..
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 50

lisp-i - L ISP What is LISP A LISt Processing language The...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online