Lisp List Processing Lisp history l John Mc

  • Slides: 11
Download presentation
Lisp "List Processing "

Lisp "List Processing "

Lisp history l John Mc. Carthy developed the basics behind Lisp during the 1956

Lisp history l John Mc. Carthy developed the basics behind Lisp during the 1956 Dartmouth Summer Research Project on Artificial Intelligence l He intended it as an algebraic LISt Processing (hence the name) language for artificial intelligence work l He showed how, given a handful of simple operators and anotation for functions, you can build a whole programming language.

Design Goals l Formalism for developing a theory of computation l Programming language for

Design Goals l Formalism for developing a theory of computation l Programming language for numerical and logical problems l Symbolic manipulation of expressions and sentences

Characteristics l LISP was one of the earliest high-level programming languages and introduced many

Characteristics l LISP was one of the earliest high-level programming languages and introduced many ideas such as garbage collection, recursive functions, symbolic expressions, and dynamic type-checking l Interest in symbolic computation influenced design l Use of simple machine model l Attention to theoretical considerations Recursive function theory, Lambda calculus

Distinctive Characteristics Not C, C++, Java: a chance to think differently l LISt Processing:

Distinctive Characteristics Not C, C++, Java: a chance to think differently l LISt Processing: the ancestor of all functional languages l Lisp is good at handling lists of things, and the abstraction level is higher than C/C++ normally allows you to get to. l

Relative Speeds of 5 language

Relative Speeds of 5 language

Description of Lisp l LISP is usually used as an interpreted language. l The

Description of Lisp l LISP is usually used as an interpreted language. l The interpreter runs what is known as a read- evaluates-print loop.

Description of Lisp l l The two most important kinds of objects in LISP

Description of Lisp l l The two most important kinds of objects in LISP for you to know about are atoms and lists. Atoms are represented as sequences of characters of reasonable length. Such as : 34 or join. Lists are recursively constructed from atoms Such as: (a john 34 c 3 po). The interpreter treats any list as containing the name of a function followed by the arguments to the function. Such as: (+ 2 13 45).

Defining Lisp Function Use defun to define your own functions in LISP. (defun <name>

Defining Lisp Function Use defun to define your own functions in LISP. (defun <name> <parameter-list> <body>) l l Example: >(defun square (x) (* x x)) SQUARE >(square 2) 4

Example Code l reverse : Format: (reverse <list>) Reverse returns a list that contains

Example Code l reverse : Format: (reverse <list>) Reverse returns a list that contains all the elements of <list> in reversed order. l Example: > (reverse '(picard riker worf crusher)) (CRUSHER WORF RIKER PICARD) > (reverse '(picard riker worf crusher))) (PICARD RIKER WORF CRUSHER) l

Resources l l http: //faqs. org/faqs/lisp-faq/part 2/section-13. html http: //www. cc. gatech. edu/data_files/classes/cs 6390/slides/lisp.

Resources l l http: //faqs. org/faqs/lisp-faq/part 2/section-13. html http: //www. cc. gatech. edu/data_files/classes/cs 6390/slides/lisp. pdf http: //web. syr. edu/~aalarifi/Common%20 Lisp. pdf http: //norvig. com/python-lisp. html