SlideShare a Scribd company logo
1 of 35
PRESENTATION OF
ARTIFICIAL
INTELLIGENCE
TOPIC TO BE DISCUSSED
An INTRODUCTION OF LISP ?
FEATUERS OF LISP
TEXT EDITOR
LISP EXECUTOR
LISP – BASIC SYNTAX
LISP-DATA TYPES
LISP CONSTANT
LISP VARIABLES
LISP OPERATOR
DECISION MAKING
LISP ARRAY
LISP LOOP
AN INTRODUCTION OF LISP ?
•Lisp – List Processing language
• John McCarthy invented LISP in 1958, shortly after the development of
FORTRAN. It was first implement by Steve Russell on an IBM 704 computer
• It is one of the most popular language for Artificial Intelligence programs
• FEATURES OF LISP:
• It is machine-independent
• It allows updating the programs dynamically.
• It provides high level debugging.
FEATUERS OF LISP
• It provides wide-ranging data types like, objects, structures, lists, vectors, adjustable
arrays, hash-tables, and symbols.
• It provides an object-oriented condition system.
• It provides complete I/O library.
• It provides extensive control structures.
• Lisp was originally created as a practical mathematical notation for computer programs
USES OF COMMON LISP
USES OF CL
• CL is a very successful language in that
it is extremely powerful as an AI tool
those that use it love it
• And yet CL is a very uncommon language because
it is very complicated
most software development is in C++ (with some in Java, C#, C, Python, Ada, etc)
such that few programmers would choose to use CL for development
• The most important software developed from CL includes:
– Emacs
– G2 (a real-time expert system)
– AutoCAD
– Igor Engraver (musical notation editor and publisher)
– Yahoo Store
TEXT EDITOR
• This will be used to type your program. Examples of few editors include Windows
Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi.
• Name and version of text editor can vary on different operating systems. For example,
Notepad will be used on Windows, and vim or vi can be used on windows as well as
Linux or UNIX.
• The files you create with your editor are called source files and contain program source
code. The source files for Lisp programs are typically named with the extension ".lisp".
• Before starting your programming, make sure you have one text editor in place and
you have enough experience to write a computer program, save it in a file, finally
execute it.
TEXT EDITOR
• The source code written in source file is the human readable source for your program.
It needs to be "executed", to turn into machine language so that your CPU can actually
execute the program as per instructions given.
• This Lisp programming language will be used to execute your source code into final
executable program. I assume you have basic knowledge about a programming
language.
• CLISP is the GNU Common LISP multi-architechtural compiler used for setting up
LISP in Windows.
LISP EXECUTOR
LISP - BASIC SYNTAX
LISP programs are made up of three basic building blocks:
• atom
• list
• string
ATOM:
An atom is a number or string of contiguous characters. It includes numbers and special
characters.
LISP BASIC SYNTAX
EXAMPLE:
Name
2343333
*HELLO*
3333309
abc123
DEFINE LIST
LIST
A list is a sequence of atoms and/or other lists enclosed in parentheses
EXAMPLE
(I AM A GENIOUS GIRL)
(I AM A LIST)
(A(A B C)D )
DEFINE STRING
STRING
A string is a group of characters enclosed in double quotation marks
EXAMPLE
“I AM A STRING”
“ HELLO WORLD”
“PLEASE ENTER THE FOLLOWING DETAILS”
ADDING COMMENTS
COMMENTS
The semicolon symbol (;) is used for indicating a comment line
EXAMPLES
“I AM A STRING”
; HELLO WORLD
“PLEASE ENTER THE FOLLOWING DETAILS”
CONCEPTS ABOUT LISP
Following are some of the important points to note
The basic numeric operations in LISP are +, -, *, and /
LISP expressions are case-insensitive
Naming Conventions in LISP
• Name or symbols can consist of any number of alphanumeric characters other than
whitespace, open and closing parentheses, double and single quotes, backslash, comma,
colon, semicolon and vertical bar. To use these characters in a name, you need to use
escape character ().
• A name can have digits but not entirely made of digits, because then it would be read as a
number. Similarly a name can have periods, but can't be made entirely of periods.
LISP DATA TYPES
LISP data types can be categorized as
• Scalar types - for example, number types, characters, symbols etc.
• Data structures - for example, lists, vectors, bit-vectors, and strings.
LISP VARIABLES
Global Variables
• Global variables have permanent values throughout the LISP system and remain in
effect until a new value is specified.
• Global variables are generally declared using the defvar construct.
Example
(Defvar X 234)
(Write x)
output: (234)
• Since there is no type declaration for variables in LISP, you directly specify a value
for a symbol with the setq construct
• Example
(set q x 10 )
(format t "x = ~2d ~%" x )
• The above expression assigns the value 10 to the variable x
output: (x = 10)
LISP VARIABLE
LOCAL VARIABLE
• Local variables are defined within a given procedure. The parameters named as
arguments within a function definition are also local variables. Local variables are
accessible only within the respective function.
• Like the global variables, local variables can also be created using the setqconstruct.
• There are two other constructs - let and prog for creating local variables.
EXAMPLE:
 (let ( (x’ a) (y ’b) (z’ c)))
Output: x = A y = B z = C
 (prog ((x '(a b c))(y '(1 2 3))(z '(p q 10)))
Output : x = (A B C) y = (1 2 3) z = (P Q 10)
LISP CONSTANT
CONSTANT
In LISP, constants are variables that never change their values during program
execution.
Constants are declared using the defconstant construct.
EXAMPLE
PI value is 3.14
Value cannot be changed
LISP OPERATOR
OPERATOR
An operator is a symbol that tells the compiler to perform specific mathematical or logical
manipulations.
The operations allowed on data could be categorized as:
• Arithmetic Operations
• Comparison Operations
• Logical Operations
• Bitwise Operations
LISP OPERATOR
ARITHMETIC OPERATORS
IF VARIABLE A HOLDS 10 AND VARIABLE B HOLDS 20
DESCRIPTION EXAMPLE
+ Adds two operands (+AB) will give 30
- Subtracts second operand from the first (- A B) will give -10
* Multiplies both operands
(* A B) will give 200
LISP OPERATOR
OPERATOR DESCRIPTION EXAMPLE
/
Divides numerator by de-numerator
(/ B A) will give 2
Mod,rem Modulus Operator and remainder of after an
integer division
(mod B A )will give
0
incf Increments operator increases integer value
by the second argument specified
(incf A 3) will give
13
decf Decrements operator decreases integer
value by the second argument specified
(decf A 4) will give 9
COMPARISON OPERATOR
OPERATO
R
DESCRIPTION EXAMPLE
= Checks if the values of the operands are
all equal or not, if yes then condition
becomes true.
(= A B) is not true.
/= Checks if the values of the operands are
all different or not, if values are not equal
then condition becomes true.
(/= A B) is true.
Assume variable A holds 10 and variable B holds
20, then:
COMPARISON OPERATOR
> Checks if the values of the operands are monotonically decreasing. (> A B) is not true.
< Checks if the values of the operands are monotonically increasing. (< A B) is true.
>= Checks if the value of any left operand is greater than or equal to the
value of next right operand, if yes then condition becomes true.
(>= A B) is not true.
COMPARISON OPERATOR
<= Checks if the value of any left operand is less than
or equal to the value of its right operand, if yes then
condition becomes true.
(<= A B) is true.
max It compares two or more arguments and returns
the maximum value.
(max A B) returns 20
min It compares two or more arguments and returns
the minimum value.
(min A B) returns 20
LOGICAL OPERATION ON BOOLEAN
VALUES
Common LISP provides three logical operators: and, or, and not that operates on
Boolean values. Assume A has value nil and B has value 5, then:
OPETATOR DESCRIPTION
EXAMPLE
and It takes any number of arguments. The arguments are
evaluated left to right. If all arguments evaluate to non-nil, then
the value of the last argument is returned. Otherwise nil is
returned.
(and A B) will
return NIL.
or It takes any number of arguments. The arguments are
evaluated left to right until one evaluates to non-nil, in such
case the argument value is returned, otherwise it returns nil
(or A B) will
return 5
not It takes one argument and returns t if the
argument evaluates to nil.
(not A) will
return T.
BITWISE OPERATIONS ON NUMBERS
• Bitwise operators work on bits and perform bit-by-bit operation. The truth tables for
bitwise and, or, and xor operations are as follows
p q P and q P or q P xor q
0 0 0 0 0
0 1 0 1 1
1 1 1 1 0
1 0 0 1 1
DECISION MAKING
• Decision making structures require that the programmer specify one or
more conditions to be evaluated or tested by the program, along with a
statement or statements to be executed if the condition is determined to be
true, and optionally, other statements to be executed if the condition is
determined to be false.
EXAMPLE
IF-ELSE STRUCTURE
DECISION MAKING
IF-ELSE STRUCTURE:
LISP LOOP
• There may be a situation, when you need to execute a block of code numbers of times.
A loop statement allows us to execute a statement or group of statements multiple
times and following is the general form of a loop statement in most of the programming
languages.
• LISP provides the following types of constructs to handle looping requirements.
LISP LOOP
LISP LOOP
CONSTRUC
T
DESCRIPTION
loop The loop construct is the simplest form of iteration provided by LISP. In its simplest form, it
allows you to execute some statement(s) repeatedly until it finds a return statement.
Loop for The loop for construct allows you to implement a for-loop like iteration as most common in
other languages.
do The do construct is also used for performing iteration using LISP. It provides a structured
form of iteration.
dotimes The dotimes construct allows looping for some fixed number of
iterations.
dolist The dolist construct allows iteration through each element of a list.
LISP ARRAY
• LISP allows you to define single or multiple-dimension arrays using the make-
array function. An array can store any LISP object as its elements.
• All arrays consist of contiguous memory locations. The lowest address corresponds to
the first element and the highest address to the last element.
• In LISP, an array element is specified by a sequence of non-negative integer
• indices. The length of the sequence must equal the rank of the array. Indexing starts
from zero.
• The number of dimensions of an array is called its rank.
LISP ARRAY
HOW TO DECLARE AN ARRAY
• For example, to create an array with 10- cells, named my-array, we can write:
• (setf my-array(make array(10)))
• The aref function allows accessing the contents of the cells. It takes two arguments, the
name of the array and the index value.
• For example, to access the content of the tenth cell, we write:
(aref my-array 9)

More Related Content

What's hot

Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
Mohd Arif
 
Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
UC San Diego
 

What's hot (20)

AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
ProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) IntroductionProLog (Artificial Intelligence) Introduction
ProLog (Artificial Intelligence) Introduction
 
Word embedding
Word embedding Word embedding
Word embedding
 
Lisp
LispLisp
Lisp
 
Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3Artificial Intelligence Notes Unit 3
Artificial Intelligence Notes Unit 3
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Lecture 26 local beam search
Lecture 26 local beam searchLecture 26 local beam search
Lecture 26 local beam search
 
Regular Grammar
Regular GrammarRegular Grammar
Regular Grammar
 
Lecture 3 general problem solver
Lecture 3 general problem solverLecture 3 general problem solver
Lecture 3 general problem solver
 
Uncertainty in AI
Uncertainty in AIUncertainty in AI
Uncertainty in AI
 
Socket programming in Java (PPTX)
Socket programming in Java (PPTX)Socket programming in Java (PPTX)
Socket programming in Java (PPTX)
 
Clustering in Data Mining
Clustering in Data MiningClustering in Data Mining
Clustering in Data Mining
 
AI Programming language (LISP)
AI Programming language (LISP)AI Programming language (LISP)
AI Programming language (LISP)
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in Compiler
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
 
Bayesian network
Bayesian networkBayesian network
Bayesian network
 
Regular expression with DFA
Regular expression with DFARegular expression with DFA
Regular expression with DFA
 
Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2
 
Primality
PrimalityPrimality
Primality
 

Similar to Lisp

AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
prakashvs7
 
Lisp and scheme i
Lisp and scheme iLisp and scheme i
Lisp and scheme i
Luis Goldster
 
Unit1 111206003944-phpapp02
Unit1 111206003944-phpapp02Unit1 111206003944-phpapp02
Unit1 111206003944-phpapp02
riddhi viradiya
 
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
Q-Step_WS_02102019_Practical_introduction_to_Python.pptxQ-Step_WS_02102019_Practical_introduction_to_Python.pptx
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
nyomans1
 

Similar to Lisp (20)

Lecture 2 lisp-Overview
Lecture 2 lisp-OverviewLecture 2 lisp-Overview
Lecture 2 lisp-Overview
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
 
Mbd dd
Mbd ddMbd dd
Mbd dd
 
Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISP
 
intro.ppt
intro.pptintro.ppt
intro.ppt
 
Lisp, An Introduction.ppt
Lisp, An Introduction.pptLisp, An Introduction.ppt
Lisp, An Introduction.ppt
 
intro.ppt
intro.pptintro.ppt
intro.ppt
 
Lisp and scheme i
Lisp and scheme iLisp and scheme i
Lisp and scheme i
 
modul-python-all.pptx
modul-python-all.pptxmodul-python-all.pptx
modul-python-all.pptx
 
LISP.ppt
LISP.pptLISP.ppt
LISP.ppt
 
002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type script
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
Parquet - Data I/O - Philadelphia 2013
Parquet - Data I/O - Philadelphia 2013Parquet - Data I/O - Philadelphia 2013
Parquet - Data I/O - Philadelphia 2013
 
Advance Python programming languages-Simple Easy learning
Advance Python programming languages-Simple Easy learningAdvance Python programming languages-Simple Easy learning
Advance Python programming languages-Simple Easy learning
 
Unit1 111206003944-phpapp02
Unit1 111206003944-phpapp02Unit1 111206003944-phpapp02
Unit1 111206003944-phpapp02
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
Q-Step_WS_02102019_Practical_introduction_to_Python.pptxQ-Step_WS_02102019_Practical_introduction_to_Python.pptx
Q-Step_WS_02102019_Practical_introduction_to_Python.pptx
 
Q-SPractical_introduction_to_Python.pptx
Q-SPractical_introduction_to_Python.pptxQ-SPractical_introduction_to_Python.pptx
Q-SPractical_introduction_to_Python.pptx
 
Basics Of C Programming For Beginners In Easiest Way
Basics Of C Programming For Beginners In Easiest WayBasics Of C Programming For Beginners In Easiest Way
Basics Of C Programming For Beginners In Easiest Way
 
Basic C Programming language
Basic C Programming languageBasic C Programming language
Basic C Programming language
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
Christopher Logan Kennedy
 

Recently uploaded (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Lisp

  • 2. TOPIC TO BE DISCUSSED An INTRODUCTION OF LISP ? FEATUERS OF LISP TEXT EDITOR LISP EXECUTOR LISP – BASIC SYNTAX LISP-DATA TYPES LISP CONSTANT LISP VARIABLES LISP OPERATOR DECISION MAKING LISP ARRAY LISP LOOP
  • 3. AN INTRODUCTION OF LISP ? •Lisp – List Processing language • John McCarthy invented LISP in 1958, shortly after the development of FORTRAN. It was first implement by Steve Russell on an IBM 704 computer • It is one of the most popular language for Artificial Intelligence programs • FEATURES OF LISP: • It is machine-independent • It allows updating the programs dynamically. • It provides high level debugging.
  • 4.
  • 5. FEATUERS OF LISP • It provides wide-ranging data types like, objects, structures, lists, vectors, adjustable arrays, hash-tables, and symbols. • It provides an object-oriented condition system. • It provides complete I/O library. • It provides extensive control structures. • Lisp was originally created as a practical mathematical notation for computer programs
  • 6. USES OF COMMON LISP USES OF CL • CL is a very successful language in that it is extremely powerful as an AI tool those that use it love it • And yet CL is a very uncommon language because it is very complicated most software development is in C++ (with some in Java, C#, C, Python, Ada, etc) such that few programmers would choose to use CL for development • The most important software developed from CL includes: – Emacs – G2 (a real-time expert system) – AutoCAD – Igor Engraver (musical notation editor and publisher) – Yahoo Store
  • 7. TEXT EDITOR • This will be used to type your program. Examples of few editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi. • Name and version of text editor can vary on different operating systems. For example, Notepad will be used on Windows, and vim or vi can be used on windows as well as Linux or UNIX. • The files you create with your editor are called source files and contain program source code. The source files for Lisp programs are typically named with the extension ".lisp". • Before starting your programming, make sure you have one text editor in place and you have enough experience to write a computer program, save it in a file, finally execute it.
  • 8. TEXT EDITOR • The source code written in source file is the human readable source for your program. It needs to be "executed", to turn into machine language so that your CPU can actually execute the program as per instructions given. • This Lisp programming language will be used to execute your source code into final executable program. I assume you have basic knowledge about a programming language. • CLISP is the GNU Common LISP multi-architechtural compiler used for setting up LISP in Windows.
  • 10. LISP - BASIC SYNTAX LISP programs are made up of three basic building blocks: • atom • list • string ATOM: An atom is a number or string of contiguous characters. It includes numbers and special characters.
  • 12. DEFINE LIST LIST A list is a sequence of atoms and/or other lists enclosed in parentheses EXAMPLE (I AM A GENIOUS GIRL) (I AM A LIST) (A(A B C)D )
  • 13. DEFINE STRING STRING A string is a group of characters enclosed in double quotation marks EXAMPLE “I AM A STRING” “ HELLO WORLD” “PLEASE ENTER THE FOLLOWING DETAILS”
  • 14. ADDING COMMENTS COMMENTS The semicolon symbol (;) is used for indicating a comment line EXAMPLES “I AM A STRING” ; HELLO WORLD “PLEASE ENTER THE FOLLOWING DETAILS”
  • 15. CONCEPTS ABOUT LISP Following are some of the important points to note The basic numeric operations in LISP are +, -, *, and / LISP expressions are case-insensitive Naming Conventions in LISP • Name or symbols can consist of any number of alphanumeric characters other than whitespace, open and closing parentheses, double and single quotes, backslash, comma, colon, semicolon and vertical bar. To use these characters in a name, you need to use escape character (). • A name can have digits but not entirely made of digits, because then it would be read as a number. Similarly a name can have periods, but can't be made entirely of periods.
  • 16. LISP DATA TYPES LISP data types can be categorized as • Scalar types - for example, number types, characters, symbols etc. • Data structures - for example, lists, vectors, bit-vectors, and strings.
  • 17. LISP VARIABLES Global Variables • Global variables have permanent values throughout the LISP system and remain in effect until a new value is specified. • Global variables are generally declared using the defvar construct. Example (Defvar X 234) (Write x) output: (234) • Since there is no type declaration for variables in LISP, you directly specify a value for a symbol with the setq construct • Example (set q x 10 ) (format t "x = ~2d ~%" x ) • The above expression assigns the value 10 to the variable x output: (x = 10)
  • 18. LISP VARIABLE LOCAL VARIABLE • Local variables are defined within a given procedure. The parameters named as arguments within a function definition are also local variables. Local variables are accessible only within the respective function. • Like the global variables, local variables can also be created using the setqconstruct. • There are two other constructs - let and prog for creating local variables. EXAMPLE:  (let ( (x’ a) (y ’b) (z’ c))) Output: x = A y = B z = C  (prog ((x '(a b c))(y '(1 2 3))(z '(p q 10))) Output : x = (A B C) y = (1 2 3) z = (P Q 10)
  • 19. LISP CONSTANT CONSTANT In LISP, constants are variables that never change their values during program execution. Constants are declared using the defconstant construct. EXAMPLE PI value is 3.14 Value cannot be changed
  • 20. LISP OPERATOR OPERATOR An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. The operations allowed on data could be categorized as: • Arithmetic Operations • Comparison Operations • Logical Operations • Bitwise Operations
  • 21. LISP OPERATOR ARITHMETIC OPERATORS IF VARIABLE A HOLDS 10 AND VARIABLE B HOLDS 20 DESCRIPTION EXAMPLE + Adds two operands (+AB) will give 30 - Subtracts second operand from the first (- A B) will give -10 * Multiplies both operands (* A B) will give 200
  • 22. LISP OPERATOR OPERATOR DESCRIPTION EXAMPLE / Divides numerator by de-numerator (/ B A) will give 2 Mod,rem Modulus Operator and remainder of after an integer division (mod B A )will give 0 incf Increments operator increases integer value by the second argument specified (incf A 3) will give 13 decf Decrements operator decreases integer value by the second argument specified (decf A 4) will give 9
  • 23. COMPARISON OPERATOR OPERATO R DESCRIPTION EXAMPLE = Checks if the values of the operands are all equal or not, if yes then condition becomes true. (= A B) is not true. /= Checks if the values of the operands are all different or not, if values are not equal then condition becomes true. (/= A B) is true. Assume variable A holds 10 and variable B holds 20, then:
  • 24. COMPARISON OPERATOR > Checks if the values of the operands are monotonically decreasing. (> A B) is not true. < Checks if the values of the operands are monotonically increasing. (< A B) is true. >= Checks if the value of any left operand is greater than or equal to the value of next right operand, if yes then condition becomes true. (>= A B) is not true.
  • 25. COMPARISON OPERATOR <= Checks if the value of any left operand is less than or equal to the value of its right operand, if yes then condition becomes true. (<= A B) is true. max It compares two or more arguments and returns the maximum value. (max A B) returns 20 min It compares two or more arguments and returns the minimum value. (min A B) returns 20
  • 26. LOGICAL OPERATION ON BOOLEAN VALUES Common LISP provides three logical operators: and, or, and not that operates on Boolean values. Assume A has value nil and B has value 5, then: OPETATOR DESCRIPTION EXAMPLE and It takes any number of arguments. The arguments are evaluated left to right. If all arguments evaluate to non-nil, then the value of the last argument is returned. Otherwise nil is returned. (and A B) will return NIL. or It takes any number of arguments. The arguments are evaluated left to right until one evaluates to non-nil, in such case the argument value is returned, otherwise it returns nil (or A B) will return 5 not It takes one argument and returns t if the argument evaluates to nil. (not A) will return T.
  • 27. BITWISE OPERATIONS ON NUMBERS • Bitwise operators work on bits and perform bit-by-bit operation. The truth tables for bitwise and, or, and xor operations are as follows p q P and q P or q P xor q 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 1 0 0 1 1
  • 28. DECISION MAKING • Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. EXAMPLE IF-ELSE STRUCTURE
  • 30. LISP LOOP • There may be a situation, when you need to execute a block of code numbers of times. A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages. • LISP provides the following types of constructs to handle looping requirements.
  • 32. LISP LOOP CONSTRUC T DESCRIPTION loop The loop construct is the simplest form of iteration provided by LISP. In its simplest form, it allows you to execute some statement(s) repeatedly until it finds a return statement. Loop for The loop for construct allows you to implement a for-loop like iteration as most common in other languages. do The do construct is also used for performing iteration using LISP. It provides a structured form of iteration. dotimes The dotimes construct allows looping for some fixed number of iterations. dolist The dolist construct allows iteration through each element of a list.
  • 33. LISP ARRAY • LISP allows you to define single or multiple-dimension arrays using the make- array function. An array can store any LISP object as its elements. • All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. • In LISP, an array element is specified by a sequence of non-negative integer • indices. The length of the sequence must equal the rank of the array. Indexing starts from zero. • The number of dimensions of an array is called its rank.
  • 35. HOW TO DECLARE AN ARRAY • For example, to create an array with 10- cells, named my-array, we can write: • (setf my-array(make array(10))) • The aref function allows accessing the contents of the cells. It takes two arguments, the name of the array and the index value. • For example, to access the content of the tenth cell, we write: (aref my-array 9)

Editor's Notes

  1. Refers to a software application that runs only on a particular type of computer. Programs that run on a variety of different types of computers are called machine independent.