Introduction to LISP<br />
Overview<br />AGENDA<br />History<br />Introduction<br />Lisp Features<br />Syntax<br />Comparison structures<br />Lambda ...
Lisp was invented by John McCarthy in 1958 while he was at the MIT.<br />McCarthy published its design in a paper in Commu...
A Lisp machine at the MIT museum<br />
Introduction to Lisp(List processing)<br />Lisp is second oldest  high-level programming languages with a long history and...
Lisp features<br />Built in support for Lists.<br />Atomic storage management.<br />Dynamic Typing<br />Uniform syntax.<br...
Syntax (Data structures)<br />Lists are surrounded by parenthesis.<br />Ex: (),(()),((a,b,c)),((1,2),3,4) are all Lists.<b...
Function Definition<br />List represents function calls as well as basic data structures.<br />(factorial 4)12<br />(+4 2...
Function inside function<br />Ex: (+3(40)6)49<br />      (+3(+3 3)4)13<br />Addition, subtraction and multiplication pro...
Comparing functions<br />The comparison symbols are( => ,< ,> ,=<, >= ,<= )<br />These function return either True(T) or N...
Other comparison function<br /><ul><li>Un-equality function( =)</li></ul>Returns TRUE if values are not equal else NIL if ...
Assigning functions:<br />Syntax: setq( argument)<br />Ex: (setq a 3)3<br />      (* a 4)12<br />Explicit evaluation cal...
4 equality predicates: (=, equal, eq, eql) for numerical values only.<br />Ex:<br />(= 2 4/2) T<br />(setf a (1 2)) (1 2...
Nil represents false and an empty list.<br />Ex:<br />(null nil)T<br />(null())T<br />(null ‘(a b))NIL<br />(not ‘(a b)...
Lambda expressions<br />Lambda operator is used to bind variables to values which are then evaluated within an expression....
Conses and lists<br />A lisp list is a singly linked list, Each cell of this list is called a Cons, is composed of two poi...
List-processing procedures<br />List can be directly created with the list procedure, which takes any number of arguments ...
Basic lisp examples<br />Basic hello world program(print “Hello world”)<br />To evaluate factorial on a number(n)<br /><u...
Lisp Summary<br />Simple syntax.  so, its very easy to parse.<br />Programming in Lisp is distinguished from other program...
Applications of Lisp programming<br />Common Lisp is used to develop research applications(often in Artificial Intelligenc...
G2
Upcoming SlideShare
Loading in...5
×

LISP: Introduction to lisp

5,654

Published on

LISP: Introduction to lisp

Published in: Technology, Education
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,654
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

LISP: Introduction to lisp

  1. 1. Introduction to LISP<br />
  2. 2. Overview<br />AGENDA<br />History<br />Introduction<br />Lisp Features<br />Syntax<br />Comparison structures<br />Lambda expressions<br />Conses and Lists<br />List processing procedures<br />Summary<br />Lisp applications<br />
  3. 3. Lisp was invented by John McCarthy in 1958 while he was at the MIT.<br />McCarthy published its design in a paper in Communications of the ACM in 1960.<br />Lisp was first implemented by Steve Russell on an IBM 704 computer.<br />Connection to AI:<br />Lisp was closely connected to AI research communities, especially on PDP-10 systems.<br />Lisp was used as the implementation of the programming language Micro Planner which was used in the famous AI system SHRUDLU.<br />Over its fifty-year history, lisp has spawned many variations on the core theme of an S-expression language. <br />Lisp history<br />
  4. 4. A Lisp machine at the MIT museum<br />
  5. 5. Introduction to Lisp(List processing)<br />Lisp is second oldest high-level programming languages with a long history and a distinctive, fully parenthesized syntax.<br />Lisp is a Tool to solve some of the most difficult problems in the world of computing.<br />It is an example of elegant, minimalist language.<br />Lisp is one of the most popular programming languages that is used for Artificial intelligence.<br />
  6. 6. Lisp features<br />Built in support for Lists.<br />Atomic storage management.<br />Dynamic Typing<br />Uniform syntax.<br />Interactive environment.<br />Extensibility<br />Standard macros.<br />Special forms(loop, do, dotimes..)<br />
  7. 7. Syntax (Data structures)<br />Lists are surrounded by parenthesis.<br />Ex: (),(()),((a,b,c)),((1,2),3,4) are all Lists.<br />Atoms are string of characters beginning with letter, digit or special characters other than left “(“ and right “)” <br />Ex: (a b c d) is a list of four elements(atoms) a,b,c,d<br /> Peace<br /> Of<br /> Mind<br /> 6678<br />Prefix notation is followed in Lisp.<br />Operators first, followed by the arguments.<br />Ex: (+ 4 5)  adds 4 to 5<br /> (/ 12 6)2<br />
  8. 8. Function Definition<br />List represents function calls as well as basic data structures.<br />(factorial 4)12<br />(+4 2)6<br />Definition of a function<br />(defun <f-name><parameter-list><body>)<br />Ex: (defun square(X)<br /> (*XX))<br /> SQUARE<br />>(square2)4<br />>(square(square 2))16<br />
  9. 9. Function inside function<br />Ex: (+3(40)6)49<br /> (+3(+3 3)4)13<br />Addition, subtraction and multiplication process<br />2*3<br />36<br />6<br />
  10. 10. Comparing functions<br />The comparison symbols are( => ,< ,> ,=<, >= ,<= )<br />These function return either True(T) or Nil.<br />Ex: (= 4 4)T<br /> (< 4 4)NIL<br /> (> 5 1)T<br /> (>= 6 3)T<br /> (<= 4 3)NIL<br />
  11. 11. Other comparison function<br /><ul><li>Un-equality function( =)</li></ul>Returns TRUE if values are not equal else NIL if values are equal.<br /><ul><li>Division function(/)</li></ul>Ex: (/4 2) 2<br /><ul><li>Max: It takes the maximum value of some numbers</li></ul>Ex: (Max -3 3 40 150 -100)150<br /><ul><li>Min: It takes the minimum value of some numbers</li></ul>Ex: (Min 3 4 10 -5)-5<br />
  12. 12. Assigning functions:<br />Syntax: setq( argument)<br />Ex: (setq a 3)3<br /> (* a 4)12<br />Explicit evaluation call;<br />(eval a)3<br />Note: A quoted value is always kept untouched.<br />(setq b ‘(+ a 4))(+ a 4)<br />
  13. 13. 4 equality predicates: (=, equal, eq, eql) for numerical values only.<br />Ex:<br />(= 2 4/2) T<br />(setf a (1 2)) (1 2)<br />(setf b (1 2)) (1 2)<br />(equal a b)T<br />(eql 3 9/3)T<br />
  14. 14. Nil represents false and an empty list.<br />Ex:<br />(null nil)T<br />(null())T<br />(null ‘(a b))NIL<br />(not ‘(a b))NIL<br />
  15. 15. Lambda expressions<br />Lambda operator is used to bind variables to values which are then evaluated within an expression.<br />Arguments to lambda are list of arguments, and the expression or expressions to which the function evaluates.<br /> (lambda (arg) (arg+1)) evaluates to the function that, when applied takes one argument , binds it to arg and returns the number one greater then that argument.<br />Ex: (lambda (arg) (arg+1) 4)5<br />
  16. 16. Conses and lists<br />A lisp list is a singly linked list, Each cell of this list is called a Cons, is composed of two pointers, called the car and cdr.<br />If the given cons is taken to be the head of the linked list, then its car points to the first element of the list, and its cdr points to the rest of the List.<br />A variable which refers to the list is simply a pointer to the first cons of the list.<br />Parenthesized S-expressions represent Linked list structure.<br />
  17. 17. List-processing procedures<br />List can be directly created with the list procedure, which takes any number of arguments and returns the list of these arguments.<br />Ex: (List 1 2 ‘ a 3) ( 1 2 a 3)<br /> (List 1 ‘ (2 3) 4)(1 (2 3) 4)<br />For the linked lists cons procedure can be used to add an element to the front of the list.<br />Ex: (cons 1 ‘ (2 3))(1 2 3)<br />Append procedure append two or more lists to one another.<br />Ex: (append ‘ (1 2) ‘ (3 4))(1 2 3 4)<br />
  18. 18. Basic lisp examples<br />Basic hello world program(print “Hello world”)<br />To evaluate factorial on a number(n)<br /><ul><li>(defun factorial (n)</li></ul> (if (<= n 1)<br /> 1<br /> (* n (factorial(- n 1)))))<br />//iterative version which uses common Lisp’s Loop Macro//<br /><ul><li>(defun factorial (n)</li></ul> (loop for I from 1 to n<br /> for fac=1 then (* fac i)<br /> finally (return fac)))<br />//using recursive function//<br /><ul><li>(defun –reverse (list)</li></ul> (let ((return –value ‘()))<br /> (dolist (e list) (push e return-value))<br /> return-value))<br />
  19. 19. Lisp Summary<br />Simple syntax. so, its very easy to parse.<br />Programming in Lisp is distinguished from other programming languages due to its unique syntax and development mode.<br />The interchangeability of code and data also gives Lisp instantly recognizable syntax. <br />All lisp program code is written as S-expressions , or parenthesized lists.<br />
  20. 20. Applications of Lisp programming<br />Common Lisp is used to develop research applications(often in Artificial Intelligence)<br />For rapid development of prototypes<br />Lisp language is often used in interactive command line, which may be combined with an IDE.<br />Common Lisp is used in many commercial applications, Including the Yahoo! Store Web-commerce site.<br />Other visible applications people have developed using Lisp are:<br /><ul><li>Emacs
  21. 21. G2
  22. 22. AutoCAD
  23. 23. Igor Engraver</li></li></ul><li>Pick a tutorial of your choice and browse through it at your own pace.<br />The tutorials section is free, self-guiding and will not involve any additional support.<br />Visit us at www.dataminingtools.net<br />Visit more self help tutorials<br />

×