728x90 AdSpace

Latest Article

LISP Tutorial AI Artificial Intelligence LISP Programming Basic Introduction

LISP Tutorial On-line,  AI Artificial Intelligence LISP Programming Basic Introduction with examples 
In AI history IPL (Information Processing Language) is often considered to be first language in which first AI program, The Logic Theorist, was written, (by Allen Newell, J. C. Shaw, and Herbert Simon). Later on LISP became the most popular language for the development of AI programs.  LISP is an acronym for “LISt Processor”. Symbolic processing languages are the languages specifically designed for the manipulation of symbols and writing AI programs. These often also termed as “list processing” languages. LISP was developed in 1958 at MIT (Massachusetts Institute of Technology), by John McCarthy. Some important features of lisp are given below:

Ø  Interpreter (Read-Eval-Print loop)
Ø  Procedural/Functional
Ø  Symbolic manipulation (each language for specific task)
Ø  Syntax flexible (macros)
Ø  No distinction between data and code
Ø  Object Oriented Programming (CLOS)
Ø  Garbage Collection
Ø  S-expression  (atom, list)
Ø  List (small parenthesis) is basis of program, List is main data structure
Ø  False = nil = ( ) = empty list
Ø  Comments  ( ;  comment  #|  multilane comment |#)
Ø  Case sensitivity
Ø  Quote, set, Setq, functions
Ø  Predicate functions (null,  atom, listp, consp, oddp etc)
Ø  Conditionals (if , cond , or , and , not)  
1.      SYNTAX
Ø  Prefix syntax
Ø  Simple Function Calls ( + , - , / , * , ) , embedded function calls

Ø  A Number, string or special symbol ( T/ nil) is evaluated to self.
Ø   A Symbol is evaluated to its value.
Ø  For List ,  first element of the list should a function name, arguments (remaining elements of the list) are evaluated first (only once), then the function is executed.
Ø  Quote is a special function which stops the evaluation of its argument.
Ø  Setq also did not allow the evaluation of its first argument (which should be a symbol), but its second argument is evaluated then it assign the value of second argument to the first symbol.

3.      LIST ACCESSING (car, first, cdr, rest, second, third, nth etc.)
> (car ‘( a  b  c))
> (cdr ‘( a  b  c))
( B    C)

> (second ‘( a  b  c))
> (tenth  ‘( a  b  c))

> (car ‘( (a  b  c))      )
(A B  C)

> (cdr ‘( (a  b  c) )    )

> (nth  1 ‘( a  b  c )    )

> (last   ‘( a  b  c)        )

4.      LIST MANIPULATING (length, member, equal, position, subseq etc)
> (length   ‘( a  b  c)        )
> (member  ‘b   ‘( a  b  c)        )
(B C)
> (position  ‘b   ‘( a  b  c)        )

> (subseq    ‘( a  b  c   d    e    f     g)    2    5        )
(C   D    E)

5.      LIST CREATING (Cons, List, Append)
> (cons ‘K nil)
( K )

> (cons ‘(A   B)  (cons ‘C nil)  )
((A   B)   C)

> (cons ‘A (cons ‘b (cons ‘c nil)))
(A   B   C)

> (list ‘A  ‘B  ‘C )
(A   B   C)

> (list ‘A   nil    ( )  100  ‘(x  y  z)   ‘hello  )
(A   nil    nil  100  (x  y  z)   hello)

> (append    ‘(A)   ‘(B)    ‘(C)  ‘(D)   )
(A   B   C  D)

> (append    ‘((A)  B)    ‘(C)  ‘(((D)))   )
((A)   B   C  ((D)) )
8.   PREDICATES  (numberp, listp, atom, symbolp, zerop, oddp, evenp, stringp, equal)

> (numberp  10)

> (symbpolp  ‘abc)

> (atom  10)

> (listp  10)

> (listp  ‘( 1 0) )

> (null  ( ))

> (null  nil)
> (stringp  ‘abc)

> (stringp  “abc”)

> (equal  ‘abc   ‘ABC)

> (equal  ‘(x y z)   ‘(x  y  z) )
no image
  • Title : LISP Tutorial AI Artificial Intelligence LISP Programming Basic Introduction
  • Posted by :
  • Date : 10:33
  • Labels :

  • Blogger Comments
  • Facebook Comments


  1. The pioneering artificial intelligence theorist Marvin Minsky died Sunday. So we thought it would be appropriate to ask for an obituary from one of his virtual descendants: Wordsmith, the automated news-writing bot from the company virtual assistant software