SlideShare una empresa de Scribd logo
1 de 17
CS552
Artificial Intelligence-
LISP (Programming Language)
BSCS-5th Semester-2020
Prepared By:
Mr. Rahat Ullah
r2mpak@gmail.com
Department Of
Computer Science
Government Degree
College Gulabad Dir (L)
KPK Pakistan
What is LISP?
 Lisp (historically LISP) is a family of programming languages.
 Lisp is an acronym for List Processing
 John McCarthy invented LISP in 1958, shortly after the development of
FORTRAN.
 It was first implemented by Steve Russell on an IBM 704 Computer.
 It is a language which is fully parenthesized, prefix notation
 Lisp is the second-oldest high-level programming language in widespread use
today.
 Today, the best-known general-purpose Lisp dialects are Racket, Common
Lisp, Scheme and Clojure
 As one of the earliest programming languages, Lisp pioneered many ideas
in computer science, including tree data structures, automatic storage
management, dynamic typing, conditionals, higher-order
functions, recursion, the self-hosting compiler, and the read–eval–print loop
 A function call or syntactic form is written as a list with the function or operator's
name first, and the arguments following; for instance, a function f that takes three
arguments would be called as (f arg1 arg2 arg3).
What is Common LISP?
 Common Lisp originated, during the 1980s and 1990s, in an attempt to unify the
work of several implementation groups that were successors to Maclisp, like
ZetaLisp and NIL (New implementation Implementation of Lisp) etc.
 It serves as a common language, which can be easily extended for specific
implementation.
 Programs written in Common LISP do not depend on machine-specific
characteristics, such as Programs written in Common LISP do not depend on
machine-specific characteristics, such as word length etc.
Features of Common LISP?
 It is machine-independent
 It uses iterative design methodology, and easy extensibility.
 It allows updating the programs dynamically.
 It provides high level debugging.
 It provides advanced object-oriented programming.
 It provides a convenient macro system.
 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 a complete I/O library.
 It provides extensive control structures
Applications built in LISP?
 Large successful applications built in LISP.
1. Emacs
2. G2
3. AutoCad
4. Igor Engraver
5. Yahoo Store
LISP environment Setup?
 If you are still willing to set up your environment for Lisp programming language,
you need the following two softwares available on your computer
1. 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.
• 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"
LISP environment Setup…
2. The Lisp Executer
• 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.
• CLISP is the GNU Common LISP multi-architechtural compiler used for
setting up LISP in Windows. The windows version emulates a unix
environment using MingW under windows.
• Installer takes care of this and automatically adds clisp to the windows
PATH variable.
• You can get the latest CLISP for Windows from here
https://sourceforge.net/projects/clisp/files/latest/download
LISP environment Setup…
LISP-Program Structure
 LISP expressions are called symbolic expressions or s-expressions.
 The s-expressions are composed of three valid objects, atoms, lists and
strings.
 Any s-expression is a valid program.
 LISP programs run either on an interpreter or as compiled code.
 The interpreter checks the source code in a repeated loop, which is also
called the read-evaluate-print loop (REPL).
 It reads the program code, evaluates it, and prints the values returned by the
program
LISP-Program Structure
 LISP expressions are called symbolic expressions or s-expressions.
 The s-expressions are composed of three valid objects, atoms, lists and
strings.
 Any s-expression is a valid program.
 LISP programs run either on an interpreter or as compiled code.
 The interpreter checks the source code in a repeated loop, which is also
called the read-evaluate-print loop (REPL).
 It reads the program code, evaluates it, and prints the values returned by the
program
LISP-Basic Building Blocks
 LISP programs are made up of three basic building blocks −
