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

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
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 …
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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++)
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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.
Background image of page 5

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

View Full DocumentRight Arrow Icon
LISP    Let’s start with the math functions There are many many built in arithmetic functions You then put these arithmetic functions together
Background image of page 6
  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)
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/13/2009 for the course CS 362 taught by Professor Yasser during the Spring '09 term at Jordan University of Science & Tech.

Page1 / 50

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online