SlideShare uma empresa Scribd logo
1 de 26
LISP
Lisp Programming Language
LISP
What is LISP?
• A LISt Processing language
– The basic data structure is linked list and Atoms.
• A functional programming language
– Each expression in LISP is a function that returns a value
• An interpretive language
– Running LISP programs involves interacting with the LISP
interpreter.
– Clisp is the common lisp interpreter available only for Linux.
– Recently Compilers have been made for this language but
they are not used a lot.
LISP
History
• First developed by John McCarthy as a language for symbolic
(rather than numeric) computation in 1958 based on Fortran
Syntax
• Very SLOW:
– no compilation of source to machine code
– inefficient garbage collector
• Historical Reason
– Most AI programs in the U.S. have been developed in LISP
– However, most AI programs in Europe have been developed
in PROLOG
LISP
Terminology
•Write a program => Define a set of
functions
•Running a program => Evaluating an
expression
•Simple syntax: operator precedence issues
eliminated
•Lists (or S-expressions) are important:
•Functions are defined as lists
•Lists can be manipulated easily in Lisp
•Functions can be manipulated easily
LISP
Functions
• Lisp is a functional language – So everything is a function
-> Functions in other languages
var sum := sqrt(x)
Print sum
In lisp this function is:
-> (sqrt x)
• Most LISP functions require you to think and use Prefix
Notation – you have to think backwards
– (print (+ 5 (sqrt 6)))
• And there are primary effects and side effects
– In ‘pure’ Lisp, we ONLY get values by executing a function.
– We DON’T set a variable to a new value INSIDE a function….that is a
side effect of executing a function. (You all probably do that all the
time in Java or C++)
LISP
How the Lisp Functions work –
The read-eval loop
• Evaluation process starts with an “S”
expression (i.e., a function and operands to
that function) This one adds two numbers….
(+ 3 4)
Parentheses – Notification to evaluate
Function name – Go get function (in this case ‘+’ is
the add function)
space - separator
operands -- value for function
Parentheses – stop evaluation and return the
answer
LISP
How Lisp Interpreter Works
•Programs are lisp objects (i.e.
functions)
•Evaluation of a lisp object returns a
new object.
•Evaluation is simply a function called
EVAL that maps lisp objects to lisp
objects:
•EVAL: object => object
•we will use the symbol => to
represent evaluation
•The Lisp interpreter is a loop
consisting of:
•read a lisp expression
LISP
Let’s start with the math
functions
• There are many built in arithmetic functions
• You then put these arithmetic functions
together
LISP
Arithmetic Functions
(+ numbers…) -- adding
(- numbers…) -- subtracting
(* numbers…) -- multiplication
(/ numbers…) -- division
(1+ number) – plus 1 (this is hard to read)
(1- number) – minus 1
(abs number) etc…..
(acos number)
LISP
Examples:
LISP
Atoms
• Atoms:
– Number
» examples: 3, 8.9, etc.
– Symbol
» An object written as a sequence of characters
» Symbols are usually manipulated as names that
are “bound” to other lisp objects
• Symbol FOO might be bound to 4.2
LISP
Lists
•Lists :
•Anything with parentheses
around it.
•()
•(a)
•(this is one too)
•(a list of (two) lists)
•(a (very (very (very
(inscrutable) list)))
LISP
A Special Symbol: NIL
• NIL represents an empty list.
• NIL is a terminator of a list.
• A list is usually built by inserting its elements
into NIL in the reverse order .
• NIL can also represent “false''.
• The special symbol representing “true” is T.
LISP
Taking lists apart
• (first <a list>) returns the first element of the
list.
• (rest <a list>) returns the remaining list (i.e.,
everything except the first element).
LISP
Quote
• Quote symbol ‘ is a short hand for the
function called QUOTE.
• (QUOTE <arg>)
• QUOTE is a special function that prevents
LISP from evaluating its argument.
• QUOTE returns the argument literately.
Example: (quote (dummy-fn 2))
==> (DUMMY-FN 2)
LISP
Basic Evaluation Rules
• A number evaluates to itself
• A symbol evaluates to its value.
• A list is evaluated by
– treating the first element as a function
– evaluating each arguments of the function in a left-to-right
order
• An expression preceded by a quote symbol ‘
evaluates to the expression itself.
LISP
Assignment and Binding
• A symbol (or variable) can be assigned a
value (called its binding) using SETQ.
• (SETQ <symbol-name> <anything>)
Example: (SETQ A ‘(A B C)) ==> (A B C)
A evaluates to ==> (A B C)
• Evaluating a symbol that does not have a
value assigned (i.e., no binding) causes error
LISP
All other functions do NOT
change the bindings
• In particular, FIRST and REST are non-
destructive.
> (setq my-friends ‘(Superman Batman Robin) )
(Superman Batman Robin)
> (first (rest my-friends))
Batman
> my-friends
(Superman Batman Robin)
LISP
Defining My-Own Functions
• A function is defined using DEFUN
• (DEFUN <fn-name> (<arg1> ...<argK>)
<exp1> ... <expN> )
• All arguments are passed by value.
• The body of the function may contain any
number of expressions (i.e., function calls).
• The function returns the value returned by the
last expression.
LISP
Defining A Function
(defun square (x)
(times x x) )
(defun add-friend (new-friend friends)
(cons new-friend friends) )
LISP
Predicates – Checking to see if
something is true….
• Functions that return ``true’’ (i.e., T) or
``false’’ (i.e., NIL).
type-testing predicates
• (NULL <item>) returns T if <item> is NIL
(empty list), otherwise NIL.
• (LISTP <item>) returns T if <item> is a list,
otherwise NIL.
• (ATOM <item>) returns T if <item> is an atom
(i.e., a symbol, a number, or NIL).
• (NUMBERP <item>) returns T if <item> is a
number
LISP
Conditional Expression
• COND is an N-branch conditional expression
(COND ( <test1> <exp11> ... <exp1L> )
( <test2> <exp21> ... <exp2M> )
...
( <testK> <expK1> ... <expKN> ) )
• Each test is evaluated sequentially until a test
returns true.
• Expressions following that test will be
executed.
• COND returns the value returned by the last
expression associated with the test.
LISP
Terminates a COND with a T
condition
(defun select-character (enemy)
(cond ( (equal enemy ‘Penguin)
‘Batman)
( (equal enemy ‘Catwoman)
‘J-Bond )
( (equal enemy ‘Black-Knight)
‘(White-Knight King-Arthur ) )
( T ; for all other enemies
‘SuperMan) ; ask Superman for help
)
)
LISP
Using AND, OR in COND
(defun Evaluate-feeling ( sentence )
(cond ( (OR (member ‘hate sentence)
(member ‘dislike sentence))
‘hatred)
( (AND (member ‘I sentence)
(member ‘feel sentence) )
‘self-centered )
( T
‘happy)
) ; end of cond
) ; end of defun
LISP
Loops
i=1, while i <= 3:
=> (loop for i in ‘(1 2 3) do (print i))
1 2 3
i=1, while i <= 3: (different step)
=> (loop for i from 1.0 to 3.0 by 0.5 do
(print i))
i=3, while i >= 1:
=> (loop for i from 3 downto 1 do (print i))
3
2
1
LISP
Conclusion
Things to remember:
•Lisp is considered the mother of a lot of
functional languages like Scheme and Haskell …..
•Common Lisp has dynamic type checking
•Lisp is interpreted.
The reason why Lisp is dead:
•Stock hardware platforms becoming faster than
special purpose hardware
•Low Interoperability with other languages

Mais conteúdo relacionado

Mais procurados

Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generationAkshaya Arunan
 
List Data Structure
List Data StructureList Data Structure
List Data StructureZidny Nafan
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal languageRabia Khalid
 
exception handling in java.ppt
exception handling in java.pptexception handling in java.ppt
exception handling in java.pptVarshini62
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of AutomataFarooq Mian
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISPNilt1234
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRRiazul Islam
 
Advanced SQL - Database Access from Programming Languages
Advanced SQL - Database Access  from Programming LanguagesAdvanced SQL - Database Access  from Programming Languages
Advanced SQL - Database Access from Programming LanguagesS.Shayan Daneshvar
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsingkunj desai
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryTsegazeab Asgedom
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Animesh Chaturvedi
 
Stl Containers
Stl ContainersStl Containers
Stl Containersppd1961
 

Mais procurados (20)

Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
 
Theory of automata and formal language
Theory of automata and formal languageTheory of automata and formal language
Theory of automata and formal language
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
exception handling in java.ppt
exception handling in java.pptexception handling in java.ppt
exception handling in java.ppt
 
Theory of Automata
Theory of AutomataTheory of Automata
Theory of Automata
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
 
Compiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLRCompiler Design LR parsing SLR ,LALR CLR
Compiler Design LR parsing SLR ,LALR CLR
 
Advanced SQL - Database Access from Programming Languages
Advanced SQL - Database Access  from Programming LanguagesAdvanced SQL - Database Access  from Programming Languages
Advanced SQL - Database Access from Programming Languages
 
Pda to cfg h2
Pda to cfg h2Pda to cfg h2
Pda to cfg h2
 
Nested Queries-SQL.ppt
Nested Queries-SQL.pptNested Queries-SQL.ppt
Nested Queries-SQL.ppt
 
Bottom - Up Parsing
Bottom - Up ParsingBottom - Up Parsing
Bottom - Up Parsing
 
Chapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata TheoryChapter1 Formal Language and Automata Theory
Chapter1 Formal Language and Automata Theory
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Stl Containers
Stl ContainersStl Containers
Stl Containers
 

Destaque

Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISPDevnology
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lispkyleburton
 
Gentle Introduction To Lisp
Gentle Introduction To LispGentle Introduction To Lisp
Gentle Introduction To LispDamien Garaud
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp languageDavid Gu
 
LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)wahab khan
 
