SlideShare a Scribd company logo
3
Why LISP
The Key motivations behind Learning LISP are as follow:-
● Some of the features of Scala are inherited from LISP.
● Scala is Hybrid Programming Language. It consist features of both
Functional and Object Oriented Programming Language.
● We most of us know the Object Oriented programming Language like JAVA,
C++ etc.
● Undersanding the Basics of LISP can help us understand the other
functional programming languages like clojure.
Most read
4
What is LISP
● LISP, an acronym for list processing, is a programming language that was
designed for easy manipulation of data strings.
● Developed in 1959 by John McCarthy,
● It is a commonly used language for artificial intelligence (AI) programming.
● It is one of the oldest programming languages still in relatively wide use.
● All program code is written as s-expressions, or parenthesized lists.
Most read
8
Expression Evaluation in LISP
Expressions representing numbers may be combined with an expression representing a
primitive procedure (such as + or *) to form a compound expression that represents the
application of the procedure to those numbers. For example:-
(+ 137 349)
486
(- 1000 334)
666
(* 5 99)
495
(/ 10 5)
2
Most read
Introduction to Programming in
LISP
...
Akash Sethi
Software Consultant
Knoldus Software LLP.
Agenda
● Why LISP
● What is LISP
● Timeline of Lisp dialects
● Fundamentals of LISP
● Expression Evaluation in LISP
● Defining Variables
● Evaluating Combinations
● Procedure Definitions
● The Substitution Model for Procedure Application
● Conditional Expressions
● Linear Recursion and Iteration
Why LISP
The Key motivations behind Learning LISP are as follow:-
● Some of the features of Scala are inherited from LISP.
● Scala is Hybrid Programming Language. It consist features of both
Functional and Object Oriented Programming Language.
● We most of us know the Object Oriented programming Language like JAVA,
C++ etc.
● Undersanding the Basics of LISP can help us understand the other
functional programming languages like clojure.
What is LISP
● LISP, an acronym for list processing, is a programming language that was
designed for easy manipulation of data strings.
● Developed in 1959 by John McCarthy,
● It is a commonly used language for artificial intelligence (AI) programming.
● It is one of the oldest programming languages still in relatively wide use.
● All program code is written as s-expressions, or parenthesized lists.
Timeline of Lisp dialects
What is LISP
● LISP, an acronym for list processing, is a programming language that was
designed for easy manipulation of data strings.
● Developed in 1959 by John McCarthy,
● It is a commonly used language for artificial intelligence (AI) programming.
● It is one of the oldest programming languages still in relatively wide use.
● All program code is written as s-expressions, or parenthesized lists.
Fundamentals of LISP
Every powerful language has three mechanisms for accomplishing this :-
● Primitive expressions, which represent the simplest entities the language
is concerned with,
● Means of combination, by which compound elements are built from
simpler ones, and
● Means of abstraction, by which compound elements can be named and
manipulated as units.
Expression Evaluation in LISP
Expressions representing numbers may be combined with an expression representing a
primitive procedure (such as + or *) to form a compound expression that represents the
application of the procedure to those numbers. For example:-
(+ 137 349)
486
(- 1000 334)
666
(* 5 99)
495
(/ 10 5)
2
Expression Evaluation in LISP
Expressions such as these, formed by delimiting a list of expressions within
parentheses in order to denote procedure application, are called combinations.
● The leftmost element in the list is called the operator, and the other elements are
called operands.
● The value of a combination is obtained by applying the procedure specified by the
operator to the arguments that are the values of the operands.
● The convention of placing the operator to the left of the operands is known as
prefix notation.
● No ambiguity can arise, because the operator is always the leftmost element and
the entire combination is delimited by the parentheses.
Defining Variables
Define is LISP language's simplest means of abstraction, for it allows us to
use simple names to refer to the results of compound operation.
(define pi 3.14159)
(define radius 10)
(* pi (* radius radius))
314.159
(define circumference (* 2 pi radius))
Circumference
62.8318
Evaluating Combinations
To evaluate a combination, do the following:
● 1. Evaluate the subexpressions of the combination.
● 2. Apply the procedure that is the
value of the leftmost subexpression
(the operator) to the arguments
that are the values of the other
subexpressions (the operands).
(* (+ 2 (* 4 6))
(+ 3 5 7))
Evaluating Combinations
Each combination is represented by a node with branches corresponding to the
operator and the operands of the combination stemming from it.
The terminal nodes (that is, nodes with no branches stemming from them)
represent either operators or numbers. Viewing evaluation in terms of the tree,
we can imagine that the values of the operands percolate upward, starting from
the terminal nodes and then combining at higher and higher levels.
the ``percolate values upward'' form of the evaluation rule is an example of a
general kind of process known as tree accumulation.
Procedure Definitions
A much more powerful abstraction technique by which a compound operation can
be given a name and then referred to as a unit.
(define (square x) (* x x))
We can understand this in the following way:
(define (square x) (* x x))
square something, multiply it by itself.
We have here a compound procedure, which has been given the name square. The
procedure represents the operation of multiplying something by itself. The thing to
be multiplied is given a local name, x, which plays the same role that a pronoun
plays in natural language. Evaluating the definition creates this compound
procedure and associates it with the name square
The Substitution Model for Procedure Application
There Exists 2 type of Orders to Evaluate any Procedure in LISP.
● Normal Order
● Applicative Order
● Normal Order :- the interpreter first evaluates the operator and operands
and then applies the resulting procedure to the resulting arguments
Normal Order
Normal Order Example :-
(sum-of-squares (+ 5 1) (* 5 2))
(+ (square 6) (square 10 ) )
If we use the definition of square, this reduces to
(+ (* 6 6) (* 10 10))
which reduces by multiplication to
(+ 36 100)
and finally to
136
Applicative Order
● Applicative Order :- An alternative evaluation model would not evaluate the operands until their
values were needed. Instead it would first substitute operand expressions for parameters until it
obtained an expression involving only primitive operators, and would then perform the evaluation.
(sum-of-squares (+ 5 1) (* 5 2))
(+ (square (+ 5 1)) (square (* 5 2)) )
(+ (* (+ 5 1) (+ 5 1)) (* (* 5 2) (* 5 2)))
followed by the reductions
(+ (* 6 6) (* 10 10))
(+ 36 100)
136
Conditional Expressions
Most of the time situation arises when we need to perform some operation based on
some condition.
For Example :- Finding the Absolute value.
Condition will be :-
● IF x > 0 return x
IF x = 0 return 0
IF x < 0 return -x
This construct is called a case analysis, and there is a special form in Lisp for notating such
a case analysis. It is called cond (which stands for ‘‘conditional’’), and it is used as follows:
● (define (abs x)
(cond ((> x 0) x)
((= x 0) 0)
((< x 0) (- x))))
Linear Recursion and Iteration
● Recursion:- the repeated application of a recursive procedure or definition.
● Iteration:- the repetition of a process.
Example:- Finding the Factorial of some number.This can easily implemented in 2
ways .
● Using Recusrion
● Using Iteration.
Linear Recursion
● Factorial Using the Recursion in LISP
(define (factorial n)
(if (= n 1)
1
(* n (factorial (- n 1)))))
● Here, Time Complexity is O(x)
● Space Complexity is O(x)
Linear Recursion
Iteration
● Factorial Using the Iteration in LISP
(define (factorial n)
(fact-iter 1 1 n))
(define (fact-iter product counter max-count)
(if (> counter max-count)
product
(fact-iter (* counter product)
(+ counter 1)
max-count)))
● Here, Time Complexity is O(x)
● Space Complexity is O(1)
Iteration
References
● http://mitpress.mit.edu/sicp/
Thank You

