lisp

Views:
 
Category: Education
     
 

Presentation Description

programming langua

Comments

Presentation Transcript

what programming language has dominated artifical intelligence over the past 50 yrs:

Prolog LISP what programming language has dominated artifical intelligence over the past 50 yrs

Introduction:

Introduction Programing languages are codes written to give special oders to a computer in a way it understand Classfication of pogramming languages ovv : Java,c ++,c#...etc Functional(ML) Data base programming : SQL,Oracle,ASP ,…etc Arificial Intellingence : Prolog,Lisp Web programming : PHP,HTML,XML…etc * Common LISP is one of the most popular programming languages that is used for Artificial intelligence

Introduction of lisp:

Introduction of lisp • An AI language developed in 1958 (J. McCarthy at MIT) • Special focus on symbolic processing and symbol manipulation – Linked list structures – Also programs, functions are represented as lists • At one point special LISP computers with basic LISP functions implemented directly on hardware were available ( Symbolics Inc., 80s) LISP today: • Many AI programs now are written in C,C++, Java

Lisp language:

Lisp language LISP Competitors: • Prolog, Python • but LISP keeps its dominance among high level (AI) programming languages Current LISP: • Common Lisp • Scheme are the most widely-known general-purpose Lisp dialects Common LISP: • Interpreter and compiler • CLOS: object oriented programming

LISP tutorial:

LISP tutorial Syntax: • Prefix notation – Operator first, arguments follow – E.g. (+ 3 2) adds 3 and 2 A lot of parentheses • These define lists and also programs • Examples: – (a b c d) is a list of 4 elements (atoms) a,b,c,d – ( defun factorial (num) ( cond ((<= num 0) 1) (t (* (factorial (- num 1)) num)) ))

LISP tutorial: data types:

LISP tutorial: data types Basic data types: • Symbols – a – john – 34 • Lists – ( ) – (a) – (a john 34) – (lambda ( arg ) (* arg arg ))

Addition ,Subtraction & Multiplication Processes :

Addition ,Subtraction & Multiplication Processes LISP is writing oders in the form of list,it consists of: Atom : One component out of list ex:2,3,k,….etc list: Brackets containing atoms like (334),(33 29 54)(3(58)(59)),….etc How to make arithemaric operations using LISP language -CL user[1]>(+33) 6 [2]>(*67) 42

Addition ,Subtraction & Multiplication Processes :

Addition ,Subtraction & Multiplication Processes Function inside function 6 36 Examples: (+ 3 (40) 6) 49 (+ 3(+33)4) 13 2*3 6

Comparing Functions:

Comparing Functions The symbols are (+> < > =< >= <=) The reply of the interpeter is True(T) or Nill (=33) T (<33) Nill (>41) T (>=41) T (<=41) Nill

Comparing Functions:

Comparing Functions Un-equality functions The symbol is \= True: If values are not equal Nill : if values are equal (\=33) Nil (\=43) True

Comparing Functions:

Comparing Functions The inversion function is\ & division function is / (/ 4 2) 2 (\ 4) 1/4

Comparing Functions:

Comparing Functions * Max: It takes the maximum value of some numbers (Max -3 3 40 150 -100) 150 (Max -3 (*3 3) 4 10) 10 * Min: It takes the minimum value of some numbers (min 3 4 10 -5) -5 (min 4 10 20 1) 1

Comparing Functions:

Comparing Functions The assigning function Function : setq ( argument) ( setq * 3) 3 (* * 4) 12

Trigonometric Functions:

Trigonometric Functions LISP : REAL SIN : SIN COS : COS TAN : TAN ASIN : SIN-1 ACOS : COS-1 ATAN : TAN-1 SINH : SINh COSH : COSh TANH : TANh ASINH : SIN-1h ACOSH : COS-1h ATANH : TAN-1H

Trigonometric Functions:

Trigonometric Functions CL USER [1]>(sin(Angle)) [2]>( Acos (Angle)){in radians}

Mathematical Functions:

Mathematical Functions EvenP : It gives True (T) if the number is even OddP : It gives True (T) if the number is odd Abs: Gives the absolute value of any number setq : Assigns the value to a variable Print: Printing outputs Examples : [1]>( evenp 2) T [2]>(ODDP 2) NIL [3]>(ABS -8) 8

Mathematical Functions:

Mathematical Functions [4]>(Abs (* -2 4 3)) 24 [5]>( setq * 3) 3 [6]>( sqrt (* 3 3)) 3 [7]>( sqrt (* x x )) 3 [8]>(print x) 3

Mathematical Functions:

Mathematical Functions PLUSP CHECKS WETHER THE PASSED NUMBER IS MORE THAN ZERO [1]>(PLUSP 4) T MINUSP CHECKS WETHER THE PASSED NUMBER IS LESS THAN ZERO [3] >(MINUSP -2) T

Mathematical Functions:

Mathematical Functions ZEROP CHECKS WETHER THE PASSED NUMBER IS ZERO OR NOT [5]>(ZEROP 0) T

LISP tutorial: input/output :

LISP tutorial: input/output You can input/output data to: • standard input/output, • string or • file A number of functions supported by the Lisp : • (read) ;; reads the input from the standard input • (print ‘a) ;; prints to the standard output • ( scanf …) ( printf …) (format …) for formatted input and output • (open ..) (close ..) for opening and closing the files • (load ..) reads and executes the file

PowerPoint Presentation:

Than Q by

authorStream Live Help