Redesigning Common Lisp
Redesigning Common LispRedesigning Common Lisp
Redesigning Common Lispfukamachi
 
Digital image processing
Digital image processingDigital image processing
Digital image processingDeevena Dayaal
 
Image processing1 introduction
Image processing1 introductionImage processing1 introduction
Image processing1 introductionPreeti Gupta
 
Digital Image Processing: An Introduction
Digital Image Processing: An IntroductionDigital Image Processing: An Introduction
Digital Image Processing: An IntroductionMostafa G. M. Mostafa
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image ProcessingReshma KC
 
Expert systems
Expert systemsExpert systems
Expert systemsJithin Zcs
 
Digital image processing
Digital image processingDigital image processing
Digital image processingAvisek Roy
 
Application of expert system
Application of expert systemApplication of expert system
Application of expert systemDinkar DP
 
Introduction and architecture of expert system
Introduction  and architecture of expert systemIntroduction  and architecture of expert system
Introduction and architecture of expert systempremdeshmane
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNoel Malle
 

Destaque (20)

Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
 
Gentle Introduction To Lisp
Gentle Introduction To LispGentle Introduction To Lisp
Gentle Introduction To Lisp
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp language
 
Prolog & lisp
Prolog & lispProlog & lisp
Prolog & lisp
 
LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)
 
Redesigning Common Lisp
Redesigning Common LispRedesigning Common Lisp
Redesigning Common Lisp
 
Digital image processing
Digital image processingDigital image processing
Digital image processing
 
Image processing1 introduction
Image processing1 introductionImage processing1 introduction
Image processing1 introduction
 
Digital Image Processing: An Introduction
Digital Image Processing: An IntroductionDigital Image Processing: An Introduction
Digital Image Processing: An Introduction
 
Why Haskell
Why HaskellWhy Haskell
Why Haskell
 
Digital Image Processing
Digital Image ProcessingDigital Image Processing
Digital Image Processing
 
Expert systems
Expert systemsExpert systems
Expert systems
 
Digital image processing
Digital image processingDigital image processing
Digital image processing
 
History of programming
History of programmingHistory of programming
History of programming
 
Application of expert system
Application of expert systemApplication of expert system
Application of expert system
 
Introduction and architecture of expert system
Introduction  and architecture of expert systemIntroduction  and architecture of expert system
Introduction and architecture of expert system
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
LISP:Program structure in lisp
LISP:Program structure in lispLISP:Program structure in lisp
LISP:Program structure in lisp
 
LISP:Control Structures In Lisp
LISP:Control Structures In LispLISP:Control Structures In Lisp
LISP:Control Structures In Lisp
 

Semelhante a Lisp Programming Languge

AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxprakashvs7
 
AI Programming language (LISP)
AI Programming language (LISP)AI Programming language (LISP)
AI Programming language (LISP)SURBHI SAROHA
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHISowmya Jyothi
 
Lisp, An Introduction.ppt
Lisp, An Introduction.pptLisp, An Introduction.ppt
Lisp, An Introduction.pptLuis Soza
 
Introduction to lambda calculus
Introduction to lambda calculusIntroduction to lambda calculus
Introduction to lambda calculusAfaq Siddiqui
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) wahab khan
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To LispLISP Content
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and FuturePushkar Kulkarni
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present FutureIndicThreads
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonchanna basava
 