More Related Content

What's hot (20)

Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
Muhammed Afsal Villan
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
Dattatray Gandhmal
 
Intro automata theory
Intro automata theory Intro automata theory
Intro automata theory
Rajendran
 
Python - gui programming (tkinter)
Python - gui programming (tkinter)Python - gui programming (tkinter)
Python - gui programming (tkinter)
Learnbay Datascience
 
Yacc
YaccYacc
Yacc
BBDITM LUCKNOW
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
Tanzeela_Hussain
 
Lex
LexLex
Lex
BBDITM LUCKNOW
 
Shell programming
Shell programmingShell programming
Shell programming
Moayad Moawiah
 
Recursion
RecursionRecursion
Recursion
Ssankett Negi
 
Lisp
LispLisp
Lisp
Fraboni Ec
 
Assemblers
AssemblersAssemblers
Assemblers
Dattatray Gandhmal
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
RaginiJain21
 
recursion.ppt
recursion.pptrecursion.ppt
recursion.ppt
NISHASOMSCS113
 
Regular expressions in Python
Regular expressions in PythonRegular expressions in Python
Regular expressions in Python
Sujith Kumar
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
Dattatray Gandhmal
 
Pseudocode
PseudocodePseudocode
Pseudocode
Harsha Madushanka
 
TOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of ComputationTOC 1 | Introduction to Theory of Computation
TOC 1 | Introduction to Theory of Computation
Mohammad Imam Hossain
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
Venkateswara Babu Ravipati
 

