"Introduction to Common LISP"

Featured Featured
Download as
 PPT
Presentation Description 

Learning LISP programming language

By:
 (1 month(s) ago)  
Unfortunately I missed them from my hard disk, I don't know how to give you the permission for download, tell me how can I help you?

By:
 (12 month(s) ago)  
Dear Sir, I saw this PPT of LISP. Its quite good. can u please do me a favour to send me this ppt or give me the permission to download this ppt Regards

authorSTREAM Premium Service
What's up on authorSTREAM?
Views: 677
Like it  ( Likes) Dislike it  ( Dislikes)
Added: October 04, 2008 This Presentation is Public 
Presentation Category : Science & Technology All Rights Reserved
Presentation Transcript

Slide 1:? Introduction to Common LISP


Slide 2:1 Introduction Ahmed M. Alaa 2008 Programming Languages are codes written to give special orders to a computer In a way it understands Classification of Programming Languages: OOP : Java, C++, C#...etc Functional (ML) Data base Programming: SQL, Oracle, ASP,…etc Artificial Intelligence: Prolog, LISP Web programming: PHP, HTML, XML…etc Common LISP is one of the most popular programming languages that is used For Artificial intelligence


Slide 3:Introduction Ahmed M. Alaa 2008 LISP is used to introduces intelligence to machines and it has many applications Books you could read in this field: “Practical common LISP” By Peter Seilberg


Slide 4:Ahmed M. Alaa 2008 2 Addition, Subtraction and Multiplication Processes LISP (list processing) is writing orders in the form of List, it consists of: Atom: One component out of list ex: 2 , 3 , k, …etc List: Brackets containing atoms like ( 3 3 4), ( 33 29 54), (3 (33) (41)),…etc How to make arithmetic operations using LISP language: -CL user [1] > (+ 3 3) 6 [2] > (* 6 7) 42 The symbol is written first and then the arguments (the numbers we want to add) The arithmetic symbols: / * + -


Slide 5:Ahmed M. Alaa 2008 Function inside function Addition, Subtraction and Multiplication Processes 2 x 3 6 6 36 Examples: (+ 3 (40) 6) 49 (+ 3 (+ 3 3) 4) 13


Slide 6:3 Comparing Functions Ahmed M. Alaa 2008 The symbols are ( => == 4 1 ) T ( >= 4 1 ) T ( <= 4 1 ) NIL


Slide 7:Ahmed M. Alaa 2008 Un-equality function The symbol is \= True: If values are not equal NIL: If values are equal ( \= 3 3 ) NIL ( \= 4 3 ) True The inversion function is \ and the division function is / ( / 4 2 ) 2 ( \ 4) ¼ Comparing Functions


Slide 8:Ahmed M. Alaa 2008 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


Slide 9:Ahmed M. Alaa 2008 The assigning function Function: setq ( argument ) ( setq x 3 ) 3 ( * x 4 ) 12 Comparing Functions