Parts of python programming language
Parts of python programming languageParts of python programming language
Parts of python programming languageMegha V
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxchandankumar364348
 
Python list manipulation basics in detail.pdf
Python list  manipulation basics in detail.pdfPython list  manipulation basics in detail.pdf
Python list manipulation basics in detail.pdfneonaveen
 

Semelhante a Lisp Programming Languge (20)

Lisp and scheme i
Lisp and scheme iLisp and scheme i
Lisp and scheme i
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
 
AI Programming language (LISP)
AI Programming language (LISP)AI Programming language (LISP)
AI Programming language (LISP)
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
 
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
 
Introduction to lambda calculus
Introduction to lambda calculusIntroduction to lambda calculus
Introduction to lambda calculus
 
(Ai lisp)
(Ai lisp)(Ai lisp)
(Ai lisp)
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence)
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 
Lisp
LispLisp
Lisp
 
Functional Programming - Past, Present and Future
Functional Programming - Past, Present and FutureFunctional Programming - Past, Present and Future
Functional Programming - Past, Present and Future
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
 
parsing.pptx
parsing.pptxparsing.pptx
parsing.pptx
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
Parts of python programming language
Parts of python programming languageParts of python programming language
Parts of python programming language
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
 
Python list manipulation basics in detail.pdf
Python list  manipulation basics in detail.pdfPython list  manipulation basics in detail.pdf
Python list manipulation basics in detail.pdf
 