Similar to Introduction to Programming in LISP (20)

Lisp
LispLisp
Lisp
huzaifa ramzan
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
prakashvs7
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
Nilt1234
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp language
David Gu
 
Report about the LISP Programming Language
Report about the LISP Programming LanguageReport about the LISP Programming Language
Report about the LISP Programming Language
maldosmelandrew
 
AI Programming language (LISP)
AI Programming language (LISP)AI Programming language (LISP)
AI Programming language (LISP)
Dr. SURBHI SAROHA
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
LISP Content
 
Lecture 2 lisp-Overview
Lecture 2 lisp-OverviewLecture 2 lisp-Overview
Lecture 2 lisp-Overview
Student at University Of Malakand, Pakistan
 
Gentle Introduction To Lisp
Gentle Introduction To LispGentle Introduction To Lisp
Gentle Introduction To Lisp
Damien Garaud
 
Principles of programming language intro
Principles of programming language introPrinciples of programming language intro
Principles of programming language intro
RajeswariA8
 
Expressions in c++
 Expressions in c++ Expressions in c++
Expressions in c++
zeeshan turi
 
(Ai lisp)
(Ai lisp)(Ai lisp)
(Ai lisp)
Ravi Rao
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence)
wahab khan
 
Lisp and scheme i
Lisp and scheme iLisp and scheme i
Lisp and scheme i
Luis Goldster
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptx
PremBorse1
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
Sigma Software
 
Funtional Programming
Funtional ProgrammingFuntional Programming
Funtional Programming
Girish Khanzode
 
201801 CSE240 Lecture 17
201801 CSE240 Lecture 17201801 CSE240 Lecture 17
201801 CSE240 Lecture 17
Javier Gonzalez-Sanchez
 
test(3)arithmetic in c
test(3)arithmetic in ctest(3)arithmetic in c
test(3)arithmetic in c
Jaya Malathy
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
baran19901990
 
AI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptxAI UNIT-4 Final (2).pptx
AI UNIT-4 Final (2).pptx
prakashvs7
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
Nilt1234
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp language
David Gu
 
Report about the LISP Programming Language
Report about the LISP Programming LanguageReport about the LISP Programming Language
Report about the LISP Programming Language
maldosmelandrew
 
AI Programming language (LISP)
AI Programming language (LISP)AI Programming language (LISP)
AI Programming language (LISP)
Dr. SURBHI SAROHA
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
LISP Content
 
Gentle Introduction To Lisp
Gentle Introduction To LispGentle Introduction To Lisp
Gentle Introduction To Lisp
Damien Garaud
 
Principles of programming language intro
Principles of programming language introPrinciples of programming language intro
Principles of programming language intro
RajeswariA8
 
Expressions in c++
 Expressions in c++ Expressions in c++
Expressions in c++
zeeshan turi
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence)
wahab khan
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptx
PremBorse1
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
Sigma Software
 
test(3)arithmetic in c
test(3)arithmetic in ctest(3)arithmetic in c
test(3)arithmetic in c
Jaya Malathy
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
baran19901990
 
Ad

More from Knoldus Inc. (20)

Angular Hydration Presentation (FrontEnd)
Angular Hydration Presentation (FrontEnd)Angular Hydration Presentation (FrontEnd)
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Optimizing Test Execution: Heuristic Algorithm for Self-HealingOptimizing Test Execution: Heuristic Algorithm for Self-Healing
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
Self-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - HealeniumSelf-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
Kanban Metrics Presentation (Project Management)
Kanban Metrics Presentation (Project Management)Kanban Metrics Presentation (Project Management)
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
Java 17 features and implementation.pptx
Java 17 features and implementation.pptxJava 17 features and implementation.pptx
Java 17 features and implementation.pptx
Knoldus Inc.
 