1. Atom
An atom is a number or string of contiguous characters. It includes
numbers and special characters. Following are examples of some valid
atoms: name, 12300888, *hello*, ABC#123, hello-rahat123
2. List
A list is a sequence of atoms and/or other lists enclosed in parentheses.
Following are examples of some valid lists −
( i am a list i am a list) , (a a ( a b c a b c) d e fgh d e fgh) ,
(father tom father tom ( susan bill joe susan bill joe)) ))
( )
LISP-Basic Building Blocks
3. String
A string is a group of characters enclosed in double quotation marks.
Following are examples of some valid strings
" I am a string" , "a ba c d efg #$%^&!“ , "Please enter your text here:"
"Hello from RK'! “
Adding Comments:
The semicolon symbol (;) is used for indicating a comment line. For
Example,
(write-line "Hello World" "Hello World") ; greet the world
; tell them your whereabouts
(write-line "I am at ‘CS-5th semester'! Learning LISP")
LISP-The “Hello World” Program
Create new source code file named Exaple.lisp and type the following code in it.
(write-line "Hello World")
(write-line "I am at ‘CS-5th Semester'! Learning LISP")
When you click the Execute button, or type Ctrl+E, LISP executes it immediately
and the result returned is
Hello World
I am at ‘CS-5th Semester'! Learning LISP
LISP-Some Notable Points
Following are some of the important points to note
 The basic numeric operations in LISP are +, -, *, and /
 LISP represents a function call f(x) as (f x), for example cos(45) is written as
cos 45
 LISP expressions are case-insensitive, cos 45 or COS 45 are same.
 LISP tries to evaluate everything, including the arguments of a function. Only
three types of elements are constants and always return their own value
a) Numbers
b) The letter t, that stands for logical true.
c) The value nil, that stands for logical false, as well as an empty list.
LISP-A Simple Program
Let us write an s-expression to find the sum of three numbers 7, 9 and 11. To do
this, we can type at the interpreter prompt
(+ 7 9 11 11)
LISP returns the resul
27
If you would like to run the same program as a compiled code, then create a LISP
source code file named myprog.lisp and type the following code in it.
(write write (+ (+ 7 9 11 11))
When you click the Execute button, or type Ctrl+E, LISP executes it immediately
and the result When returned is
27
LISP-Prefix Notation
 You might have noted that LISP uses prefix notation.
 In the above program the + symbol works as the function name for the process of
summation of the numbers.
 In prefix notation, operators are written before their operands. For example, the
expression,
a * ( b + c ) / d will be written as (/ (* a (+ b c)) d)
 Let us take another example, let us write code for converting Fahrenheit temp of
60F to the centigrade scale
The mathematical expression for this conversion will be (60 * 9 / 5) + 32
 Create a source code file named temp.lisp and type the following code in it.
(write(+ (* (/ 9 5)60) 32)) by executing the file you will get the result as 140
Department Of Computer Science
Government Degree College Gulabad Dir (L)
KPK Pakistan | r2mpak@gmail.com
Thanks for the
Attention!

Más contenido relacionado

La actualidad más candente

Code generation errors and recovery
Code generation errors and recoveryCode generation errors and recovery
Code generation errors and recoveryMomina Idrees
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compileradilmehmood93
 
Workshop presentation hands on r programming
Workshop presentation hands on r programmingWorkshop presentation hands on r programming
Workshop presentation hands on r programmingNimrita Koul
 
Lex and Yacc ppt
Lex and Yacc pptLex and Yacc ppt
Lex and Yacc pptpssraikar
 
Compiler Design File
Compiler Design FileCompiler Design File
Compiler Design FileArchita Misra
 
Flex (fast lexical analyzer generator )
Flex (fast lexical analyzer generator )Flex (fast lexical analyzer generator )
Flex (fast lexical analyzer generator )Sandip Basnet
 
7 compiler lab
7 compiler lab 7 compiler lab
7 compiler lab MashaelQ
 
A SUCCINCT PROGRAMMING LANGUAGE WITH A NATIVE DATABASE COMPONENT
A SUCCINCT PROGRAMMING LANGUAGE WITH A NATIVE DATABASE COMPONENTA SUCCINCT PROGRAMMING LANGUAGE WITH A NATIVE DATABASE COMPONENT
A SUCCINCT PROGRAMMING LANGUAGE WITH A NATIVE DATABASE COMPONENTijpla
 
Simplified instructional computer
Simplified instructional computerSimplified instructional computer
Simplified instructional computerKirby Fabro
 
File handling With Solve Programs
File handling With Solve ProgramsFile handling With Solve Programs
File handling With Solve ProgramsRohan Gajre
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)omercomail
 
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...Bhavin Darji
 