Último

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Lisp Programming Languge

  • 2. LISP What is LISP? • A LISt Processing language – The basic data structure is linked list and Atoms. • A functional programming language – Each expression in LISP is a function that returns a value • An interpretive language – Running LISP programs involves interacting with the LISP interpreter. – Clisp is the common lisp interpreter available only for Linux. – Recently Compilers have been made for this language but they are not used a lot.
  • 3. LISP History • First developed by John McCarthy as a language for symbolic (rather than numeric) computation in 1958 based on Fortran Syntax • Very SLOW: – no compilation of source to machine code – inefficient garbage collector • Historical Reason – Most AI programs in the U.S. have been developed in LISP – However, most AI programs in Europe have been developed in PROLOG
  • 4. LISP Terminology •Write a program => Define a set of functions •Running a program => Evaluating an expression •Simple syntax: operator precedence issues eliminated •Lists (or S-expressions) are important: •Functions are defined as lists •Lists can be manipulated easily in Lisp •Functions can be manipulated easily
  • 5. LISP Functions • Lisp is a functional language – So everything is a function -> Functions in other languages var sum := sqrt(x) Print sum In lisp this function is: -> (sqrt x) • Most LISP functions require you to think and use Prefix Notation – you have to think backwards – (print (+ 5 (sqrt 6))) • And there are primary effects and side effects – In ‘pure’ Lisp, we ONLY get values by executing a function. – We DON’T set a variable to a new value INSIDE a function….that is a side effect of executing a function. (You all probably do that all the time in Java or C++)
  • 6. LISP How the Lisp Functions work – The read-eval loop • Evaluation process starts with an “S” expression (i.e., a function and operands to that function) This one adds two numbers…. (+ 3 4) Parentheses – Notification to evaluate Function name – Go get function (in this case ‘+’ is the add function) space - separator operands -- value for function Parentheses – stop evaluation and return the answer
  • 7. LISP How Lisp Interpreter Works •Programs are lisp objects (i.e. functions) •Evaluation of a lisp object returns a new object. •Evaluation is simply a function called EVAL that maps lisp objects to lisp objects: •EVAL: object => object •we will use the symbol => to represent evaluation •The Lisp interpreter is a loop consisting of: •read a lisp expression
  • 8. LISP Let’s start with the math functions • There are many built in arithmetic functions • You then put these arithmetic functions together
  • 9. LISP Arithmetic Functions (+ numbers…) -- adding (- numbers…) -- subtracting (* numbers…) -- multiplication (/ numbers…) -- division (1+ number) – plus 1 (this is hard to read) (1- number) – minus 1 (abs number) etc….. (acos number)
  • 11. LISP Atoms • Atoms: – Number » examples: 3, 8.9, etc. – Symbol » An object written as a sequence of characters » Symbols are usually manipulated as names that are “bound” to other lisp objects • Symbol FOO might be bound to 4.2
  • 12. LISP Lists •Lists : •Anything with parentheses around it. •() •(a) •(this is one too) •(a list of (two) lists) •(a (very (very (very (inscrutable) list)))
  • 13. LISP A Special Symbol: NIL • NIL represents an empty list. • NIL is a terminator of a list. • A list is usually built by inserting its elements into NIL in the reverse order . • NIL can also represent “false''. • The special symbol representing “true” is T.
  • 14. LISP Taking lists apart • (first <a list>) returns the first element of the list. • (rest <a list>) returns the remaining list (i.e., everything except the first element).
  • 15. LISP Quote • Quote symbol ‘ is a short hand for the function called QUOTE. • (QUOTE <arg>) • QUOTE is a special function that prevents LISP from evaluating its argument. • QUOTE returns the argument literately. Example: (quote (dummy-fn 2)) ==> (DUMMY-FN 2)
  • 16. LISP Basic Evaluation Rules • A number evaluates to itself • A symbol evaluates to its value. • A list is evaluated by – treating the first element as a function – evaluating each arguments of the function in a left-to-right order • An expression preceded by a quote symbol ‘ evaluates to the expression itself.
  • 17. LISP Assignment and Binding • A symbol (or variable) can be assigned a value (called its binding) using SETQ. • (SETQ <symbol-name> <anything>) Example: (SETQ A ‘(A B C)) ==> (A B C) A evaluates to ==> (A B C) • Evaluating a symbol that does not have a value assigned (i.e., no binding) causes error
  • 18. LISP All other functions do NOT change the bindings • In particular, FIRST and REST are non- destructive. > (setq my-friends ‘(Superman Batman Robin) ) (Superman Batman Robin) > (first (rest my-friends)) Batman > my-friends (Superman Batman Robin)
  • 19. LISP Defining My-Own Functions • A function is defined using DEFUN • (DEFUN <fn-name> (<arg1> ...<argK>) <exp1> ... <expN> ) • All arguments are passed by value. • The body of the function may contain any number of expressions (i.e., function calls). • The function returns the value returned by the last expression.
  • 20. LISP Defining A Function (defun square (x) (times x x) ) (defun add-friend (new-friend friends) (cons new-friend friends) )
  • 21. LISP Predicates – Checking to see if something is true…. • Functions that return ``true’’ (i.e., T) or ``false’’ (i.e., NIL). type-testing predicates • (NULL <item>) returns T if <item> is NIL (empty list), otherwise NIL. • (LISTP <item>) returns T if <item> is a list, otherwise NIL. • (ATOM <item>) returns T if <item> is an atom (i.e., a symbol, a number, or NIL). • (NUMBERP <item>) returns T if <item> is a number
  • 22. LISP Conditional Expression • COND is an N-branch conditional expression (COND ( <test1> <exp11> ... <exp1L> ) ( <test2> <exp21> ... <exp2M> ) ... ( <testK> <expK1> ... <expKN> ) ) • Each test is evaluated sequentially until a test returns true. • Expressions following that test will be executed. • COND returns the value returned by the last expression associated with the test.
  • 23. LISP Terminates a COND with a T condition (defun select-character (enemy) (cond ( (equal enemy ‘Penguin) ‘Batman) ( (equal enemy ‘Catwoman) ‘J-Bond ) ( (equal enemy ‘Black-Knight) ‘(White-Knight King-Arthur ) ) ( T ; for all other enemies ‘SuperMan) ; ask Superman for help ) )
  • 24. LISP Using AND, OR in COND (defun Evaluate-feeling ( sentence ) (cond ( (OR (member ‘hate sentence) (member ‘dislike sentence)) ‘hatred) ( (AND (member ‘I sentence) (member ‘feel sentence) ) ‘self-centered ) ( T ‘happy) ) ; end of cond ) ; end of defun
  • 25. LISP Loops i=1, while i <= 3: => (loop for i in ‘(1 2 3) do (print i)) 1 2 3 i=1, while i <= 3: (different step) => (loop for i from 1.0 to 3.0 by 0.5 do (print i)) i=3, while i >= 1: => (loop for i from 3 downto 1 do (print i)) 3 2 1
  • 26. LISP Conclusion Things to remember: •Lisp is considered the mother of a lot of functional languages like Scheme and Haskell ….. •Common Lisp has dynamic type checking •Lisp is interpreted. The reason why Lisp is dead: •Stock hardware platforms becoming faster than special purpose hardware •Low Interoperability with other languages

Notas do Editor

  1. Prefix notation – as opposed to infix a= 3 + 4)
  2. T and nil are reserved words for atoms