Slide 10:4 Complex and imaginary numbers Ahmed M. Alaa 2008 A complex number consists of two parts: 1- An imaginary part 2- A real part The imaginary number is the square root of a negative number, we refer to the Imaginary number by the symbol “i” Where “i” is the square root of negative one An example: the complex number 3 + 5i Is written as (#c 3 5 ) We can do operations on the complex numbers [1] > ( * (#c 3 5 ) ( #c 3 -5 ) ) 34


Slide 11:5 Trigonometric Functions Ahmed M. Alaa 2008 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


Slide 12:Trigonometric functions Ahmed M. Alaa 2008 CL USER [1] > ( sin (Angle) ) [2] > ( Acos (Angle)) { in radians }


Slide 13:6 Mathematical Functions Ahmed M. Alaa 2008 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 a value to a variable Print: Printing outputs Examples: [1] > ( EvenP 2 ) T [2] > ( ODDP 2) NIL [3] > (Abs -8) 8


Slide 14:Mathematical Functions Ahmed M. Alaa 2008 [4] > (Abs ( * -2 4 3 ) ) 24 [5] > ( setq x 3 ) 3 [6] > ( sqrt ( * 3 3) ) 3 [7] > (sqrt ( * x x )) 3 [8] > ( print x ) 3


Slide 15:Mathematical Functions Ahmed M. Alaa 2008 Plusp Checks whether the passed number is more than zero [1] > (Plusp 4) T [2] > (Plusp ( * 2 -4 )) NIL Minusp Checks whether the passed number is less than zero [3] > (Minusp -2) T [4] > (Plusp ( * 2 4 )) NIL


Slide 16:Mathematical Functions Ahmed M. Alaa 2008 Zerop Checks whether the passed number is zero or not [5] > ( Zerop 0 ) T [6] > ( Zerop 1 ) T [7] > ( Zerop -0.0 ) T [8] > ( Zerop 0/8 ) T


Slide 17:Mathematical Functions Ahmed M. Alaa 2008 PI A preserved variable for Pi [1] > Pi 3.141592653589793 EXP The exponential function [2] > ( exp 1 ) 2.71828182 [3] > ( exp 2 ) 7.389056098


Slide 18:Mathematical Functions Ahmed M. Alaa 2008 LOG The logarithmic function [1] > ( log 2 ) 0.69314718 GCD The greatest common factor [2] > ( gcd 60 42 ) 6


Slide 19:Mathematical Functions Ahmed M. Alaa 2008 LCM The least common multiple for a number of passed numbers If we passed one number, it returns its absolute value If we didn’t pass any it returns 1 (the neutral element) Examples: {Lcm a b ) == ( / (abs ( * a b)) (gcd a b)) (Lcm a 0) == ( Lcm 0 a ) == 0 [1] > (lcm 25 30) 150 [2] > (lcm -24 18 10) 360


Slide 20:Mathematical Functions Ahmed M. Alaa 2008 INCF Increment function Example: [1] > (setq x 5) 5 [2] > (incf x) 6 [3] > (incf x 3) 9 [4] > (incf x -0.5) 8.5


Slide 21:Mathematical Functions Ahmed M. Alaa 2008 1+ It increments the value by one only, and does NOT store the new value [1] > (setq k 3) 3 [2] > ( 1+ k) 4 To decrement we use the functions “decf” and “1-”


Slide 22:Mathematical Functions Ahmed M. Alaa 2008 SIGNUM It returns -1 if the passed number is negative, 1 if positive and 0 if we passed zero [1] > (signum 0) 0 [2] > (signum 99) 1 [3] > (signum -1.5) 1


Slide 23:Mathematical Functions Ahmed M. Alaa 2008 NUMBERP It returns T if the passed object was a number is, and NIL if not [1] > (numberp 0) T [2] > (numberp 99) T [3] > (numberp Ahmed) NIL


Slide 24:Mathematical Functions Ahmed M. Alaa 2008 RANDOM It selects a random number within a certain specified range [1] > (random 1000) 485 [2] > (random 5.5) 5.0420854 SQRT Calculates the square root of any number (complex or real) [3] > (sqrt 9) 3 [4] > (sqrt -1) #c ( 0.0 1.0) The function ISQRT gets the root of positive numbers only


Slide 25:Mathematical Functions Ahmed M. Alaa 2008 CLS It gets an angle in radians and returns its sine and cosine complex number [1] > (cis 0.0) #c (1.0 0.0) MOD Returns the modulus [2] > (mod 13 4) 1


Slide 26:Mathematical Functions Ahmed M. Alaa 2008 Complex assignments [1] > (setq x (complex 3 5) ) #c ( 3 5 ) The function complexp checks whether the number is complex or not Rationalize and Rational [2] > (rational 0.1) 3602879701896307 / 36028797018963968 [3] > (rationalize 0,1) 1/10