La actualidad más candente (20)

Code generation errors and recovery
Code generation errors and recoveryCode generation errors and recovery
Code generation errors and recovery
 
Lexyacc
LexyaccLexyacc
Lexyacc
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
 
Workshop presentation hands on r programming
Workshop presentation hands on r programmingWorkshop presentation hands on r programming
Workshop presentation hands on r programming
 
Lex and Yacc ppt
Lex and Yacc pptLex and Yacc ppt
Lex and Yacc ppt
 
R Course Online
R Course OnlineR Course Online
R Course Online
 
Compiler Design File
Compiler Design FileCompiler Design File
Compiler Design File
 
Flex (fast lexical analyzer generator )
Flex (fast lexical analyzer generator )Flex (fast lexical analyzer generator )
Flex (fast lexical analyzer generator )
 
7 compiler lab
7 compiler lab 7 compiler lab
7 compiler lab
 
Data Mining with R programming
Data Mining with R programmingData Mining with R programming
Data Mining with R programming
 
A SUCCINCT PROGRAMMING LANGUAGE WITH A NATIVE DATABASE COMPONENT
A SUCCINCT PROGRAMMING LANGUAGE WITH A NATIVE DATABASE COMPONENTA SUCCINCT PROGRAMMING LANGUAGE WITH A NATIVE DATABASE COMPONENT
A SUCCINCT PROGRAMMING LANGUAGE WITH A NATIVE DATABASE COMPONENT
 
Simplified instructional computer
Simplified instructional computerSimplified instructional computer
Simplified instructional computer
 
File handling With Solve Programs
File handling With Solve ProgramsFile handling With Solve Programs
File handling With Solve Programs
 
lect 5
lect 5lect 5
lect 5
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)
 
Intro to php
Intro to phpIntro to php
Intro to php
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
 
Unit 1 cd
Unit 1 cdUnit 1 cd
Unit 1 cd
 
Compiler Design Tutorial
Compiler Design Tutorial Compiler Design Tutorial
Compiler Design Tutorial
 
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
Overview of Language Processor : Fundamentals of LP , Symbol Table , Data Str...
 

Similar a 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).pptxprakashvs7
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To LispLISP Content
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp languageDavid Gu
 
Let's LISP like it's 1959
Let's LISP like it's 1959Let's LISP like it's 1959
Let's LISP like it's 1959Mohamed Essam
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийSigma Software
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_pythongunanandJha2
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptMohitChaudhary637683
 
Chapter One
Chapter OneChapter One
Chapter Onebolovv
 
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
Compiler Engineering Lab#5 : Symbol Table, Flex ToolCompiler Engineering Lab#5 : Symbol Table, Flex Tool
Compiler Engineering Lab#5 : Symbol Table, Flex ToolMashaelQ
 
Lisp, An Introduction.ppt
Lisp, An Introduction.pptLisp, An Introduction.ppt
Lisp, An Introduction.pptLuis Soza
 
Programing paradigm & implementation
Programing paradigm & implementationPrograming paradigm & implementation
Programing paradigm & implementationBilal Maqbool ツ
 

Similar a Lecture 2 lisp-Overview (20)

AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
 
Lisp
LispLisp
Lisp
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 
LISP.ppt
LISP.pptLISP.ppt
LISP.ppt
 
Lisp
LispLisp
Lisp
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp language
 
Presentation1
Presentation1Presentation1
Presentation1
 
Let's LISP like it's 1959
Let's LISP like it's 1959Let's LISP like it's 1959
Let's LISP like it's 1959
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_python
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.ppt
 
Lisp and scheme i
Lisp and scheme iLisp and scheme i
Lisp and scheme i
 