Chaos Mesh Introducing Chaos in Kubernetes
Chaos Mesh Introducing Chaos in KubernetesChaos Mesh Introducing Chaos in Kubernetes
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
GraalVM - A Step Ahead of JVM Presentation
GraalVM - A Step Ahead of JVM PresentationGraalVM - A Step Ahead of JVM Presentation
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
DAPR - Distributed Application Runtime Presentation
DAPR - Distributed Application Runtime PresentationDAPR - Distributed Application Runtime Presentation
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
Introduction to Azure Virtual WAN Presentation
Introduction to Azure Virtual WAN PresentationIntroduction to Azure Virtual WAN Presentation
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
Introduction to Argo Rollouts Presentation
Introduction to Argo Rollouts PresentationIntroduction to Argo Rollouts Presentation
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
Intro to Azure Container App Presentation
Intro to Azure Container App PresentationIntro to Azure Container App Presentation
Intro to Azure Container App Presentation
Knoldus Inc.
 
Insights Unveiled Test Reporting and Observability Excellence
Insights Unveiled Test Reporting and Observability ExcellenceInsights Unveiled Test Reporting and Observability Excellence
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
Introduction to Splunk Presentation (DevOps)
Introduction to Splunk Presentation (DevOps)Introduction to Splunk Presentation (DevOps)
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
Code Camp - Data Profiling and Quality Analysis Framework
Code Camp - Data Profiling and Quality Analysis FrameworkCode Camp - Data Profiling and Quality Analysis Framework
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
AWS: Messaging Services in AWS Presentation
AWS: Messaging Services in AWS PresentationAWS: Messaging Services in AWS Presentation
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
Amazon Cognito: A Primer on Authentication and Authorization
Amazon Cognito: A Primer on Authentication and AuthorizationAmazon Cognito: A Primer on Authentication and Authorization
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
ZIO Http A Functional Approach to Scalable and Type-Safe Web DevelopmentZIO Http A Functional Approach to Scalable and Type-Safe Web Development
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
Managing State & HTTP Requests In Ionic.
Managing State & HTTP Requests In Ionic.Managing State & HTTP Requests In Ionic.
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 
Angular Hydration Presentation (FrontEnd)
Angular Hydration Presentation (FrontEnd)Angular Hydration Presentation (FrontEnd)
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Optimizing Test Execution: Heuristic Algorithm for Self-HealingOptimizing Test Execution: Heuristic Algorithm for Self-Healing
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
Self-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - HealeniumSelf-Healing Test Automation Framework - Healenium
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
Kanban Metrics Presentation (Project Management)
Kanban Metrics Presentation (Project Management)Kanban Metrics Presentation (Project Management)
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
Java 17 features and implementation.pptx
Java 17 features and implementation.pptxJava 17 features and implementation.pptx
Java 17 features and implementation.pptx
Knoldus Inc.
 
Chaos Mesh Introducing Chaos in Kubernetes
Chaos Mesh Introducing Chaos in KubernetesChaos Mesh Introducing Chaos in Kubernetes
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
GraalVM - A Step Ahead of JVM Presentation
GraalVM - A Step Ahead of JVM PresentationGraalVM - A Step Ahead of JVM Presentation
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)Nomad by HashiCorp Presentation (DevOps)
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
DAPR - Distributed Application Runtime Presentation
DAPR - Distributed Application Runtime PresentationDAPR - Distributed Application Runtime Presentation
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
Introduction to Azure Virtual WAN Presentation
Introduction to Azure Virtual WAN PresentationIntroduction to Azure Virtual WAN Presentation
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
Introduction to Argo Rollouts Presentation
Introduction to Argo Rollouts PresentationIntroduction to Argo Rollouts Presentation
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
Intro to Azure Container App Presentation
Intro to Azure Container App PresentationIntro to Azure Container App Presentation
Intro to Azure Container App Presentation
Knoldus Inc.
 