Chapter One
Chapter OneChapter One
Chapter One
 
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
Compiler Engineering Lab#5 : Symbol Table, Flex ToolCompiler Engineering Lab#5 : Symbol Table, Flex Tool
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
 
intro.ppt
intro.pptintro.ppt
intro.ppt
 
intro.ppt
intro.pptintro.ppt
intro.ppt
 
Lisp, An Introduction.ppt
Lisp, An Introduction.pptLisp, An Introduction.ppt
Lisp, An Introduction.ppt
 
Ch1 (1).ppt
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).ppt
 
Programing paradigm & implementation
Programing paradigm & implementationPrograming paradigm & implementation
Programing paradigm & implementation
 

Más de Student at University Of Malakand, Pakistan (6)

Lecture 4 system programming-data representation
Lecture 4  system programming-data representationLecture 4  system programming-data representation
Lecture 4 system programming-data representation
 
Lecture 4 means end analysis
Lecture 4 means end analysisLecture 4 means end analysis
Lecture 4 means end analysis
 
Lecture 3 general problem solver
Lecture 3 general problem solverLecture 3 general problem solver
Lecture 3 general problem solver
 
Lecture 1- Artificial Intelligence - Introduction
Lecture 1- Artificial Intelligence - IntroductionLecture 1- Artificial Intelligence - Introduction
Lecture 1- Artificial Intelligence - Introduction
 
waspmote Presentation
waspmote Presentationwaspmote Presentation
waspmote Presentation
 
Presentation No.1
Presentation No.1Presentation No.1
Presentation No.1
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Último (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Lecture 2 lisp-Overview

  • 1. CS552 Artificial Intelligence- LISP (Programming Language) BSCS-5th Semester-2020 Prepared By: Mr. Rahat Ullah r2mpak@gmail.com Department Of Computer Science Government Degree College Gulabad Dir (L) KPK Pakistan
  • 2. What is LISP?  Lisp (historically LISP) is a family of programming languages.  Lisp is an acronym for List Processing  John McCarthy invented LISP in 1958, shortly after the development of FORTRAN.  It was first implemented by Steve Russell on an IBM 704 Computer.  It is a language which is fully parenthesized, prefix notation  Lisp is the second-oldest high-level programming language in widespread use today.  Today, the best-known general-purpose Lisp dialects are Racket, Common Lisp, Scheme and Clojure  As one of the earliest programming languages, Lisp pioneered many ideas in computer science, including tree data structures, automatic storage management, dynamic typing, conditionals, higher-order functions, recursion, the self-hosting compiler, and the read–eval–print loop  A function call or syntactic form is written as a list with the function or operator's name first, and the arguments following; for instance, a function f that takes three arguments would be called as (f arg1 arg2 arg3).
  • 3. What is Common LISP?  Common Lisp originated, during the 1980s and 1990s, in an attempt to unify the work of several implementation groups that were successors to Maclisp, like ZetaLisp and NIL (New implementation Implementation of Lisp) etc.  It serves as a common language, which can be easily extended for specific implementation.  Programs written in Common LISP do not depend on machine-specific characteristics, such as Programs written in Common LISP do not depend on machine-specific characteristics, such as word length etc.
  • 4. Features of Common LISP?  It is machine-independent  It uses iterative design methodology, and easy extensibility.  It allows updating the programs dynamically.  It provides high level debugging.  It provides advanced object-oriented programming.  It provides a convenient macro system.  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 a complete I/O library.  It provides extensive control structures
  • 5. Applications built in LISP?  Large successful applications built in LISP. 1. Emacs 2. G2 3. AutoCad 4. Igor Engraver 5. Yahoo Store
  • 6. LISP environment Setup?  If you are still willing to set up your environment for Lisp programming language, you need the following two softwares available on your computer 1. 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. • 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"
  • 7. LISP environment Setup… 2. The Lisp Executer • 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. • CLISP is the GNU Common LISP multi-architechtural compiler used for setting up LISP in Windows. The windows version emulates a unix environment using MingW under windows. • Installer takes care of this and automatically adds clisp to the windows PATH variable. • You can get the latest CLISP for Windows from here https://sourceforge.net/projects/clisp/files/latest/download
  • 9. LISP-Program Structure  LISP expressions are called symbolic expressions or s-expressions.  The s-expressions are composed of three valid objects, atoms, lists and strings.  Any s-expression is a valid program.  LISP programs run either on an interpreter or as compiled code.  The interpreter checks the source code in a repeated loop, which is also called the read-evaluate-print loop (REPL).  It reads the program code, evaluates it, and prints the values returned by the program
  • 10. LISP-Program Structure  LISP expressions are called symbolic expressions or s-expressions.  The s-expressions are composed of three valid objects, atoms, lists and strings.  Any s-expression is a valid program.  LISP programs run either on an interpreter or as compiled code.  The interpreter checks the source code in a repeated loop, which is also called the read-evaluate-print loop (REPL).  It reads the program code, evaluates it, and prints the values returned by the program
  • 11. LISP-Basic Building Blocks  LISP programs are made up of three basic building blocks − 1. Atom An atom is a number or string of contiguous characters. It includes numbers and special characters. Following are examples of some valid atoms: name, 12300888, *hello*, ABC#123, hello-rahat123 2. List A list is a sequence of atoms and/or other lists enclosed in parentheses. Following are examples of some valid lists − ( i am a list i am a list) , (a a ( a b c a b c) d e fgh d e fgh) , (father tom father tom ( susan bill joe susan bill joe)) )) ( )
  • 12. LISP-Basic Building Blocks 3. String A string is a group of characters enclosed in double quotation marks. Following are examples of some valid strings " I am a string" , "a ba c d efg #$%^&!“ , "Please enter your text here:" "Hello from RK'! “ Adding Comments: The semicolon symbol (;) is used for indicating a comment line. For Example, (write-line "Hello World" "Hello World") ; greet the world ; tell them your whereabouts (write-line "I am at ‘CS-5th semester'! Learning LISP")
  • 13. LISP-The “Hello World” Program Create new source code file named Exaple.lisp and type the following code in it. (write-line "Hello World") (write-line "I am at ‘CS-5th Semester'! Learning LISP") When you click the Execute button, or type Ctrl+E, LISP executes it immediately and the result returned is Hello World I am at ‘CS-5th Semester'! Learning LISP
  • 14. LISP-Some Notable Points Following are some of the important points to note  The basic numeric operations in LISP are +, -, *, and /  LISP represents a function call f(x) as (f x), for example cos(45) is written as cos 45  LISP expressions are case-insensitive, cos 45 or COS 45 are same.  LISP tries to evaluate everything, including the arguments of a function. Only three types of elements are constants and always return their own value a) Numbers b) The letter t, that stands for logical true. c) The value nil, that stands for logical false, as well as an empty list.
  • 15. LISP-A Simple Program Let us write an s-expression to find the sum of three numbers 7, 9 and 11. To do this, we can type at the interpreter prompt (+ 7 9 11 11) LISP returns the resul 27 If you would like to run the same program as a compiled code, then create a LISP source code file named myprog.lisp and type the following code in it. (write write (+ (+ 7 9 11 11)) When you click the Execute button, or type Ctrl+E, LISP executes it immediately and the result When returned is 27
  • 16. LISP-Prefix Notation  You might have noted that LISP uses prefix notation.  In the above program the + symbol works as the function name for the process of summation of the numbers.  In prefix notation, operators are written before their operands. For example, the expression, a * ( b + c ) / d will be written as (/ (* a (+ b c)) d)  Let us take another example, let us write code for converting Fahrenheit temp of 60F to the centigrade scale The mathematical expression for this conversion will be (60 * 9 / 5) + 32  Create a source code file named temp.lisp and type the following code in it. (write(+ (* (/ 9 5)60) 32)) by executing the file you will get the result as 140
  • 17. Department Of Computer Science Government Degree College Gulabad Dir (L) KPK Pakistan | r2mpak@gmail.com Thanks for the Attention!