Insights Unveiled Test Reporting and Observability Excellence
Insights Unveiled Test Reporting and Observability ExcellenceInsights Unveiled Test Reporting and Observability Excellence
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
Introduction to Splunk Presentation (DevOps)
Introduction to Splunk Presentation (DevOps)Introduction to Splunk Presentation (DevOps)
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
Code Camp - Data Profiling and Quality Analysis Framework
Code Camp - Data Profiling and Quality Analysis FrameworkCode Camp - Data Profiling and Quality Analysis Framework
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
AWS: Messaging Services in AWS Presentation
AWS: Messaging Services in AWS PresentationAWS: Messaging Services in AWS Presentation
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
Amazon Cognito: A Primer on Authentication and Authorization
Amazon Cognito: A Primer on Authentication and AuthorizationAmazon Cognito: A Primer on Authentication and Authorization
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
ZIO Http A Functional Approach to Scalable and Type-Safe Web DevelopmentZIO Http A Functional Approach to Scalable and Type-Safe Web Development
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
Managing State & HTTP Requests In Ionic.
Managing State & HTTP Requests In Ionic.Managing State & HTTP Requests In Ionic.
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 
Ad

Recently uploaded (20)

SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.pptSAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptxMicrosoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWSWomen in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Intelli grow
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Transmission Media. (Computer Networks)
Transmission Media.  (Computer Networks)Transmission Media.  (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdfLooking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and DartStep by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free DownloadWondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized InnovationAdvanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FMEAutomated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.pptSAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptxMicrosoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWSWomen in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
AI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA TechnologiesAI and Deep Learning with NVIDIA Technologies
AI and Deep Learning with NVIDIA Technologies
SandeepKS52
 
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Intelli grow
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 WebinarPorting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
Transmission Media. (Computer Networks)
Transmission Media.  (Computer Networks)Transmission Media.  (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdfLooking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and DartStep by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free DownloadWondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized InnovationAdvanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FMEAutomated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 

Introduction to Programming in LISP

  • 1. Introduction to Programming in LISP ... Akash Sethi Software Consultant Knoldus Software LLP.
  • 2. Agenda ● Why LISP ● What is LISP ● Timeline of Lisp dialects ● Fundamentals of LISP ● Expression Evaluation in LISP ● Defining Variables ● Evaluating Combinations ● Procedure Definitions ● The Substitution Model for Procedure Application ● Conditional Expressions ● Linear Recursion and Iteration
  • 3. Why LISP The Key motivations behind Learning LISP are as follow:- ● Some of the features of Scala are inherited from LISP. ● Scala is Hybrid Programming Language. It consist features of both Functional and Object Oriented Programming Language. ● We most of us know the Object Oriented programming Language like JAVA, C++ etc. ● Undersanding the Basics of LISP can help us understand the other functional programming languages like clojure.
  • 4. What is LISP ● LISP, an acronym for list processing, is a programming language that was designed for easy manipulation of data strings. ● Developed in 1959 by John McCarthy, ● It is a commonly used language for artificial intelligence (AI) programming. ● It is one of the oldest programming languages still in relatively wide use. ● All program code is written as s-expressions, or parenthesized lists.
  • 5. Timeline of Lisp dialects
  • 6. What is LISP ● LISP, an acronym for list processing, is a programming language that was designed for easy manipulation of data strings. ● Developed in 1959 by John McCarthy, ● It is a commonly used language for artificial intelligence (AI) programming. ● It is one of the oldest programming languages still in relatively wide use. ● All program code is written as s-expressions, or parenthesized lists.
  • 7. Fundamentals of LISP Every powerful language has three mechanisms for accomplishing this :- ● Primitive expressions, which represent the simplest entities the language is concerned with, ● Means of combination, by which compound elements are built from simpler ones, and ● Means of abstraction, by which compound elements can be named and manipulated as units.
  • 8. Expression Evaluation in LISP Expressions representing numbers may be combined with an expression representing a primitive procedure (such as + or *) to form a compound expression that represents the application of the procedure to those numbers. For example:- (+ 137 349) 486 (- 1000 334) 666 (* 5 99) 495 (/ 10 5) 2
  • 9. Expression Evaluation in LISP Expressions such as these, formed by delimiting a list of expressions within parentheses in order to denote procedure application, are called combinations. ● The leftmost element in the list is called the operator, and the other elements are called operands. ● The value of a combination is obtained by applying the procedure specified by the operator to the arguments that are the values of the operands. ● The convention of placing the operator to the left of the operands is known as prefix notation. ● No ambiguity can arise, because the operator is always the leftmost element and the entire combination is delimited by the parentheses.
  • 10. Defining Variables Define is LISP language's simplest means of abstraction, for it allows us to use simple names to refer to the results of compound operation. (define pi 3.14159) (define radius 10) (* pi (* radius radius)) 314.159 (define circumference (* 2 pi radius)) Circumference 62.8318
  • 11. Evaluating Combinations To evaluate a combination, do the following: ● 1. Evaluate the subexpressions of the combination. ● 2. Apply the procedure that is the value of the leftmost subexpression (the operator) to the arguments that are the values of the other subexpressions (the operands). (* (+ 2 (* 4 6)) (+ 3 5 7))
  • 12. Evaluating Combinations Each combination is represented by a node with branches corresponding to the operator and the operands of the combination stemming from it. The terminal nodes (that is, nodes with no branches stemming from them) represent either operators or numbers. Viewing evaluation in terms of the tree, we can imagine that the values of the operands percolate upward, starting from the terminal nodes and then combining at higher and higher levels. the ``percolate values upward'' form of the evaluation rule is an example of a general kind of process known as tree accumulation.
  • 13. Procedure Definitions A much more powerful abstraction technique by which a compound operation can be given a name and then referred to as a unit. (define (square x) (* x x)) We can understand this in the following way: (define (square x) (* x x)) square something, multiply it by itself. We have here a compound procedure, which has been given the name square. The procedure represents the operation of multiplying something by itself. The thing to be multiplied is given a local name, x, which plays the same role that a pronoun plays in natural language. Evaluating the definition creates this compound procedure and associates it with the name square
  • 14. The Substitution Model for Procedure Application There Exists 2 type of Orders to Evaluate any Procedure in LISP. ● Normal Order ● Applicative Order ● Normal Order :- the interpreter first evaluates the operator and operands and then applies the resulting procedure to the resulting arguments
  • 15. Normal Order Normal Order Example :- (sum-of-squares (+ 5 1) (* 5 2)) (+ (square 6) (square 10 ) ) If we use the definition of square, this reduces to (+ (* 6 6) (* 10 10)) which reduces by multiplication to (+ 36 100) and finally to 136
  • 16. Applicative Order ● Applicative Order :- An alternative evaluation model would not evaluate the operands until their values were needed. Instead it would first substitute operand expressions for parameters until it obtained an expression involving only primitive operators, and would then perform the evaluation. (sum-of-squares (+ 5 1) (* 5 2)) (+ (square (+ 5 1)) (square (* 5 2)) ) (+ (* (+ 5 1) (+ 5 1)) (* (* 5 2) (* 5 2))) followed by the reductions (+ (* 6 6) (* 10 10)) (+ 36 100) 136
  • 17. Conditional Expressions Most of the time situation arises when we need to perform some operation based on some condition. For Example :- Finding the Absolute value. Condition will be :- ● IF x > 0 return x IF x = 0 return 0 IF x < 0 return -x This construct is called a case analysis, and there is a special form in Lisp for notating such a case analysis. It is called cond (which stands for ‘‘conditional’’), and it is used as follows: ● (define (abs x) (cond ((> x 0) x) ((= x 0) 0) ((< x 0) (- x))))
  • 18. Linear Recursion and Iteration ● Recursion:- the repeated application of a recursive procedure or definition. ● Iteration:- the repetition of a process. Example:- Finding the Factorial of some number.This can easily implemented in 2 ways . ● Using Recusrion ● Using Iteration.
  • 19. Linear Recursion ● Factorial Using the Recursion in LISP (define (factorial n) (if (= n 1) 1 (* n (factorial (- n 1))))) ● Here, Time Complexity is O(x) ● Space Complexity is O(x)
  • 21. Iteration ● Factorial Using the Iteration in LISP (define (factorial n) (fact-iter 1 1 n)) (define (fact-iter product counter max-count) (if (> counter max-count) product (fact-iter (* counter product) (+ counter 1) max-count))) ● Here, Time Complexity is O(x) ● Space Complexity is O(1)